AnsweredAssumed Answered

Link errors under IntRam configuration

Question asked by Shenwei Wang Employee on Mar 7, 2013


I was recently moved to work on Kinetis MCU. I installed the CodeWarrior v10.3 and MQX4.0 on the development PC. After received a K40x256 tower reference boards, I can't help myself to start to do some practice.  My plan is to write a hello world simple application, and to make myself familiar with the building environment, the debug tools, and the debugging procedure.  The application is based on MQX4.0 so than I could have a glance at the RTOS as well.

The testing goes very well, and the hello world application is soon complete. There are three building configurations for this  project: IntRam, IntFlash_Debug, and IntFlash_Relase.  I was first trying to build the application under IntFlash_Debug configuration, and the process went well. The binary was successfully created. The binary was downloaded to the target board and executed as expected. However, trouble came out when IntRam configuration was selected. The building process failed at link stage. The following is the error details from CodeWarrior.

"Link failed: Overflow in segment: rom from section: .main_application Segment reserved size is: 0x00007be0 -- Overflow of: 0x00004e68"

build-error.jpg

It looks like a link script issue. As I was not familiar with CodeWarrior, it did take some time to locate the link script file.  From the menu: Project->Properties->C/C++ Build->Setting, you can find the link command file location. The following is the picture:

linkfile.jpg

 

Then opening ${MQX_ROOT_DIR}\lib\twrk40x256.cw10\debug\bsp\intram.lcf,  the code area size is defined there as 0x00007BE0.

MEMORY {      vectorram    (RW): ORIGIN = 0x1FFF8000, LENGTH = 0x00000420  # SRAM - Vector table      rom              (RX): ORIGIN = 0x1FFF8420, LENGTH = 0x00007BE0  # SRAM - Code + Const data      ram              (RW): ORIGIN = 0x20000000, LENGTH = 0x00008000  # SRAM - RW data      ...    

After check the binary, it seems the code size should be 0x0000CE68, so I changed the initram.lcf file as following:

MEMORY {       vectorram    (RW): ORIGIN = 0x1FFF8000, LENGTH = 0x00000420  # SRAM - Vector table      rom              (RX): ORIGIN = 0x1FFF8420, LENGTH = 0x0000CE68 # SRAM - Code + Const data      ram              (RW): ORIGIN = 0x20005288, LENGTH = 0x00002D78 # SRAM - RW data      ...    

 

Clean and build again, building passed with no errors!

Downloading the ram based binary onto the K40x256 Tower board, the application works fine as expected.

Outcomes