Page 1 of 1

Problems with ROLLBACK

Posted: Thu Apr 11, 2019 1:48 pm
by dhananjay.sutariya
Hi all,
Even After configuring the ROLLBACK macro in the sdk config. My App is not going into self diagnosis code . This one:

Code: Select all

    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();
            }
        }
    }
Please Help.

Re: Problems with ROLLBACK

Posted: Tue Apr 16, 2019 2:10 am
by Konstantin
Hi, dhananjay.sutariya.

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.