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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,799 Views
gdub
Contributor I

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

0 Kudos
7 Replies

854 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Freescale has AN4498 for description of lcf file for kinetis. see attached

854 Views
gdub
Contributor I

Hello Zhang,

Thanks for attaching "AN4498_lcf_for_kinetis.pdf". This document is extremely helpful.

However, I was also wondering if certain "MQX" specific information could be explained. For example, the MQX boot stack. According to the linker file (see original post) it looks like the boot stack is reused by MQX kernel data, but do you know how big this needs to be? I think the issue I may be having is that when I split the RAM in half, I may not have left enough space for the boot stack, or something like that. But I am not sure how to verify this.

Thanks for any help/advice.

0 Kudos

854 Views
reubennoronha
Contributor I

Hi,

I have the same question !

Is there any document which gives info specific to MQX for the linker file ?

If this was solved, can you tell me what you did?

0 Kudos

854 Views
Roguetroop
Contributor I

I too have similar questions. I cannot find any explanation or guide that explains IAR MQX linker files properly. For example, why do all the MQX linker files have no cstack and yet still run fine? Does MQX create its own stack before the RTOS begins to run? Don't we still need a stack before the RTOS is called?

0 Kudos

854 Views
soledad
NXP Employee
NXP Employee

Hello Reuben,

Please check the below application note, I hope this helps,

Have a nice day!!

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4367.pdf


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

854 Views
Tim562
Senior Contributor I

Hi Zhang,

     I've been searching for a document like this that describes the LCF file for the Freescale MPC-5125. Do you have a link to something like that or would this AN4498.PDF document also apply to that Power PC part? Thanks.

Best,

Tim

0 Kudos

854 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

please check if an4497 can help.

0 Kudos