How to wirte the data to absolute address?

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

How to wirte the data to absolute address?

Jump to solution
3,583 Views
kbj
Contributor IV

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?

1.PNG

Best regards,

Byungju.

Labels (2)
1 Solution
3,021 Views
jiri_kral
NXP Employee
NXP Employee

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

View solution in original post

7 Replies
3,021 Views
jiri_kral
NXP Employee
NXP Employee

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 

3,021 Views
kbj
Contributor IV

Hi Jiri,

Thanks for your help.

It is very helpful for me.

Best regards,

Byugnju.

0 Kudos
3,022 Views
jiri_kral
NXP Employee
NXP Employee

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

3,021 Views
578294688
Contributor II

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;

0 Kudos
3,021 Views
kbj
Contributor IV

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.

0 Kudos
3,021 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Byungju,

Which MCU?

BR

Alice

0 Kudos
3,021 Views
kbj
Contributor IV

Dear Alice,

I use S32K144 MCU.

Best Regards,

Byungju.

0 Kudos