Help with manually launching second stage bootloader from application.
Posted: Mon Nov 27, 2023 12:52 am
Hi Everyone,
I am struggling a bit with finding a way to manually launch the second stage bootloader from a running application partition. My code implements a custom serial bootloader using bootloader hooks and it would be nice to be able to force launch it.
I also use OTA, but the serial backup is great if for some reason (Bug/corruption) there are no more viable firmware images on the device. This also lets me update the partition table on the device even though the device is using secure boot/encryption etc.
Does anyone know how I could go about launching the second stage bootloader safely?
I'm also toying with the idea of just forcing the PC, but not sure how to go about this safely?
I've tried this:
but I get a warning back
Sounds like there is an instruction set limitation here. Is there a way to get around that with inline asm?
I had planned to use some of the RTC retain memory to signal to the bootloader that it has been manually entered and delay it restarting the main application, but the retain memory is re-initialised (by code) at bootloader entry as far as I can tell.
I was hoping to use this function to tell that it came from application space:
If its all too hard I'll have to give up, but thought I'd see if anyone has any ideas. I can always do it through a GPIO at boot, but it would be nice not to have to do that.
Thanks in advance!
I am struggling a bit with finding a way to manually launch the second stage bootloader from a running application partition. My code implements a custom serial bootloader using bootloader hooks and it would be nice to be able to force launch it.
I also use OTA, but the serial backup is great if for some reason (Bug/corruption) there are no more viable firmware images on the device. This also lets me update the partition table on the device even though the device is using secure boot/encryption etc.
Does anyone know how I could go about launching the second stage bootloader safely?
I'm also toying with the idea of just forcing the PC, but not sure how to go about this safely?
I've tried this:
Code: Select all
((void(*)(void))0x1000)();
Code: Select all
(.text.app_resetToBootloader+0x36): dangerous relocation: windowed longcall crosses 1GB boundary; return may fail: (*UND*+0x1000)
I had planned to use some of the RTC retain memory to signal to the bootloader that it has been manually entered and delay it restarting the main application, but the retain memory is re-initialised (by code) at bootloader entry as far as I can tell.
I was hoping to use this function to tell that it came from application space:
Code: Select all
intptr_t esp_cpu_get_call_addr(intptr_t return_address)
Thanks in advance!