cancel
Showing results for 
Search instead for 
Did you mean: 

Hi! Anyone knows how to compile code for STM32 (using gcc) which can be loaded at any position in flash and works ok?

Krzysztof Sawicki
Associate
Posted on December 09, 2016 at 08:34

I'm going to write 2 revisions of the same program to flash and make a bootloader which will start one of them, depending on some criterias.

#gcc-position-independend

Note: this post was migrated and contained many threaded conversations, some content may be missing.
13 REPLIES 13
gaurav patni
Associate II
Posted on August 16, 2017 at 06:57

Hi

Wagner.Joerg

,

request you please share the solution with details of require compiler - linker settings required.

Posted on August 16, 2017 at 06:58

Hi

Wagner.Joerg

,

request you please share the solution with details of require compiler - linker settings required.

Posted on August 16, 2017 at 17:12

Do you understand the concept of the vector table used in the Cortex-Mx parts? You'll need to exclude a sector of RAM (512 byte aligned) into which you will need to create a new vector table, you'll go through the vectors adjusting the addresses to reflect the address you've chosen to place the executable code. After that you'll need to point SCB->VTOR at this new table. If you link the image with a ZERO based address you can add the new offset to each vector.

Work product might not be sharable, especially if you work in a competitive company. Apply your knowledge/appreciation of compilers, linkers and loaders when it comes to creating relocatable objects with the tools you have chosen.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 28, 2017 at 18:16

In my case:

int main(void)

{

/* USER CODE BEGIN 1 */

SCB->VTOR=0x080C0000; // my app is located at this address in Flash

...