How to put a constant array into a specified flash memory?

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

How to put a constant array into a specified flash memory?

Jump to solution
1,538 Views
tanmingming
Contributor II

     Hello!     

     I want to put a constant array into a specified flash memory (address is 0x00007FF0)in S32 Design Studio for ARM.However,"const  char flag[10]@0x00007FF0" doesn't work.

    So,Should I modify the  Flash.ld?111.jpg

1 Solution
1,256 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you need to add custom section into linker file:

/* Specify the memory areas */
MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x00007BE0
m_mydata (RX) : ORIGIN = 0x00007FF0, LENGTH = 0x000000FF

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00007000
}

/* Define output sections */
SECTIONS
{

.mydata :
{
   KEEP(*(.mydata))
} > m_mydata

and define variable by using __attribute__ like this:

__attribute__ ((section(".mydata"))) const char flag[] = {"ABCDEFGHIJ"};

Jiri

View solution in original post

2 Replies
1,257 Views
jiri_kral
NXP Employee
NXP Employee

Hi, 

you need to add custom section into linker file:

/* Specify the memory areas */
MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x00007BE0
m_mydata (RX) : ORIGIN = 0x00007FF0, LENGTH = 0x000000FF

/* SRAM_L */
m_data (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00008000

/* SRAM_U */
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00007000
}

/* Define output sections */
SECTIONS
{

.mydata :
{
   KEEP(*(.mydata))
} > m_mydata

and define variable by using __attribute__ like this:

__attribute__ ((section(".mydata"))) const char flag[] = {"ABCDEFGHIJ"};

Jiri

1,256 Views
tanmingming
Contributor II

Hi,

Thank you very much for your help.

 It's useful to add the "KEEP".I have solved the problem. :smileyhappy:

Best wishes

Mingming

0 Kudos