Skip to main content
DBurr
Senior
May 26, 2020
Solved

Load multiple applications to flash and pass execution from one to another

  • May 26, 2020
  • 4 replies
  • 3746 views

Hi,

I'm using an STM32F746ZG and writing my own custom bootloader. The bootloader will work by initially running and determining which of 2 applications to launch, both stored at different locations in the MCU's internal flash memory. How do you pass execution on to one of these 2 applications from the bootloader?

Thanks,

Doug Burrell

This topic has been closed for replies.
Best answer by TDK

Short answer: Do this, except use the location of your program instead of BootAddr.

https://community.st.com/s/article/STM32H7-bootloader-jump-from-application

4 replies

TDK
TDKBest answer
Super User
May 26, 2020

Short answer: Do this, except use the location of your program instead of BootAddr.

https://community.st.com/s/article/STM32H7-bootloader-jump-from-application

"If you feel a post has answered your question, please click ""Accept as Solution""."
DBurr
DBurrAuthor
Senior
May 27, 2020

Thanks for the fast response! This FAQ that you're referring to applies to the STM32H7, will the same solution also work for the STM32F7?

Tesla DeLorean
Guru
May 27, 2020

It illustrates control transfer.

You're using a micro-controller, you can pretty much test whatever memory region you want, and jump/branch into code there. On the CM7 parts this is typically done via the Vector Table. You might want to review texts on the Cortex parts, technical manuals from ARM, and IAP examples from ST

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
May 28, 2020

That ST's example is as all ST's code - pretty fragile and dumb. Look at my comment for a much more robust and simpler solution here:

https://community.st.com/s/question/0D50X0000AFpTmUSQV/using-nvicsystemreset-in-bootloaderapplication-jumps

DBurr
DBurrAuthor
Senior
June 5, 2020

Thanks for the feedback. I've finally got HW and have been testing out the solution. I'm using the initial solution provided by @TDK​ and this seems to work, most of the time, but sometimes it doesn't and after the bootloader has run and handed off execution to the other application there's no activity and the processor appears to be dead. The solution @Piranha​ has suggested won't work for this application because it needs to determine which of 2 application partitions it should branch to and this is done by reading data from a flash chip. Anyway, I don't understand what is going on such that sometimes it works and sometimes it doesn't work. Any suggestions?

Thanks,

Doug Burrell

Piranha
Principal III
June 18, 2020

> The solution @Piranha (Community Member)​ has suggested won't work for this application because it needs to determine which of 2 application partitions it should branch to and this is done by reading data from a flash chip.

My solution basically passes a commands between the bootloader and the application. One can add additional commands and virtually any amount of parameters, which bootloader can pass to itself going through the reset.

As for that example and your problem... Well, it's ST's code! For example, not using the required memory barriers is a classic from those brainless code monkeys. My example has them even with a short explaining comments.