Modifying linker scripts in MCUXpresso

cancel
Showing results for 
Search instead for 
Did you mean: 

Modifying linker scripts in MCUXpresso

3,920 Views
robertpoor
Contributor V

I've recently switched from KDS to MCUXpresso, but I'm stumped on how to modify the load map.  

Specifically: in KDS, to support a flash-resident bootloader in low memory, I modified the memory areas in MKL27Z64xxx4_flash.ld from its default:

MEMORY
{
 m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000200
 m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
 m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0000FBF0
 m_data (RW) : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
 m_usb_sram (RW) : ORIGIN = 0x400FE000, LENGTH = 0x00000200
}

to look like this. Note that the BCA starts at 0x43c0 and m_text at 0x4400, and I've added a "BootloaderConfig" section:

MEMORY
{
 m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000200
 m_bootloader_config (RX) : ORIGIN = 0x43C0, LENGTH = 0x0040
 m_text (RX) : ORIGIN = 0x00004400, LENGTH = 0x0000B800
 m_data (RW) : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
 m_usb_sram (RW) : ORIGIN = 0x400FE000, LENGTH = 0x00000200
}
SECTIONS
{
 ...
 .bca :
 {
 . = ALIGN(4);
 KEEP(*(.BootloaderConfig)) /* Bootloader Configuration Area (BCA) */
 . = ALIGN(4);
 } > m_bootloader_config
...
}

After that, I could use __attribute__((section(".BootloaderConfig"))) in my code to initialize the BCA.

However, with the new Managed Linker system in MCUXpresso, the .ld files are evidently automatically generated by "Freemarker", so it would be a Bad Idea to modify the generated files directly.

But I'm stumped as to how to tell Freemarker to make the corresponding changes.  Are there examples of how to do this?

4 Replies

1,343 Views
robertpoor
Contributor V

I also found this thread, which is highly relevant:

In MCUXpresso I cannot set up the BCA anymore 

The main point is that I should be using Memory Editor (Project => Properties => C/C++ Build => MCU settings => Memory Details) to create the new section(s).  Further hints are given in:

https://community.nxp.com/servlet/JiveServlet/download/911737-1-404912/Relocating%20Code%20and%20Dat... 

1,343 Views
converse
Senior Contributor IV

To start with, my suggest you read chapter 16 of the User Guide...

0 Kudos

1,343 Views
robertpoor
Contributor V

I already read chapter 16 and I'm still stumped.  I saw nothing in there about how to create new sections other than editing the .ldt templates.  But there are no .ldt files in my project nor in my SDK.  (What am I missing?)

I could uncheck Properties => C/C++ Build => Settings => Managed Linker Script => "Manage Linker script" and go back to doing the old-school way.  But I prefer to work with the tools than disable them.  

converse‌: can you be a little more specific about how to do this?

0 Kudos

1,343 Views
robertpoor
Contributor V

Heh.  I *almost* put a note to the effect that "Erich has probably already done this but..." but I'd only seen your note from 2012 ( Defining Variables at Absolute Addresses with gcc | MCU on Eclipse ), so I wasn't sure. 

The section on "Custom Linker Files" is just what's needed -- thanks very much for the updated blog entry!

0 Kudos