Help with ESP32 OTA Rollback Option

helpwithesp32
Posts: 7
Joined: Wed Jan 18, 2023 5:55 am

Help with ESP32 OTA Rollback Option

Postby helpwithesp32 » Thu Jan 19, 2023 4:10 am

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?

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: Help with ESP32 OTA Rollback Option

Postby ESP_Mahavir » Sun Jan 22, 2023 2:10 pm

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.

helpwithesp32
Posts: 7
Joined: Wed Jan 18, 2023 5:55 am

Re: Help with ESP32 OTA Rollback Option

Postby helpwithesp32 » Sun Jan 22, 2023 8:14 pm

@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?

ESP_Mahavir
Posts: 190
Joined: Wed Jan 24, 2018 6:51 am

Re: Help with ESP32 OTA Rollback Option

Postby ESP_Mahavir » Mon Jan 23, 2023 3:36 am

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.

helpwithesp32
Posts: 7
Joined: Wed Jan 18, 2023 5:55 am

Re: Help with ESP32 OTA Rollback Option

Postby helpwithesp32 » Thu Jan 26, 2023 2:01 am

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.

helpwithesp32
Posts: 7
Joined: Wed Jan 18, 2023 5:55 am

Re: Help with ESP32 OTA Rollback Option

Postby helpwithesp32 » Thu Feb 09, 2023 11:50 pm

Hi @ESP_Mahavir,
Did you see my last post?

Thanks
Robert

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 104 guests