cancel
Showing results for 
Search instead for 
Did you mean: 

Best Practice For Updating Custom Bootloader

BJohn.1
Associate II

I have a bit of an interesting situation. Our boards utilize the STM32f769NI chip, and we run our own custom bootloader that is used to read firmware images off of a microSD card and then update the firmware in flash memory. We flash a bootloader to the boards through a JTAG interface before shipping, but unfortunately (or perhaps fortunately) when the boards get put in their housing, the JTAG interface is then hidden from the user, and so accessing it is out of the question.

A situation has come up where we need to update a board's bootloader while it is with a customer in the field. We do not want to force the customer to send back their board just so we can disassemble the housing to get to the JTAG interface, so we are developing a custom firmware image that will update the bootloader.

Right now the bootloader is stored at 0x08000000, and the application/firmware gets flashed to memory location 0x08020000. I want to be able to do this process in a way where if we lose power during the update process, we can fall back to a backup image of the old bootloader so the board does not become "bricked".

So before erasing the old bootloader section and programming the new bootloader image, I thought it would be a good idea to copy the old bootloader image at 0x08000000 to a different flash location (ie 0x081C0000) and have the BOOT_ADD0 register point to our backup bootloader image. However that means I have to update the contents of the vector table with the new location. Wouldn't I also have to update the .text contents with their new references in memory? Or am I thinking of that wrong?

I am looking for general guidance on how to copy existing code to a new location and booting successfully from that new location. Or if anyone can think of a better way of going about this. Any feedback would be very much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
BJohn.1
Associate II

Never mind I have found a solution, I was making it way too complicated. I can still copy over the old bootloader image to another location in flash, but as for our failsafe in the case of a loss of power, I can just have BOOT_ADD0 point directly to the entry of our applicatoin code at 0x08020000 instead, we don't have to go through the bootloader. That way we don't have to worry about changing vector table values or function memory locations.

View solution in original post

1 REPLY 1
BJohn.1
Associate II

Never mind I have found a solution, I was making it way too complicated. I can still copy over the old bootloader image to another location in flash, but as for our failsafe in the case of a loss of power, I can just have BOOT_ADD0 point directly to the entry of our applicatoin code at 0x08020000 instead, we don't have to go through the bootloader. That way we don't have to worry about changing vector table values or function memory locations.