cancel
Showing results for 
Search instead for 
Did you mean: 

Changing default memory sections

CTapp.1
Senior II

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
CTapp.1
Senior II

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

 

View solution in original post

2 REPLIES 2
Pavel A.
Super User

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.

 

 

CTapp.1
Senior II

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