Place variable at specific location in data flash

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

Place variable at specific location in data flash

2,113 次查看
ozillator
Contributor I

Hi,

I need to place a char* at location 2005 in the data flash. Just to be certain about circumstances, the code is meant for the  DSC56000/E family (56F803 and 56F8357). As IDE I'm using CodeWarrior for DSC56800/E version 8.2.3 build 7.

To get the variable in place, on code side I tried the following:

In the .h file:

#pragma define_section SECDSPDESCRIPTION ".DspDescription" R

and in the .c file either:

 __declspec(SECDSPDESCRIPTION) char* gl_mca_dsp_description = "CB 137 LD 144 NumAct 2";

 or:

 

#pragma section SECDSPDESCRIPTION begin __declspec(SECDSPDESCRIPTION) char* gl_mca_dsp_description = "CB 137 LD 144 NumAct 2";#pragma section SECDSPDESCRIPTION end

In the linker .cmd file I added the following lines:

 

MEMORY {        .x_ReservedDescription  (R) : ORIGIN = 0x00002006, LENGTH = 0x00000020....SECTIONS {  .DspDescription : {       __START_SECDESCRIPTION = .;       *(.DspDescription)       __END_SECDESCRIPTION = .;       #. = ALIGN(0x1);    } > .x_ReservedDescription

 

 

But looking at the xMAP file: it doesn't map the variable to the according section.

 

Anybody got any thoughts on that? Or even experiences?

 

I would be more than thankfull!

 

Regards, Steffen

标签 (1)
标记 (1)
0 项奖励
回复
3 回复数

1,607 次查看
ozillator
Contributor I

I just found out, that when declaring the section as RW in the code, it places the variable, but (mis)alligns it to 0x00002006.

 

In general the reason for doing this, is to access the description of the application on the DSC from bootloader and application side. Therefore this char* needs to be in a specific location known by both sides.

0 项奖励
回复

1,607 次查看
ozillator
Contributor I

Just to get this to an end and avoid people to stumble into the same pitfall as I did: the solution was to not define a *char instead a char[]. With the second the linker really allocates memory at the given address.

 

So in code I used

 

#pragma define_section ...#pragma section ...

 and everything worked as expected.

 

One thing I still don't get is the fact, that my precedessor uses the following line to access the char at the given location:

 p_item = (char *) (ADDR_DSP_DESCRIPTION << 1); while( *(p_item++) && (descr_length < 30)) { ....

with:

 

#define ADDR_DSP_DESCRIPTION        0x00002005L


Why does he shift the address one to the left? Is this related to the address space of the 56F8357?

0 项奖励
回复

1,607 次查看
stanish
NXP Employee
NXP Employee

Hi Steffen,

This is indeed related to 56800E architecture. See the snippet from MCU DSC compiler manual (c:\Freescale\CW MCU v10.7\MCU\Help\PDF\MCU_DSC_Compiler.pdf):

pastedImage_2.png

Hope it helps.

Stan

0 项奖励
回复