[arm-gnu] Placing variable at absolute address in RAM

42Bastian list-bastian.schick at sciopta.com
Fri Apr 6 10:57:38 UTC 2012


Hi

> I manually chose several static and global variables to go into SRAM1
> using "__attribute__ ((section(".sram1")))", and this works pretty well
> linker-wise.  The problem is, some of these variables no longer
> function.  I can't say how exactly because they are from a third party
> library (lwIP) and I haven't debugged yet, but I know if I let the
> linker allocate automatically, they're ok.

For variables that do not go to the standard places .data and .bss you
need to initialize them with your own code.

If you are lucky, those variables are initialized to zero, so you can do
a memset() of SRAM by hand.

If initialized you need to enhance your linker script like this:

 .sram1 : {
	*(.sram1_data)
	sram1_bss = .;
	*(.sram1_bss)
 } > SRAM1 AT > FLASH

sram1_loadaddr = LOADADDR(.sram1);

> .data : AT (ADDR(.text) + SIZEOF(.text)) { _data = .; *(vtable) 
> *(.data*) _edata = .; } > SRAM2

BTW: Better way is
.data : {

} > SRAM2 AT > FLASH
(Leave it to ld to do the calculation.)


-- 
42Bastian
+
| http://www.sciopta.com
| Fastest direct message passing kernel.
| IEC61508 certified.
+



More information about the arm-gnu mailing list