firmware-ota (#2)

Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
2026-03-03 22:47:03 -05:00
parent 9bce74e027
commit 0ec7f7f08a
21 changed files with 1065 additions and 255 deletions

View File

@@ -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)
{