AnsweredAssumed Answered

Linker script templates

Question asked by LPCware Support on Mar 31, 2016

This FAQ relates to LPCXpresso IDE v 7.8.0 and earlier.

For later versions, please see: Freemarker Linker Script Templates 

 

The LPCXpresso IDE makes use of a template linker script which is then used together with the chosen MCU and other project settings (such as "Enable CRP") in order to create the managed linker script that is autogenerated into the Debug/Release subdirectory of your project. This linker script then controls the way that the code and data in your application are laid out in memory.

 

However it is also possible to tweak this template for project specific requirements by placing a local copy into your application project. One simple example of this might be to place the heap and stack in the RamAHB32 region (at 0x2007c000) for an LPC1768 project. To do this:

 

  1. Right click on your project in the Project Explorer view, and select New -> Folder to create a subdirectory within the project structure. This subdirectory must be called "linkscripts".
  2. Outside of the LPCXpresso IDE, open up a file browser and navigate to <installdir>\lpcxpresso\Wizards\linker. Now copy the file link_template.ld from that subdirectory and paste it into the linkscriptssubdirectory of your project.
  3. Open the project copy of link_template.ld up within the LPCXpresso IDE and change the two lines towards the bottom of the file from:

PROVIDE(${heap_symbol} = .);

PROVIDE(_vStackTop = __top_${DATA} - ${STACK_OFFSET});

to

PROVIDE(${heap_symbol} = ADDR(.data_RAM2));

PROVIDE(_vStackTop = __top_RamAHB32 - ${STACK_OFFSET});

 

If you now clean, then build your project, your modified template will be used rather than the default one to create the managed linker script file in the Debug/Release directory, and your application will use RamAHB32 for placing the heap and stack in.

 

For more information:

Outcomes