Skip to content

Commit fd6f508

Browse files
committed
Properly set boot partition after OTA
1 parent b8fb24f commit fd6f508

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

components/ocs_system/target_esp32/native_updater.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,6 @@ status::StatusCode NativeUpdater::write(const uint8_t* buf, size_t len) {
5151
}
5252

5353
status::StatusCode NativeUpdater::commit() {
54-
configASSERT(!committed_);
55-
56-
const auto partition = esp_ota_get_next_update_partition(nullptr);
57-
configASSERT(partition);
58-
59-
const auto err = esp_ota_set_boot_partition(partition);
60-
if (err != ESP_OK) {
61-
ocs_loge(log_tag, "esp_ota_set_boot_partition(): %s", esp_err_to_name(err));
62-
63-
return status::StatusCode::Error;
64-
}
65-
6654
committed_ = true;
6755

6856
return status::StatusCode::OK;
@@ -72,12 +60,22 @@ status::StatusCode NativeUpdater::end() {
7260
configASSERT(handle_);
7361

7462
if (committed_) {
75-
const auto err = esp_ota_end(handle_);
63+
auto err = esp_ota_end(handle_);
7664
if (err != ESP_OK) {
7765
ocs_loge(log_tag, "esp_ota_end(): %s", esp_err_to_name(err));
7866

7967
return status::StatusCode::Error;
8068
}
69+
70+
const auto partition = esp_ota_get_next_update_partition(nullptr);
71+
configASSERT(partition);
72+
73+
err = esp_ota_set_boot_partition(partition);
74+
if (err != ESP_OK) {
75+
ocs_loge(log_tag, "esp_ota_set_boot_partition(): %s", esp_err_to_name(err));
76+
77+
return status::StatusCode::Error;
78+
}
8179
} else {
8280
const auto err = esp_ota_abort(handle_);
8381
if (err != ESP_OK) {

0 commit comments

Comments
 (0)