Re: Constant at fixed address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/02/2022 22:37, Henrique Coser wrote:
> Martin and David,  thank you for your answers.
> 
> Attached is the linker script that I use.
> 
> In Keil, where I did the first version of the boot loader I can assure you that a constant value is placed and correctly filled when use __attribute__((at(0x0401000)))
> I don't know how they do this but they do!
> 
> I would be grateful If you could help me editting this script.
> 
> Thank you very much.
> 
> 

The length of your "rom" space in sam3s4b_flash.ld does not make much
sense.  I haven't used Atmel's SAM devices, but I'd be surprised to see
one with a little under 12 K flash.

The linker files you attached are not, I think, the ones you used when
you got the link error - they don't have any mention of the
".bootversion" section.  So all I can do is show a typical way to have
this set up in a linker file.



Your "rom" section starts with :

   .text :
    {
        . = ALIGN(4);
        _sfixed = .;
        KEEP(*(.vectors .vectors.*))
        *(.text .text.* .gnu.linkonce.t.*)
        ...
    } > rom

That will put the ".vectors" section(s) first, at the start of rom, then
everything after it.

What you need to have is the fixed sections, then everything that can be
freely allocated:

   .headers :
    {
        FILL(0xff)
        . = ALIGN(4);
        _sfixed = .;
        KEEP(*(.vectors .vectors.*))
        . = 0x1000;
        KEEP(*(.bootversion .bootversion.*))
    } > rom

   .text :
    {
        . = ALIGN(4);
        *(.text .text.* .gnu.linkonce.t.*)
        ...
    } > rom


Then the main ".text" and other flash sections get put after the
bootversion section, and you don't get an overlap.

This wastes the space between the vectors and the fixed .bootversion
section, but you could put other data there if you like (maybe some of
the arrays used for constructors or initialisation).  Don't bother
unless you are tight for space.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux