My question in this topic is about the OTA update logic itself, I have my code running inside ESP32-WROOM-32E and the update itself is running smoothly.
My goal is to implement a logic in such a way that the device won’t perform an OTA update to a state that it can’t perform OTA again.
I thought that using the rollback functions of the esp_https_ota library was the solution, but it seems that once the ESP32 boots from the new partition (the one that you downloaded the new version to) the former program is erased from flash, therefore you cannot go back to it. Can anyone give me some suggestions on how I can go on with this idea?
Does anyone have any ideas about this?
So, after reading some documentation over here (Over The Air Updates (OTA) - ESP32 - — ESP-IDF Programming Guide latest documentation) I was finally able to make some progress on this matter, anyway, there are still some problems I’d like some help with.
At the rollback process part (Over The Air Updates (OTA) - ESP32 - — ESP-IDF Programming Guide latest documentation) it is mentioned that when you perform OTA, the first boot with the new partition is monitored, therefore it receives the ESP_OTA_IMG_PENDING_VERIFY flag and in case of reboot before calling the esp_ota_mark_app_valid_cancel_rollback() function the application would rollback to the previous working version.
Unfortunately, that is not what is happening, instead, after the OTA update, both images are shown as valid, so the rollback never occurs.
Did somebody encounter the same problem?
The documentation states that :
If the CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE option is set, and a reset occurs without calling either function then the application is rolled back.
The default setting certainly is that this option is not set. I didn’t look at how it can be enabled (I am using PlatformIO and some ESP32 build settings are harder to find under this platforms).