cancel
Showing results for 
Search instead for 
Did you mean: 

Building STM32-Nucleo demo for position independence.

LThal
Associate II

I'm trying to build the IO_Toggle demo for the STM32 Nucleo board as position independent. I've followed the description given in the Atollic TrueStudio for Arm User Guide (p171), and I still end up with variables and structs having problems. Has anyone run into this, and are there any suggestions / solutions? Thanks.

4 REPLIES 4
S.Ma
Principal

If you can describe what you needs in condensed explanation, would help (time is precious, we may not have the time to read a yellow page book size manual)

LThal
Associate II

I've added -fPIE to the assembly, C and linker command lines (also tried -fPIC, which made no discernible difference), set up the stack pointer in Reset_Handler(). I still end up in the HardFault_Handler due to invalid address access. Is there something I'm still missing for building this as position independent code?

I would start by identify the specific points of failure.

I would build two binaries at different address so that I could diff them to confirm what address data continued to leak into the output.

The alternative is to have some relocation data so you can fix-up the image as you write it to flash at a specific address.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LThal
Associate II

Code seems to be fine. I'm seeing problems with structs and variables, where they get located to areas outside of the RAM address space. I seem to have fixed a couple of the problems by defining the variables as static, but I'm not sure if that's a real fix or just hiding the problems. I also don't understand why the compiler is producing the output it is.