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
Solved! Go to Solution.
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
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!
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?
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