From 1f432d9d8a8820d2e2ad368ae7c6302e2b9d2292 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 29 Apr 2026 12:30:51 -0500 Subject: [PATCH] hold watchdog for part write, could timeout and brick --- esphome/components/ota/ota_backend_esp_idf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/ota/ota_backend_esp_idf.cpp b/esphome/components/ota/ota_backend_esp_idf.cpp index 70a2d14aae..503a1fbbe6 100644 --- a/esphome/components/ota/ota_backend_esp_idf.cpp +++ b/esphome/components/ota/ota_backend_esp_idf.cpp @@ -305,6 +305,12 @@ OTAResponseTypes IDFOTABackend::update_partition_table() { // Deinitialize NVS to prevent unwanted flash writes nvs_flash_deinit(); + // Hold the watchdog open for the entire critical section: optional app copy, partition-table + // erase/write, and boot partition selection. None of the steps below should yield long enough + // to require a refresh, but bundling them under a single guard avoids spurious resets if the + // underlying ESP-IDF calls take longer than expected on a given chip variant. + watchdog::WatchdogManager watchdog(15000); + // Copy the running app partition to new position if needed if (new_app_part_index == -1) { const esp_partition_t *running_app_part = nullptr; @@ -324,7 +330,6 @@ OTAResponseTypes IDFOTABackend::update_partition_table() { ESP_LOGD(TAG, "Copying running app from 0x%X to 0x%X (size: 0x%X)", running_app_part->address, app_copy_target_part->address, running_app_size); - watchdog::WatchdogManager watchdog(15000); err = esp_partition_copy(app_copy_target_part, 0, running_app_part, 0, running_app_size); if (err != ESP_OK) {