A common way to just define the specified address as this does not require you to modify the linker script file.
#define version_info *(int *)0x80000000
and then write to the address:
version_info = 1234;
Are you able to use this approach?
Thanks for your support.
Maybe my description is not clear.
I want to assign a value to address during compiler phase, not in run-time phase.
That means, after the code is compiled, the value is assigned to my specified address.
For example, I want to assign value 1234 at address 0x08000000. And after the code is compiled, I can see from image file (hex file etc.) that the value of address 0x08000000 is 0x1234.
How to do it?
1 of 1 people found this helpful
Create a.c with the following line:
unsigned int myint __attribute__ ((section (".mysection"))) = 1234;
Then, at link time, add -Wl,--section-start=.mysection=0x800000 to the command line.
Thanks for your help.
But I tried and it does not work.
I have found a solution for it:
create a section in ld file:
} > BOOT_CODE_INFO
and in my source code, create a variable:
const unsigned short verinfo __attribute__ ((section (".BOOTCODE_VER"))) = 0x1234;
Anyway, thanks very much for your quickly support.