2025-06-09 1:31 PM
I'm working on some code that has a boot loader and an application. At the moment I am using one linker script for each, which means I have to make sure I keep them in sync. Is it possible to configure the build for (e.g.) the boot loader so that .boottext is used instead of .text for the code so that a single linker file can be used?
I've tried searching (here and internet) and it appears as if this can't be done with GCC - but I thought it was worth asking just in case I've missed something.
Solved! Go to Solution.
2025-06-10 2:27 AM - edited 2025-06-10 2:28 AM
Thanks, that's got me where I need to be (only needed the --defsym).
I've just used DEFINED when creating the memory regions:
flashStart = DEFINED(isBootLoader) ? 0x8000000 : 0x8010000;
flashLength = DEFINED(isBootLoader) ? 64K : 64K;
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = flashStart, LENGTH = flashLength
}
And then just add a linker flag when building the boot loader:
-Xlinker --defsym isBootLoader=1
2025-06-09 4:22 PM
Kind of. You can use the --defsym option to define constants for linker script on the command line.
Use these constants as addresses and sizes of memory regions.
Also you can use REGION_ALIAS statements to define aliases for memory regions.
For example in the common part of the script use the region name "ROM" which is alias of either FLASH1 or FLASH2, etc.
2025-06-10 2:27 AM - edited 2025-06-10 2:28 AM
Thanks, that's got me where I need to be (only needed the --defsym).
I've just used DEFINED when creating the memory regions:
flashStart = DEFINED(isBootLoader) ? 0x8000000 : 0x8010000;
flashLength = DEFINED(isBootLoader) ? 64K : 64K;
/* Memories definition */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
FLASH (rx) : ORIGIN = flashStart, LENGTH = flashLength
}
And then just add a linker flag when building the boot loader:
-Xlinker --defsym isBootLoader=1