cancel
Showing results for 
Search instead for 
Did you mean: 

Custom "thick" bootloader to boot identical application binary from either address A or B?

Code257
Associate III

Hello. I have run into a problem in a MCU project I have. I'll explain the situation.

We have a STM32F072RB -based product where we are implementing firmware update functionality. There would be 3 binaries in the MCU:

  1. Custom "thick" bootloader selecting application binary 1 or application binary 2 and jumping to run it
  2. Application binary 1 beginning at address A
  3. Application binary 2 beginning at address B

Our initial plan was to build different application binaries with explicitly different locations, but my customer is kind of wishing to use only one application binary. Therefore binary 1 would have exactly the same contents as binary 2.

Some experts say the way my customer wants the functionality is almost impossible to make. What do you say?

If anyone has any pointers what to google, what documents to read, etc, I'm all ears.

(My current, possibly stupid, idea is to make the single application binary to contain some kind of functionality to determine where it is run from and if it is run from binary 2 beginning from address B, then maybe perform some kind of elegant function/resource remapping so that when the image 2 runs, it does not use image 1 addresses for stuff, but locations in image 2 address space. Is this totally dumb?)

23 REPLIES 23

"The loader in this case would need to set aside some RAM to relocate the vector table into,and create an environment where either image code run successfully."

No, this is wrong. Loader should never do anything else than jump to actual image (via setting stack pointer and program counter it reads from image beginning in flash). Why? Because the firmware image knows best how itself is bootstrapped. I wrote an article about this:

https://paalijarvi.fi/tgblog/2021/09/05/firmware-interrupt-vector-table-relocation-by-bootloader-considered-harmful/

> It seems that about 99% of the information of this on various forums and other places is inaccurate, misleading, lacking or wrong.

The very definition of Internet.

JW

Code257
Associate III

Still here. Finally writing the article. Stay tuned.