EmbDev.net

Forum: ARM programming with GCC/GNU tools Variable Space in internal AT91SAM7 flash


von Nick Moszer (Guest)


Rate this post
useful
not useful
Hello,

Has anyone found a need to modify the linker scripts for the AT91SAM7 to
carve off some internal flash variable space?

I'm working with a AT91SAM7S256 and would LIKE to shave off the top 1k
to store variables but am having trouble getting it to work right.

Details:  using WinARM w/ gcc 4.1.1
I have the linker scripts from Martin Thomas' gamma example (last
updated on 2-Sept-06.  In my AT91SAM7S256_memory.ldh file I modified it
as follows:

From:

MEMORY
{
  CODE (rx)  : ORIGIN = 0x00100000, LENGTH = 256k
  DATA (rwx) : ORIGIN = 0x00200000, LENGTH = 64k
}

To:

MEMORY
{
  CODE (rx)  : ORIGIN = 0x00100000, LENGTH = 255k
  DATA (rwx) : ORIGIN = 0x00200000, LENGTH = 64k
  VARS (rx)  : ORIGIN = 0x0013FC00, LENGTH = 1k
}


And declared a variable as:
const unsigned int checker _attribute_ ((section ("VARS"))) = 0xF;

When the linker runs and it reports the following:

Size after:
main.tmp.elf  :
section     size      addr
.text      53444   1048576
VARS           4   1102020
.data       2928   2097152
.noinit       12   2100080
.bss        3328   2100092
.comment    1512         0
Total      61228

So it looks like the variable is in the "VARS" section but the address
doesn't make sense.  It is in the "CODE" section a.k.a. addr:
0x0010D0C4.

I'm guessing I have to modify the AT91SAM7S_sections_ROM.ldh file to
accomodate this change but that file just looks scary.

Has anyone done something similar and got it to work out?

Thanks in advance for any help!

von Nick Moszer (Guest)


Rate this post
useful
not useful
Nick Moszer wrote:
> Hello,
>
> Has anyone found a need to modify the linker scripts for the AT91SAM7 to
> carve off some internal flash variable space?
>
> I'm working with a AT91SAM7S256 and would LIKE to shave off the top 1k
> to store variables but am having trouble getting it to work right.
>
> Details:  using WinARM w/ gcc 4.1.1
> I have the linker scripts from Martin Thomas' gamma example (last
> updated on 2-Sept-06.  In my AT91SAM7S256_memory.ldh file I modified it
> as follows:
>
> From:
>
> MEMORY
> {
>   CODE (rx)  : ORIGIN = 0x00100000, LENGTH = 256k
>   DATA (rwx) : ORIGIN = 0x00200000, LENGTH = 64k
> }
>
> To:
>
> MEMORY
> {
>   CODE (rx)  : ORIGIN = 0x00100000, LENGTH = 255k
>   DATA (rwx) : ORIGIN = 0x00200000, LENGTH = 64k
>   VARS (rx)  : ORIGIN = 0x0013FC00, LENGTH = 1k
> }
>
>
> And declared a variable as:
> const unsigned int checker _attribute_ ((section ("VARS"))) = 0xF;
>
> When the linker runs and it reports the following:
>
> Size after:
> main.tmp.elf  :
> section     size      addr
> .text      53444   1048576
> VARS           4   1102020
> .data       2928   2097152
> .noinit       12   2100080
> .bss        3328   2100092
> .comment    1512         0
> Total      61228
>
> So it looks like the variable is in the "VARS" section but the address
> doesn't make sense.  It is in the "CODE" section a.k.a. addr:
> 0x0010D0C4.
>
> I'm guessing I have to modify the AT91SAM7S_sections_ROM.ldh file to
> accomodate this change but that file just looks scary.
>
> Has anyone done something similar and got it to work out?
>
> Thanks in advance for any help!


Wow, ok I think I actually got it.  Maybe anyway.

I just edited that AT91SAM7S_sections_ROM.ldh as (added .vars):

  .dtors :
  {
    PROVIDE(_dtors_start_ = .);
    KEEP(*(SORT(.dtors.*)))
    KEEP(*(.dtors))
    PROVIDE(_dtors_end_ = .);
  } >CODE

  . = ALIGN(4);

  .vars :
  {
    __vars_start = . ;
    _vars_start_ = . ;
    *(.vars)
    *(.vars.*)
    *(.gnu.linkonce.v.*)
    *(VARS)
    . = ALIGN(4);
  } >VARS

  . = ALIGN(4);

  _etext = . ;
  PROVIDE (etext = .);

  /* .data section which is used for initialized data */
  .data : AT (_etext)
  {


Is this the proper way to do this?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.