2016-12-08 11:34 PM
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.2016-12-09 02:41 AM
Hi
sawicki.krzysztof
,You can do this by creating new sections in Flah using scatter (Linker) file . See example shown in this
https://community.st.com/0D50X00009XkhC7SAJ
.-Hannibal-
2016-12-09 12:43 PM
Not sure right now, but ST link should be able to load code into any location of memory? However it is much more convenient to have one file, or you can use the gnu tools to append one code at the end of other or so to create one binary out of it (objcopy???). I think it's the same process as loading a bootloader and an app into the MCU.
Have a nice day,
Renegade
2016-12-12 02:15 AM
It is not a problem for me to load the code at any position, but the problem is: how to get the machine code which will run at any position (this means no absolute adresses, jumps etc.).
2016-12-20 04:01 AM
The feature you look for is called 'PIC' (Position Independent Code); At gcc
-fpic
option would generate PIC code.If can refer directly to the gcc Code Generation Options (
https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html ♯ Code-Gen-Options
) and ARM machine dependent options (https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html ♯ ARM-Options
) for details.ARM Cortex-M should support
-fpic
since there are ARM specific options around PIC such as-mpic-register=
reg .2017-04-08 04:20 PM
Some things work (GPIO based) and some not.
HAL_Delay() with the use of Systick will never return.
Using a Timer for HAL_Delay(), the application is not even executed.
I'm still looking for the right recipe.
2017-04-08 05:13 PM
The vector table contains absolute addresses, you'd want to fixup/rebase that into RAM
2017-04-09 12:21 AM
Linux style code which can be ram loaded anywhere in the memory space is to be in demand in embedded bare metal or rtos space. It basically forbid to use the satically defined heap space by the linker. In 1990's HW access was done through what became the bios, through so called SWI #nn to make code more relocatable. If the code only use stack, then something might be ironed out. Indirect addressing in accessing data or function by pointers may cost cycles and acceleration bumps. These are performance or energy penalties when developping deep embedded apps on battery budget.
2017-04-09 05:09 PM
Magic!
Thank you so much!
2017-08-01 12:51 AM
Can you please share your solution? I am having some sanity issues with relocating executable code into RAM.