Reputation: 109
As i Understand the rollback feature is supposed to get implemented and the app is supposed to get into Diagnosis mode as soon as i enable APP_ROLLBACK_ENABLE Feature, yet my app is not going into diagnosis state. The state is mentioned in code :
As it can be seen here that my state is supposedly not ESP_VERIFY
esp_partition_get_sha256(esp_ota_get_running_partition(), sha_256);
print_sha256(sha_256, "SHA-256 for current firmware: ");
const esp_partition_t *running = esp_ota_get_running_partition();
esp_ota_img_states_t ota_state;
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
ESP_LOGI(TAG, "Get State Partition was Successfull");
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
// run diagnostic function ...
bool diagnostic_is_ok = true;
if (diagnostic_is_ok) {
ESP_LOGI(TAG, "Diagnostics completed successfully! Continuing execution ...");
esp_ota_mark_app_valid_cancel_rollback();
} else {
ESP_LOGE(TAG, "Diagnostics failed! Start rollback to the previous version ...");
esp_ota_mark_app_invalid_rollback_and_reboot();
}
}
}
EXPECTED: App Diagnosis should occur ACTUAL: App Diagnosis code is not getting state :ESP_OTA_IMG_PENDING_VERIFY
Upvotes: 2
Views: 1367
Reputation: 11
When you download your firmware first time, OTADATA will be erased. In bootloader, it set to the right ota_seq and ESP_OTA_IMG_VALID state. It means that in an application your code will be not checked by the diagnostic code, because you have only one bootable app and rollback is not possible.
After OTA your app has ESP_OTA_IMG_PENDING_VERIFY
state and only while first booting this part of code should be executed. This state will be changed esp_ota_mark_app_valid_cancel_rollback()
function to ESP_OTA_IMG_VALID.
Upvotes: 1