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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
972 Views
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 (full version of script as attached file):

 

MEMORY

{

    resetvector:           org = 0x00000000,   len = 0x00000008

 

    system_cfg:            org = 0x00003000,   len = 0x00000010

    internal_flash:        org = 0x00003010,   len = 0x000FCFF0

(...)

}

 

(...)

 

.__software_version (CONST) LOAD(ADDR(.__software_version)) : {} > 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 = 0x12345678;

#pragma pop

 

In the linker setting, I put ROM Image Address and RAM Buffer Address of ROM Image at 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

 

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

 

Hugo

Original Attachment has been moved to: intflash.lcf.zip

Labels (1)
0 Kudos
1 Solution
824 Views
hbouch
Contributor III

Thanks Lukas,

I'm doing pretty much what's in the example you sent me. However, to avoid linker warnings and to make my code runnable, I need to put ROM Image Address and RAM Buffer Address of ROM Image at 0x00003010.

When I use address 0x00003010, the new section created is not included in the output file. Therefore I need to add the constant of the software version in the FORACTIVE section of the linker file or used __declspec(force_export) when declaring it. That's the part I was missing...

Thanks!

Hugo

View solution in original post

0 Kudos
2 Replies
824 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I found old test project in my repository. See attachment - take a look at main.c and linker file.

And one more thing I can remember - if the start address of "internal_flash" segment is changed, it is necessary to update the linker settings: RAM Buffer Address and ROM Image Address must be set to the same value:

pastedImage_0.png

pastedImage_1.png

Regards,

Lukas

0 Kudos
825 Views
hbouch
Contributor III

Thanks Lukas,

I'm doing pretty much what's in the example you sent me. However, to avoid linker warnings and to make my code runnable, I need to put ROM Image Address and RAM Buffer Address of ROM Image at 0x00003010.

When I use address 0x00003010, the new section created is not included in the output file. Therefore I need to add the constant of the software version in the FORACTIVE section of the linker file or used __declspec(force_export) when declaring it. That's the part I was missing...

Thanks!

Hugo

0 Kudos