Is it possible to modify the OTA data partition with a custom bootloader?
Posted: Tue Mar 04, 2025 6:55 pm
My problem is the following:
I have three OTA related partitions on my ESP32 (app0, app1 and OTA data). By default app0 is the boot partition; it contains a firmware that can receive a firmware.bin file and install it on the app1 partition. When app0 received the complete firmware.bin file, it sets app1 as the boot partition (in the OTA data partition) and reboots the system. The bootloader looks in the OTA data partition and sees that it has to start app1. Suppose the app1 that is now running crashes, so the system will reboot. But since the OTA data partition still points to app1, the bootloader will start app1 again. This will cause a app1 bootloop.
I can prevent this by setting the boot partition to app0 in the app1 code. But I don't want to have to assume that app1 contains such code, it should be any firmware.
The best solution would be if the bootloader looks in the OTA data partition and remembers what it has to start (lets call this app_to_start), then writes into the OTA data partition that the next time app0 has to be started, and then starts app_to_start.
Is it possible to modify the bootloader in such a way?
I have three OTA related partitions on my ESP32 (app0, app1 and OTA data). By default app0 is the boot partition; it contains a firmware that can receive a firmware.bin file and install it on the app1 partition. When app0 received the complete firmware.bin file, it sets app1 as the boot partition (in the OTA data partition) and reboots the system. The bootloader looks in the OTA data partition and sees that it has to start app1. Suppose the app1 that is now running crashes, so the system will reboot. But since the OTA data partition still points to app1, the bootloader will start app1 again. This will cause a app1 bootloop.
I can prevent this by setting the boot partition to app0 in the app1 code. But I don't want to have to assume that app1 contains such code, it should be any firmware.
The best solution would be if the bootloader looks in the OTA data partition and remembers what it has to start (lets call this app_to_start), then writes into the OTA data partition that the next time app0 has to be started, and then starts app_to_start.
Is it possible to modify the bootloader in such a way?