How to place a byte-array at a specific location in FLASH? (Need help with #pragma key-words)

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

How to place a byte-array at a specific location in FLASH? (Need help with #pragma key-words)

1,719 Views
claus_schmidt
Contributor I
Hello
 
Can any one guide me with some #pragma key words and examples of how I place a const in a specific FLASH location, so that it can be modified later.
 
I think it has something to do with seting up a segment in the linker file (.lcf) (don't need more than 10 bytes).
And with the key-word of that segment use some kind of #pragma when defining my const.
 
Any one?
Labels (1)
0 Kudos
2 Replies

483 Views
Nouchi
Senior Contributor II
Hi,

Your lcf file might looks like this:
Code:
MEMORY{        flash    (RX)  : ORIGIN = 0x00000000, LENGTH = 0x0003FFBF specSect (RX)  : ORIGIN = 0x0003FFC0, LENGTH = 0x00000040 vram (RWX) : ORIGIN = 0x20000000, LENGTH = 0x00000400 sram (RWX) : ORIGIN = 0x20000400, LENGTH = 0x00007C00 ipsbar  (RWX) : ORIGIN = 0x40000000, LENGTH = 0x0}SECTIONS { .ipsbar  : {} > ipsbar     .vectors : {  vectors.s (.text)  . = ALIGN (0x10); } > flash        .text :    {        *(.text)  .= ALIGN(0x10);        *(.rodata)  .= ALIGN(0x10);        ___DATA_ROM    = .;        __S_romp       = .;     } >> flash .yourArraySection : {  *(.yourArrayZone) } > specSect     .data : AT(ADDR(.text)+SIZEOF(.text))  {  ___DATA_RAM    = .;        *(.exception)   .              = ALIGN(0x10);   __exception_table_start__ = .;     EXCEPTION  __exception_table_end__   = .;  ___sinit__    = .;     STATICINIT        *(.data)  .             = ALIGN (0x10);  ___DATA_END   = .;  __START_SDATA = .;        *(.sdata)  .             = ALIGN (0x10);  __END_SDATA   = .;  __SDA_BASE    = .;  .             = ALIGN(0x10); } > sram .bss : {  . = ALIGN(0x10);  __START_SBSS = .;  *(.sbss)  *(SCOMMON)  __END_SBSS   = .;  . = ALIGN(0x10);  __START_BSS  = .;  *(.bss)  *(COMMON)  __END_BSS    = .;         ___BSS_START = __START_SBSS;        ___BSS_END   = __END_BSS;        . = ALIGN(0x10); } >> sram ___FLASH  = ADDR(.vectors); ___FLASH_SIZE = 0x0003E000; ___SRAM   = ADDR(sram); ___SRAM_SIZE = 0x00007C00; ___VECTOR_RAM = ADDR(vram); ___IPSBAR  = ADDR(.ipsbar);    ___SP_SIZE      = 0x400; ___HEAP_START = .; ___HEAP_END  = ___SRAM + ___SRAM_SIZE - ___SP_SIZE; ___SP_END  = ___HEAP_END; ___SP_INIT  = ___SP_END + ___SP_SIZE;    ___heap_addr  = ___HEAP_START; ___heap_size  = ___HEAP_END - ___HEAP_START ; __SP_INIT   = ___SP_INIT; }

and in your C file :
Code:
#pragma define_section yourArrayZone ".yourArrayZone" far_absolute R__declspec(yourArrayZone)char WhatYouWant[] = {"Data of your Array"};

Emmanuel


 

 

0 Kudos

483 Views
claus_schmidt
Contributor I
Thanks.
 
It did the job.
 
I had to move the specSect to 0x0001FFC0 due to a license limit at 128k though. Took me a while to find :smileywink:
 
specSect (RX) : ORIGIN = 0x0001FFC0,  LENGTH = 0x00000040
 
 
Thanks again.
Claus
0 Kudos