Skip to main content
LThal
Associate III
January 15, 2019
Question

Building STM32-Nucleo demo for position independence.

  • January 15, 2019
  • 3 replies
  • 834 views

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.

This topic has been closed for replies.

3 replies

S.Ma
Principal
January 16, 2019

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
LThalAuthor
Associate III
January 16, 2019

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?

Tesla DeLorean
Guru
January 16, 2019

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 VenmoUp vote any posts that you find helpful, it shows what's working..
LThal
LThalAuthor
Associate III
January 16, 2019

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.