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

JM hondgm at yahoo.com
Fri Apr 6 12:03:38 UTC 2012


Sorry, I'm a little confused.  I'm getting an error

bi/4.5.2/../../../../arm-none-eabi/bin/ld.exe: section .data loaded at [00028bc0,00028bcf] overlaps section .sram1 loaded at [00028bc0,00028c7b]
collect2: ld returned 1 exit status
cs-make: *** [RTOSDemo.axf] Error 1

so something is wrong.  I'm fairly sure I misinterpreted the change you suggested.  


MEMORY
{
    FLASH (rx) : ORIGIN = 0x00001000, LENGTH = 252K
    SRAM1 (rwx) : ORIGIN = 0x20000000, LENGTH = 464
    DMA (rwx) : ORIGIN = 0x200001D0, LENGTH = 16
    SRAM2 (rwx) : ORIGIN = 0x200001E0, LENGTH = 97824
}

SECTIONS
{
    .text :
    {
        KEEP(*(.isr_vector))
        *(.text*)
        *(.rodata*)
        _etext = .;
    } > FLASH

    .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

    .bss(NOLOAD) :
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        _ebss = .;
        . = ALIGN (8);
       _end = .;
    } > SRAM2
    
    .dmaRegisters  0x200001D0 (NOLOAD) : 
    {
        *(.dmaRegisters)
    } > DMA    

}

/* end of allocated ram _end */
PROVIDE( _HEAP_START = _end );

/* end of the heap -> align 8 byte */ 
PROVIDE ( _HEAP_END = ALIGN(ORIGIN(SRAM2) + LENGTH(SRAM2),8) );




________________________________
 From: 42Bastian <list-bastian.schick at sciopta.com>
To: arm-gnu at codesourcery.com 
Sent: Friday, April 6, 2012 6:57 AM
Subject: Re: [arm-gnu] Placing variable at absolute address in RAM
 
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.
+
_______________________________________________
arm-gnu mailing list
arm-gnu at codesourcery.com
http://sourcerytools.com/cgi-bin/mailman/listinfo/arm-gnu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/arm-gnu/attachments/20120406/fafb7c1a/attachment.html>


More information about the arm-gnu mailing list