Hi,
I would like to write the data to absolute address.
So I do as below, but warnig is occured and don't write the data.
How to write the data to absolute address?
Best regards,
Byungju.
Solved! Go to Solution.
Hi,
The safe way is modify your linker script and add section in RAM for your variable(s). If you have more vars - just put them in a struct - if you don't like to have section for each var.
m_myram (RW) : ORIGIN = 0x20000000, LENGTH = 0x00000010
SECTIONS
{
.my_ram_space (NOLOAD):
{
*(.my_ram_space)
} > m_myram
Variable def:
__attribute__ ((section(".my_ram_space"))) int my_abs_var;
There is example - https://community.nxp.com/docs/DOC-335619 which uses DFLASH for data - the same principle you can use for store data in regular flash area (just use your address 0x20400).
Jiri
I also found this topic on Erich Styger's blog - Defining Variables at Absolute Addresses with gcc | MCU on Eclipse
But in this case there is no exactly defined address - your section is added in the m_data memory space based on place in SECTIONS definition. If your section is very first - it starts on beginning.
Jiri
Hi Jiri,
Thanks for your help.
It is very helpful for me.
Best regards,
Byugnju.
Hi,
The safe way is modify your linker script and add section in RAM for your variable(s). If you have more vars - just put them in a struct - if you don't like to have section for each var.
m_myram (RW) : ORIGIN = 0x20000000, LENGTH = 0x00000010
SECTIONS
{
.my_ram_space (NOLOAD):
{
*(.my_ram_space)
} > m_myram
Variable def:
__attribute__ ((section(".my_ram_space"))) int my_abs_var;
There is example - https://community.nxp.com/docs/DOC-335619 which uses DFLASH for data - the same principle you can use for store data in regular flash area (just use your address 0x20400).
Jiri
I don't know is it correct,why don't you use the pointer?For example,if I want to write 0x55 at 0x8000 0000,I can use the pointer,
*((volatile uint32_t *)(0x8000 0000)) = 0x55;
Hi,
I want write some information to the specific address that is not application source code section.
the informations are sw version, application source code mask to check validation and so on.
I can read the information I want at the address in binary file.
The way you showed me is not right for what i want.
Thanks for your help.
Best regards,
Byungju.
Hello Byungju,
Which MCU?
BR
Alice
Dear Alice,
I use S32K144 MCU.
Best Regards,
Byungju.