AnsweredAssumed Answered

Can someone explain the MQX linker (*.lcf) file?

Question asked by gdub on Nov 20, 2013
Latest reply on Jul 20, 2015 by John Elson

Hello,

 

I am using a kinetis MK10DX256 and MQX4.0. It seems that there are things that the BSP and PSP build depend on that are defined in the linker file. The MK10DX256 has 64kB of RAM, I am trying to preserve 32kB of that RAM for our application. Therefore, I updated the linker file so as not to use this second half of RAM. Everything compiles fine and loads but then the MQX initialization function "_mqx()" crashes and burns (as seen by the debugger). Here is part of the original linker file before being modified:

 

MEMORY

{

   vectorrom   (RX): ORIGIN = 0x00000000, LENGTH = 0x00000400

   cfmprotrom  (RX): ORIGIN = 0x00000400, LENGTH = 0x00000020

   rom         (RX): ORIGIN = 0x00000420, LENGTH = 0x0003FBE0  # Code + Const data  

   ram         (RW): ORIGIN = 0x1FFF8000, LENGTH = 0x00010000  # SRAM - RW data

 

 

   # kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)

   end_of_kd   (RW): ORIGIN = 0x20007FF0, LENGTH = 0x00000000

  

   # Boot stack reused by MQX Kernel data

   bstack      (RW): ORIGIN = 0x20007A00, LENGTH = 0x00000200  # Boot stack

   end_bstack  (RW): ORIGIN = 0x20007C00, LENGTH = 0x00000000

}

 

Does anyone know why "bstack" and "end_bstack" are at address x20007A00 and x20007C00 respectively? And why is "end_of_kd" 0xF bytes before the end of RAM?

 

I have tried to modify this linker file to keep everything in the first half of memory (see below):

 

MEMORY

{

   vectorrom   (RX): ORIGIN = 0x00000000, LENGTH = 0x00000400

   cfmprotrom  (RX): ORIGIN = 0x00000400, LENGTH = 0x00000020

   rom         (RX): ORIGIN = 0x00000420, LENGTH = 0x0003FBE0  # Code + Const data  

   # Reserve SRAM_U (upper) for task space

  ram         (RW): ORIGIN = 0x1FFF8000, LENGTH = 0x00008000  # SRAM - RW data

 

   # kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap)

   end_of_kd   (RW): ORIGIN = 0x1FFFFFF0, LENGTH = 0x00000000

  

   # Boot stack reused by MQX Kernel data

   bstack      (RW): ORIGIN = 0x1FFFFA00, LENGTH = 0x00000200  # Boot stack

   end_bstack  (RW): ORIGIN = 0x1FFFFC00, LENGTH = 0x00000000

}

 

But I feel like I am just guessing where "end_of_kd", "bstack", and "end_bstack" go.

 

If anyone has any information on setting up the linker file to work with MQX, it would be greatly appreciated. I am assuming most people may just use the default linker file and that is why I can't seem to find any documentation about modifying it. But if someone knows where the documentation is, that would also be greatly appreciated.

 

Thanks,

G

Outcomes