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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

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

跳至解决方案
1,598 次查看
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 解答
1,316 次查看
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

在原帖中查看解决方案

2 回复数
1,317 次查看
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,316 次查看
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 项奖励