cancel
Showing results for 
Search instead for 
Did you mean: 

Help : Bootloader and 2 flash sections on STM32U575

joeSD
Associate III

Hi All,

I am using a STM32U575QI and I am wondering if it would be possible to create my own boot loader and then split my FLASH into 2 sections. I know I can get the boot loader application to start at address 0x0800000 and I have offset the vector table and applicationA.

But what I am trying to figure out if it is possible to split FLASH in the linker file to allow me to have two applications, it would be the same project but two different versions of it. Basically I want the boot loader to run and I want to read application A and B from an SD card and store them in FLASH. Then have my boot loader run and decide which application to run.

From some research I know it can be possible with the two banks on the device without the need for a boot loader but wondered if it would be possible this way with a boot loader and 2 sections of FLASH.

Would I need to have a project each for application A and B and specify where the vector table is for both of them in each section of FLASH?

Any help would be appreciated.

Thanks!

10 REPLIES 10
TDK
Guru

No problems with this scheme. You can split the FLASH into as many sections as you want, just ensure they are all on separate flash pages.

When the application starts, it should set the vector table location itself based on what you specify in the linker file. That's the idea at least, probably want to verify that.

If you feel a post has answered your question, please click "Accept as Solution".
Radosław
Senior II

Need to remember both aplication need to be compiled with own start address

joeSD
Associate III

Hi, thanks for the replies. Let me just give some more information to still see if its possible.

The applications I want to be able to store in two sections of Flash are exactly the same just different versions - compiled the same way and everything.

The only thing I did to the linker file was create a section section of FLASH (gave both the correct sizes). Do I need to set up the .rodata, .isr_vector etc for the section section?

If both applications are the same with the same linker files will they both be able to run if they are stored in flash in different sections?

This is all new to me so apologies if its not 100% correct or I'm not getting it across properly!

@TDK @Radosław 

My suggestion: bootloader need check if copy 1(working aplication) are correct, and if not, move copy 2 to working section, bootloader can not erase anythning from section 2.

 

OliM
Senior

If you want to actually run the unaltered application in both locations, you would have to make sure that it is build and linked in a location independent way. Normally the linker would not use offset addressing but direct addressing for jumps into funtions etc. . That can not work if the application can be at two different places in the rom.

This is why the common solution (e.g. the standard in mcuboot, which by the way can support your controller) is to swap the applications before starting them, so that the execution always happens from the same address. The hardware solution is to use two times the same offset, meaning you also have the bootloader twice, on two banks and switch the banks, but in my mind that only wastes flash.

They need to have different FLASH sections, which means the linker file needs to be different. That is all you need to do, apart from jumping to the correct address within the bootloader. No messing with vector tables, etc.

If you feel a post has answered your question, please click "Accept as Solution".
joeSD
Associate III

Thanks!

So both AppA and AppB need to be different projects with different linker files pointing to different parts of Flash?

Or can they be the same project and same linker file?

Everything depends of your needs,  when AppA AppB will be programmed,  why you need 2 of them etc.

 

Are you speaking about two different applications or two different versions of one application?

If you have two different applications, then building and linking them to their respective locations separately makes most sense.
They can also move and adjust the vector tabels themselves right at their respective startup, so the bootloader doesn't need to concern itself with that and just initiate the jump.

If you want to have two different versions of one application I would still advise to use the swap operation, because that omits working with location Independent code.