56800E Linker Command file  for 56F8367 question

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

56800E Linker Command file  for 56F8367 question

1,603 次查看
bdang
Contributor II

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. 

标签 (1)
8 回复数

1,329 次查看
bdang
Contributor II

Hi Jennie,

Sorry that I was tied up with other projects until recently. I looked into your sample project after linking, and found the two const arrays were placed in the  .x_RAM   section, instead of pflash ROM section. Why would one waste RAM space for const instead of using code flash ROM? The target is a 56F8367 processor with plenty of space for code memory. How would you do to assign these const (and any string constants such as in error_message="Motor is overheated!") to Code flash rom memory?

const int table[5] = {0,1,2,3,4};
const int test[5] = {3, 4, 5,6,7};

Best,

Brian

0 项奖励
回复

1,329 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Brain.

see this demo code *.cmd file, const data is defined in x_RAM. thus string "table" and "test" are allocated in x_RAM.

pastedImage_1.png

in your application, if you don't want const code allocation in x_RAM, please set it to the PFLASH or other ROM section that you want. This can distribute const data to ROM


Have a great day,
Jennie Zhang

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

0 项奖励
回复

1,329 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Good! Thanks for the sharing.

Best Regards,

Jennie Zhang.

0 项奖励
回复

1,329 次查看
bdang
Contributor II

Hi Jennie,

I followed this instruction found on the old post of Fiona Kuang, and I was able to open your sample project:

"2) Or in your CW go to File->Import project Browse for the project location and set the "objects of" field to "All Files" Select the *.mcp file and click open Now in the window "Name new project as:" you should name your project and select Save. By doing any of the above you should be able to open your project."

Thanks,

Brian

1,329 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Brain.

Thank you for contacting us.

The attached project is a small example for place data at a specific address.

Can you please refer this demo to develop yours.


Have a great day,
Jennie Zhang

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

0 项奖励
回复

1,329 次查看
bdang
Contributor II

Hi Jennie,

Thank you for the sample project but for some reasons when open the project *.mcp file, it didn't open properly. See below. What did I do wrong?

Thanks,

Brian

pastedImage_1.png

0 项奖励
回复

1,329 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

HI Brain.

Please open IDE menu "Edit" "preference", check "use text-based projects". then restart Codewarrior. import the demo project. it should work.

pastedImage_1.png


Have a great day,
Jennie Zhang

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

0 项奖励
回复

1,329 次查看
bdang
Contributor II

Hi Jennie,

I checked "Use Text based project" as instructed, then clicked on the project file *.mcp, but still had the same problem of opening the project. Might be I didn't read you correctly. You said "then restart Codewarrior. import the demo project. it should work." 

You wrote "import the demo project" and so I also tried "File" , "Import Project", but there is no *.xml file to open.

I'm lost here.

Brian

0 项奖励
回复