Soft reset to second stage bootloader

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

Soft reset to second stage bootloader

Postby felixcollins » Mon Aug 07, 2023 2:58 am

Hi, I have a situation where I want to jump to the second stage bootloader after completing an OTA fw update. I do not want to reset the gpio state as I rely on a gpio to keep power latched on. If I do an esp_restart() then the power goes off and the user has to turn it on again.

Can I just use an asm jump to the correct address? Is there a header with the correct symbol to jump to?

Cheers,
Felix

ESP_igrr
Posts: 2067
Joined: Tue Dec 01, 2015 8:37 am

Re: Soft reset to second stage bootloader

Postby ESP_igrr » Tue Aug 08, 2023 1:37 pm

You probably can't jump directly into the 2nd stage bootloader because it is not present in RAM when the application runs. (Keeping it present there would waste RAM.)
Therefore the boot process has to go through the boot ROM, which would copy the 2nd stage bootloader code into RAM (overwriting part of app's RAM) and execute it.
However it should be possible to do what you are trying to do with esp_restart. I've looked at esp_restart code and I don't see GPIO state being reset explicitly, though. Can you please add which ESP chip and which IDF version you are using?

felixcollins
Posts: 125
Joined: Fri May 24, 2019 2:02 am

Re: Soft reset to second stage bootloader

Postby felixcollins » Wed Aug 09, 2023 9:11 pm

Sorry, I'm using the ESP32 WROOM 32E. It is in a custom circuit. GPIO19 is held high to latch power on.

Thanks for your help. I realised once I started looking into things that I would have to load the 2nd bootloader, so I gave up!

We want to restart to boot new FW after an OTA update and load the new code. This seems like a common enough use case. If esp_restart() does not clear the gpio I wonder if it is something in the boot process that is clearing it.

Cheers,
Felix

Who is online

Users browsing this forum: MicroController and 134 guests