From 1ef6637ee2356364bd28dc0d92e0d051c7a1b285 Mon Sep 17 00:00:00 2001 From: Dmitriy Shilin Date: Fri, 26 Dec 2025 14:52:47 +0100 Subject: [PATCH] Properly set boot partition after OTA --- .../target_esp32/native_updater.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/components/ocs_system/target_esp32/native_updater.cpp b/components/ocs_system/target_esp32/native_updater.cpp index 688fa0ee..2e0d3e0a 100644 --- a/components/ocs_system/target_esp32/native_updater.cpp +++ b/components/ocs_system/target_esp32/native_updater.cpp @@ -51,18 +51,6 @@ status::StatusCode NativeUpdater::write(const uint8_t* buf, size_t len) { } status::StatusCode NativeUpdater::commit() { - configASSERT(!committed_); - - const auto partition = esp_ota_get_next_update_partition(nullptr); - configASSERT(partition); - - const auto err = esp_ota_set_boot_partition(partition); - if (err != ESP_OK) { - ocs_loge(log_tag, "esp_ota_set_boot_partition(): %s", esp_err_to_name(err)); - - return status::StatusCode::Error; - } - committed_ = true; return status::StatusCode::OK; @@ -72,12 +60,22 @@ status::StatusCode NativeUpdater::end() { configASSERT(handle_); if (committed_) { - const auto err = esp_ota_end(handle_); + auto err = esp_ota_end(handle_); if (err != ESP_OK) { ocs_loge(log_tag, "esp_ota_end(): %s", esp_err_to_name(err)); return status::StatusCode::Error; } + + const auto partition = esp_ota_get_next_update_partition(nullptr); + configASSERT(partition); + + err = esp_ota_set_boot_partition(partition); + if (err != ESP_OK) { + ocs_loge(log_tag, "esp_ota_set_boot_partition(): %s", esp_err_to_name(err)); + + return status::StatusCode::Error; + } } else { const auto err = esp_ota_abort(handle_); if (err != ESP_OK) {