fix: add check to ensure OTA buffer size for 16-byte aligned

This commit added guide to, round off OTA written size to allowed
aignmnet when flash ecnryption enabled.
This commit is contained in:
nilesh.kale
2025-09-15 11:53:37 +05:30
parent 46def9972a
commit 873fd18c5a
2 changed files with 13 additions and 0 deletions

View File

@@ -14,6 +14,7 @@
#include <sys/param.h>
#include <inttypes.h>
#include "esp_check.h"
#include "esp_flash_encrypt.h"
#include "hal/efuse_hal.h"
ESP_EVENT_DEFINE_BASE(ESP_HTTPS_OTA_EVENT);
@@ -528,6 +529,14 @@ esp_err_t esp_https_ota_begin(const esp_https_ota_config_t *ota_config, esp_http
}
const int alloc_size = MAX(ota_config->http_config->buffer_size, DEFAULT_OTA_BUF_SIZE);
if (ota_config->ota_resumption) {
if (esp_flash_encryption_enabled() && (alloc_size & 0xFU) != 0) {
// For FE case the flash is written in multiples of 16 bytes
ESP_LOGE(TAG, "Buffer size must be multiple of 16 bytes for FE and ota resumption case");
goto http_cleanup;
}
}
if (ota_config->buffer_caps != 0) {
https_ota_handle->ota_upgrade_buf = (char *)heap_caps_malloc(alloc_size, ota_config->buffer_caps);
} else {