How to force constants in a specific section (MPC5668G with CW10.5)

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

How to force constants in a specific section (MPC5668G with CW10.5)

跳至解决方案
1,109 次查看
hbouch
Contributor III

Hi,

I'm trying to create a section at a specific address in which I want to put the software version of the application so it can be read back by the bootloader. Here is what I did in the linker script:

 

MEMORY

{

    resetvector:           org = 0x00000000,   len = 0x00000008

 

    system_cfg:            org = 0x00003000,   len = 0x00000010

    internal_flash:        org = 0x00003010,   len = 0x000FCFF0

(...)

}

 

(...)

 

GROUP: {

    .__software_version (CONST) : {}

} > system_cfg

 

In my code, I have declared the software version constant as follow:

 

#pragma push

#pragma section R ".__software_version" ".__software_version"

__declspec (section ".__software_version") const uint32_t ESM_ku32NESSoftwareVersion;

#pragma pop

 

In the linker setting, I put ROM Image Address and RAM Buffer Address of ROM Image at 0x00003010 but the code won't boot. It get stuck in __init_data function. I've also tried to put 0x00003000 but it doesn't even reach the __start function and I get warnings at compilation on ROM image address overlapping other sections.

 

What am I doing wrong? Can anyone help me please?

 

Hugo

标签 (1)
0 项奖励
1 解答
594 次查看
hbouch
Contributor III

The ROM Image Address and RAM Buffer Address of ROM Image that should be used is 0x00003010.

Also, to make sure that my constant is in the output file, __declspec(force_export) has to be used in the declaration:

#pragma push

#pragma section R ".__software_version"

__declspec(section ".__software_version") __declspec(force_export) const uint32_t ESM_ku32NESSoftwareVersion = 0x12345678;

#pragma pop

Thanks for you help.

Hugo

在原帖中查看解决方案

0 项奖励
3 回复数
594 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello Hugo

Could you please replace your code in link command file with this one? And leave the ‘Generate ROM Image’ options with their default settings.

GROUP : {

            .__software_version (CONST) LOAD(ADDR(.__software_version)): {}

     } > system_cfg

Best Regards

Fiona Kuang

TIC - Technical Information Center

-----------------------------------------------------------------------------------------------------------------------

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

0 项奖励
594 次查看
hbouch
Contributor III

Hello Fiona,

Thanks for your answer but it didn't solve my problem. However I'm sure of what you mean when you say "eave the ‘Generate ROM Image’ options with their default settings". I assumed 0x00003000. It compiles with the following linker warnings:

"Overlap of the ROM image address of .init section with executable address of .init section."

"Overlap of the ROM image address of .text section with executable address of .text section."

When I look at the .sx file, I see the block at address 0x00003000 but the content is not what I expected. I should see the software version (0x12345678):

S31900003000480000697C6000A6646302007C6001247FE802A6AA

If forgot the initialisation of the constant in my previous post. You should have read:

#pragma push

#pragma section R ".__software_version" ".__software_version"

__declspec (section ".__software_version") const uint32_t ESM_ku32NESSoftwareVersion = 0x12345678;

#pragma pop

Any other ideas?

0 项奖励
595 次查看
hbouch
Contributor III

The ROM Image Address and RAM Buffer Address of ROM Image that should be used is 0x00003010.

Also, to make sure that my constant is in the output file, __declspec(force_export) has to be used in the declaration:

#pragma push

#pragma section R ".__software_version"

__declspec(section ".__software_version") __declspec(force_export) const uint32_t ESM_ku32NESSoftwareVersion = 0x12345678;

#pragma pop

Thanks for you help.

Hugo

0 项奖励