Made everything needed to update firmware. Added the bundle to upload both front and backendin a bundle. Added magic number for more safety
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
|
||||
// Project
|
||||
#include "appstate.hpp"
|
||||
#include "types.hpp"
|
||||
@@ -59,6 +58,7 @@ internal esp_err_t api_ota_frontend_handler(httpd_req_t *req)
|
||||
|
||||
int total_read = 0;
|
||||
int remaining = req->content_len;
|
||||
bool first_chunk = true;
|
||||
|
||||
while (remaining > 0)
|
||||
{
|
||||
@@ -77,6 +77,21 @@ internal esp_err_t api_ota_frontend_handler(httpd_req_t *req)
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (first_chunk)
|
||||
{
|
||||
if ((uint8_t)buf[0] == 0xE9)
|
||||
{
|
||||
ESP_LOGE("OTA", "Magic 0xE9 detected. This looks like a FIRMWARE bin, "
|
||||
"but you are uploading to FRONTEND slot!");
|
||||
free(buf);
|
||||
httpd_resp_send_err(
|
||||
req, HTTPD_400_BAD_REQUEST,
|
||||
"Invalid file: This is a Firmware binary, not a UI binary.");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
first_chunk = false;
|
||||
}
|
||||
|
||||
err = esp_partition_write(partition, total_read, buf, recv_len);
|
||||
if (err != ESP_OK)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user