avr-gcc-list
[Top][All Lists]
Advanced

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

RE: [avr-gcc-list] Howto put constants on fixed address


From: Stu Bell
Subject: RE: [avr-gcc-list] Howto put constants on fixed address
Date: Wed, 19 Dec 2007 10:55:17 -0700

Darn it, the wrap function messed up the C:

/* flash code length -- this is loaded in flash by the linker and other
scripts */
const uint32_t ProgramLength __attribute__ ((section (".length"))) = 0;

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Stu Bell
Sent: Wednesday, December 19, 2007 10:26 AM
To: address@hidden; address@hidden
Subject: RE: [avr-gcc-list] Howto put constants on fixed address

I have code in my bootloader that runs a CRC on the loaded code for a
sanity check.  For that I need a length.  Of course, that needs to be
supplied after the code is compiled, but I allocate space for it by
doing the following:

In the .c file:

/* flash code length -- this is loaded in flash by the linker and other
scripts */ const uint32_t ProgramLength __attribute__ ((section
(".length"))) = 0;

Modified linker script (This is avr<architecture>.x in
<WinAVR>\avr\lib\ldscripts - for me avr6.x):

. . . 
  /* Internal text space or external memory.  */
  .text :
  {
    *(.vectors)
    KEEP(*(.vectors))
    *(.length)
    KEEP(*(.length))
    /* For data that needs to reside in the lower 64k of progmem.  */
    *(.progmem.gcc*)
. . .

(where the .length stuff is what I added)

Give it a shot.


Best regards, 

Stu Bell
DataPlay (DPHI, Inc.) 


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
address@hidden
Sent: Wednesday, December 19, 2007 10:07 AM
To: address@hidden
Subject: RE: [avr-gcc-list] Howto put constants on fixed address

Well, perhaps I've written something wrong, because I think that you are
talking about something else. Or I did not understand that, that is also
possible :-).

I need to put my constants on specific address into flash memory, not
into sram. I want to have the resulting flash content like this:

0000-03FF    some part of .text section (including vectors and so on)
0400-041F    my .foo section
0420-end     the rest of .text section
______________________________________________________________
>> Hi, I need to put some constants on specific address, for example 
>> 0x400.
>> 
>> I've declared my constants in a section .foo:
>> char __attribute__ ((section(".foo"))) myconsts="qwertyuiop";
>> 
>> then I've compiled that code using:
>> -Wl,-section-start=.foo=0x200
>> 
>> 
>> But I get this error:
>> .... ld.exe: section .foo [00000400 -> 0000040a] overlaps section 
>> .text [00000000 -> 00001b7d]
>> 
>> 
>> I've tried to change the linker script and so on, but I was unable to

>> "insert" my code into the .text section. The only solution was to 
>> place my section after the end of the .text section, so the sections 
>> do not overlap, but that is not what I want. Is it possible to put 
>> section to any address?
>> Or are the sections "unbreakable"?
>
>I thought this answer was in the avr-libc user manual somwhere.
>
>The linker cannot do separate address spaces, it only knows about a 
>single address space. So .data, .bss, .eeprom are set at specific, very

>high offsets to make them fit in this single address space and not 
>overlap the .text (code) section. Add the relevant offset to your 
>-section-start flag. See the default linker scripts to see how this 
>works.



_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




reply via email to

[Prev in Thread] Current Thread [Next in Thread]