From 9b3f8f6f6e66501ebc967b788705dcf5b83d7ba5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 29 Apr 2026 12:34:25 -0500 Subject: [PATCH] explict name --- esphome/components/ota/ota_backend_esp_idf.cpp | 2 +- esphome/components/ota/ota_backend_esp_idf.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/esphome/components/ota/ota_backend_esp_idf.cpp b/esphome/components/ota/ota_backend_esp_idf.cpp index 15b83e400e9..2a08bece9a6 100644 --- a/esphome/components/ota/ota_backend_esp_idf.cpp +++ b/esphome/components/ota/ota_backend_esp_idf.cpp @@ -98,7 +98,7 @@ void IDFOTABackend::set_update_md5(const char *expected_md5) { OTAResponseTypes IDFOTABackend::write(uint8_t *data, size_t len) { #ifdef USE_OTA_PARTITIONS if (this->ota_type_ == ota::OTA_TYPE_UPDATE_PARTITION_TABLE) { - if (len > OTA_BUFFER_SIZE - this->buf_written_) { + if (len > PARTITION_TABLE_BUFFER_SIZE - this->buf_written_) { ESP_LOGE(TAG, "Wrong partition table size"); return OTA_RESPONSE_ERROR_PARTITION_TABLE_VERIFY; } diff --git a/esphome/components/ota/ota_backend_esp_idf.h b/esphome/components/ota/ota_backend_esp_idf.h index 6192f5f9690..d9de8a5eed2 100644 --- a/esphome/components/ota/ota_backend_esp_idf.h +++ b/esphome/components/ota/ota_backend_esp_idf.h @@ -10,7 +10,10 @@ namespace esphome::ota { #ifdef USE_OTA_PARTITIONS -static constexpr size_t OTA_BUFFER_SIZE = ESP_PARTITION_TABLE_MAX_LEN; // 0xC00 +// Dedicated staging buffer size for the new partition table image. Must be at least +// ESP_PARTITION_TABLE_MAX_LEN (0xC00) so the entire partition table fits before verification. +// Kept separate from any OTA chunk-transfer buffer to avoid coupling unrelated sizes. +static constexpr size_t PARTITION_TABLE_BUFFER_SIZE = ESP_PARTITION_TABLE_MAX_LEN; // 0xC00 #endif #ifdef USE_OTA_PARTITIONS @@ -43,7 +46,7 @@ class IDFOTABackend final { bool md5_set_{false}; #ifdef USE_OTA_PARTITIONS ota::OTAType ota_type_{ota::OTA_TYPE_UPDATE_APP}; - uint8_t buf_[OTA_BUFFER_SIZE]; + uint8_t buf_[PARTITION_TABLE_BUFFER_SIZE]; size_t buf_written_{0}; size_t image_size_{0}; const esp_partition_t *partition_table_part_{nullptr};