Page 1 of 1

Help with ESP32 OTA Rollback Option

Posted: Thu Jan 19, 2023 4:10 am
by helpwithesp32
On the ESP32 (micropython, not Arduino) for OTA updates, do rollbacks occur by default, or does the CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE need to be set in the menuconfig for this to happen? Also, does any manual code need to be added to the firmware for rollback to occur?

Re: Help with ESP32 OTA Rollback Option

Posted: Sun Jan 22, 2023 2:10 pm
by ESP_Mahavir
Yes, rollback feature has following 2 requirements:

1. Enable `CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE` option in the project
2. Use following APIs in the application to set correct rollback status

Code: Select all

// Mark firmware as valid and cancel rollback process
esp_ota_mark_app_valid_cancel_rollback();

// Mark firmware as invalid and rollback to previous firmware
esp_ota_mark_app_invalid_rollback_and_reboot();
Please refer to https://blog.espressif.com/ota-updates- ... 5438e30c12 for more information.

Re: Help with ESP32 OTA Rollback Option

Posted: Sun Jan 22, 2023 8:14 pm
by helpwithesp32
@ESP_Mahavir

Thank you for the response. Where should I put these lines of code in my program?

Also, I don't understand how I could use the invalid line. It seems invalid should be assumed if the valid line is never run?

Re: Help with ESP32 OTA Rollback Option

Posted: Mon Jan 23, 2023 3:36 am
by ESP_Mahavir
Hello,
Thank you for the response. Where should I put these lines of code in my program?
This you will have to decide on when you can safely consider the new image as valid and cancel the rollback process. In some case, a new firmware connecting to Wi-Fi network or a cloud endpoint is considered to be a good checkpoint. Please see the blog post I linked in my earlier comment.
Also, I don't understand how I could use the invalid line. It seems invalid should be assumed if the valid line is never run?
Calling the API `esp_ota_mark_app_invalid_rollback_and_reboot` is optional and can be based on some diagnostic runs on the new firmware image. Please have a look at the examples under `examples/system/ota/` from IDF and how you can use different APIs.

Re: Help with ESP32 OTA Rollback Option

Posted: Thu Jan 26, 2023 2:01 am
by helpwithesp32
Thank you. So if I enable the option, the minimum I need to do is add this line to my code?

// Mark firmware as valid and cancel rollback process
esp_ota_mark_app_valid_cancel_rollback();

How quickly after startup do I need to call this function before it auto rolls back to the previous version? Assuming that is what happens.

Re: Help with ESP32 OTA Rollback Option

Posted: Thu Feb 09, 2023 11:50 pm
by helpwithesp32
Hi @ESP_Mahavir,
Did you see my last post?

Thanks
Robert