Help with ESP32 OTA Rollback Option
-
- Posts: 7
- Joined: Wed Jan 18, 2023 5:55 am
Help with ESP32 OTA Rollback Option
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?
-
- Posts: 190
- Joined: Wed Jan 24, 2018 6:51 am
Re: Help with ESP32 OTA Rollback Option
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
Please refer to https://blog.espressif.com/ota-updates- ... 5438e30c12 for more information.
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();
Mahavir
https://github.com/mahavirj/
https://github.com/mahavirj/
-
- Posts: 7
- Joined: Wed Jan 18, 2023 5:55 am
Re: Help with ESP32 OTA Rollback Option
@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?
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?
-
- Posts: 190
- Joined: Wed Jan 24, 2018 6:51 am
Re: Help with ESP32 OTA Rollback Option
Hello,
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.Thank you for the response. Where should I put these lines of code in my program?
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.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?
Mahavir
https://github.com/mahavirj/
https://github.com/mahavirj/
-
- Posts: 7
- Joined: Wed Jan 18, 2023 5:55 am
Re: Help with ESP32 OTA Rollback Option
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.
// 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.
-
- Posts: 7
- Joined: Wed Jan 18, 2023 5:55 am
Re: Help with ESP32 OTA Rollback Option
Hi @ESP_Mahavir,
Did you see my last post?
Thanks
Robert
Did you see my last post?
Thanks
Robert
Who is online
Users browsing this forum: jesper and 68 guests