AnsweredAssumed Answered

how to use" __attribute__ ((section(""))) "to lnitialize a variable

Question asked by jinshuai xu on Aug 17, 2017
Latest reply on Aug 17, 2017 by jinshuai xu

l want to initialize the memory 0x10000000-0x1000 0007 with {0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01}, I set

in   .c

 __attribute__ ((section(".APP_VERSION1"))) uint8_t test5[8]={0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01} ;

for(i=0;i<8;i++)   {sourceBuffer[i]=test5[i];}

I found from test5[0] to test5[7] and sourceBuffer[0] to sourceBuffer[7] is 0xff,who can tell me how to initialize it,thank you for you response.

 

 

below is my code 

in   .c

 __attribute__ ((section(".APP_VERSION1"))) uint8_t test5[8]={0x08,0x07,0x06,0x05,0x04,0x03,0x02,0x01} ;

 

in .ld

 

MEMORY
{
/* Flash */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0-0x8000

/* ccp_1 (RX : ORIGIN = 0x00042000, LENGTH = 0x00002000
name_1 (RX) : ORIGIN = 0x00044000, LENGTH = 0x00002000 */

ccp_1 (RW) : ORIGIN = 0x10000000, LENGTH = 0x00002000
name_1 (RW) : ORIGIN = 0x10002000, LENGTH = 0x00002000

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

/* my_data1 (1FFF8000 1FFF CFFFF )20K ( 1FFFD000 1FFFFFFF 8K )
my_data1 (RW) : ORIGIN = 0x1FFFd000, LENGTH = 0x00002000
*/

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

SECTIONS
{

...

.APP_VERSION1 :
{
. = ALIGN(4);
KEEP (*(.APP_VERSION1))
. = ALIGN(4);
} > ccp_1

...}

Original Attachment has been moved to: flash_TEST.rar

Outcomes