AnsweredAssumed Answered

56800E Linker Command file  for 56F8367 question

Question asked by brian dang on Feb 17, 2017
Latest reply on Jun 18, 2017 by ZhangJennie

Tool: Codewarrior tool for DSC56800/E version 8.3 build 091203

target: 56F8367 processor

 

I'm having issue of string constant. The code below to initialize a Global char array does not work (the array elements have wrong data when later being read out as ex: serial_dr = String[0] does not TX out ascii H correctly) :

char String[] = "Hello";      // defined as global variable

 

However, when assigning the array individually in main(), as below, it works (serial_dr=String[1] does send out 'e' ascii)

String[0]='H';

String[1]='e';

String[2]='l';

String[3]='l';

String[4]='o';

String[5]='\0';

 

I looked into the Linker command file trying to understand how the tool writing the "Hello" string into the array. Does the tool write the string "Hello" into p_flash_ROM_data(RX) (which is located in the program flash memory block as the executable code), and then when the code runs after power reset, the code copies the string from p_flash into the array String[] (in internal RAM)?

(It seems the p_flash_ROM_data section is located right after the executing code section. How does the tool know if the p_flash_ROM_data does not written over the chip's p_flash ROM total area with a very large string constant for example?)

 

MEMORY
{
.p_interrupts_ROM (RX) : ORIGIN = 0x0000, LENGTH = 0x00AC # reserved for interrupts
.p_flash_ROM (RX) : ORIGIN = 0x00AC, LENGTH = 0x3FF54 # 256K words contiguous flash minus interrupt space

# p_flash_ROM_data mirrors internal xRAM, mapping to origin and length
# the "X" flag in "RX" tells the debugger to download to p-memory.
# the download to p-memory is directed to the address determined by AT
# in the section definition below.

 

.p_flash_ROM_data (RX) : ORIGIN = 0x0001, LENGTH = 0x3FFF # internal xRAM mirror

.p_boot_flash_ROM (RX) : ORIGIN = 0x40000, LENGTH = 0x4000 # 16K words
# .p_reserved : ORIGIN = 0x44000, LENGTH = 0xB800 # 46K words
.p_internal_RAM (RWX) : ORIGIN = 0x4F800, LENGTH = 0x0800 # 2K words
.p_external_RAM (RWX) : ORIGIN = 0x50000, LENGTH = 0x0000 # max available
.x_internal_RAM (RW) : ORIGIN = 0x0001, LENGTH = 0x3FFF
.x_flash_ROM (RW) : ORIGIN = 0x4000, LENGTH = 0x4000
.x_external_RAM (RW) : ORIGIN = 0x8000, LENGTH = 0x7000
.x_onchip_peripherals (RW) : ORIGIN = 0xF000, LENGTH = 0x1000
.x_external_RAM_2 (RW) : ORIGIN = 0x10000, LENGTH = 0xFEFF00
.x_EOnCE (RW) : ORIGIN = 0xFFFF00, LENGTH = 0x0000
}

 

Thank you,

Brian

 

Sorry that I posted this earlier on Classic/legacy, but think that site does not get the same exposure as this site. 

Outcomes