cancel
Showing results for 
Search instead for 
Did you mean: 

add offset for application start address

Legacy member
Not applicable

Hi,

I've ran into an issue which is about start address of an application. I'm using an own bootloader to switch between two different applications. For the application I changed the start address in FLASH.id file to 0x08040000. That works perfectly fine.

My problem occurs when I try to jump to the second application at 0x080a0000. It works too but the first application at 0x08040000 will be ran again.

I figured out that it is because of the start address which is in both cases the same, 0x08040000. So probably the bootloader jumps to reset vector of 0x080a0000 and from there it jumps back to 0x08040000. If I change the start addres of the second application to 0x080a0000 everything works fine and I can jump from one to the other.

Is there any way to provide an offset or so to keep the second application running in 0x080a0000 even if their start address is 0x08040000?

I'd like to keep only two parts of the flash for the applications instead of three and copiing the data each time I want the make a swap.

 

regards

Ben

1 ACCEPTED SOLUTION

Accepted Solutions
Legacy member
Not applicable

Hi,

I found a solution. After seeking for how to change absolute to relative linking and SCB->VTOR I figured out that I can also use the RAM to run the code.

The bootloader will copy the selected code from Flash to RAM and then jumps to RAM start address. Works fine for both applications. 

Thanks for the hints anyways.

View solution in original post

4 REPLIES 4
Pavel A.
Evangelist III

It is not quite clear what you're doing. Do you build two distinct binaries of the app, one located at 0x080a0000 another at 0x08040000? or you have only one binary and want to place it in both areas? For the latter you'd need a  position independent binary, which does not occur by default.

 

The vector table contains absolute addresses, you can build a table in RAM with relocated addresses, and then point SCB->VTOR at that. The Address on most of these parts need to be 512-byte aligned to accommodate the content. 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Legacy member
Not applicable

Hi,

thanks for your replies. 

@Pavel A. sorry, seems like I didn't explain it properly. My system has a bootloader at 0x08000000 and I want to be able to boot two different firmware versions, current running and an update for example. Located are they at 0x08040000 and 0x080a0000. So it's kind of the same binary I want to place in both areas.

@Tesla DeLorean that's what I thought that the vector table is using absolute addresses. So there is a way to make it run with relative addresses? I guess I need to tell the compiler/linker to do that and then point SCB->VTOR to it while bootloader is running? 

Legacy member
Not applicable

Hi,

I found a solution. After seeking for how to change absolute to relative linking and SCB->VTOR I figured out that I can also use the RAM to run the code.

The bootloader will copy the selected code from Flash to RAM and then jumps to RAM start address. Works fine for both applications. 

Thanks for the hints anyways.