5 years, 5 months ago.

Change Start Address of Compiled Program

I am curious as to whether there is a way to change the start address of a program compiled using either the online compiler (for NUCELO STM32F303RE) or the CLI so as to allow my application to be used with a custom bootloader I developed.

1 Answer

5 years, 5 months ago.

I can give a partial answer. I've done it before, though I'm struggling to recall all the subtleties. I followed a guide and sample code from Atollic for STM32 but used the old mbed 2 library on both bootloader and main project. Atollic makes you sign in but I think it's free. I did this in SystemWorkbench.

http://info.atollic.com/bootloader_training_presentation?hsCtaTracking=138e926b-f09e-4811-b194-9eb9affe5749%7C45c0097d-8cb8-4c75-82e5-e89a0b907d2d

The handover from bootloader execution to main app execution is the tricky part but they walk you through that. Relocating main app I believe is as simple as updating the linker script. You just adjust the Flash start address and size in the linker script. So STM32 normal flash start is 0x08000000, you move main app by changing to:

  FLASH (rx) : ORIGIN = 0x08010000, LENGTH = 512K - 0x10000

I don't know if linker script be updated using online compiler.

Thank you for the link, for some time I have been attempting to do exactly as you have proposed in various offline compilers and NONE of them have worked. Maybe Atollic will work where the others (ARM GCC for Eclipse and STM32 WEorkbench (which is admittedly kind of the same thing)) have all failed. I actually wrote my bootloader in those compilers and it has shown to work with small programs I have thrown together in that IDE. Unfortunately, a majority of my prototype code for my product was written on the mbed online compiler and any and all efforts to export the code to any offline compiler have failed miserably. IT was this lengthy and troubled process which brought me to inquiring as to whether it is possible to do exactly as you have said "I don't know if linker script be updated using online compiler." using either the online compiler or the CLI.

posted by Matthew Connolly 07 Nov 2018