Re: [avr-gcc-list] Howto put constants on fixed address
Stu Bell [EMAIL PROTECTED] wrote: My feeling is that you are asking quite a bit too much from the linker to expect it to flow code around an obstacle in the middle of it's memory map. I agree. If at all, I'd simply use the last (upmost) ROM location for that magic number or magic string. Another option would be to use a real magic string right behind the vectors table. Just introduce it by a known 32-bit word that can never be part of the vectors table itself. This is basically the way the old revision control system SCCS worked with its @(#) magic number, which was then found and extracted by the what command. -- cheers, Jorg .-.-. --... ...-- -.. . DL8DTL http://www.sax.de/~joerg/NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-) ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Howto put constants on fixed address
You've now found yourself exactly where I did. I wanted to bury a software part number at 0x100 in the flash so a 'universal' programming 'pod' could look in this specific location of the hex file and determine if the target was valid for an upgrade regardless of what AVR was implemented on the target board. Best I could do is define my own section at 0x100 leaving the bytes below unused. It appears that the gcc linker is not able to wrap code around this reserved section like the IAR linker can and utilize the space above and below 'my section'. [EMAIL PROTECTED] 12/20/2007 9:09 AM Thanks for the links, but that is not exactly what I am looking for. Using this document I was able to create output like this: 0x-0x008F .vectors 0x0090-0x03FF gap 0x0400-0x041F my section 0x0420- rest of the .text section The gap is empty - it's waste of the flash space. I have not found if it is possible to put my section to any address and let linker to flow the .text section round it, it seems to me that it is not possible, but I don't know why - the linker should be able to do this, it's not a difficult task... __ Od: [EMAIL PROTECTED] Komu: Martin Ĺ̋iĹžka [EMAIL PROTECTED] CC: avr-gcc List avr-gcc-list@nongnu.org Datum: 20.12.2007 01:12 Předmět: Re: [avr-gcc-list] Howto put constants on fixed address On Dec 19, 2007, at 5:03 PM, Martin Žižka wrote: Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. I think this URL describes the syntax to do what Martin is looking to do: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_21.html#SEC21 More hints here, in that one can edit the . address: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_10.html -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Howto put constants on fixed address
Thanks for the links, but that is not exactly what I am looking for. Using this document I was able to create output like this: 0x-0x008F .vectors 0x0090-0x03FF gap 0x0400-0x041F my section 0x0420- rest of the .text section The gap is empty - it's waste of the flash space. I have not found if it is possible to put my section to any address and let linker to flow the .text section round it, it seems to me that it is not possible, but I don't know why - the linker should be able to do this, it's not a difficult task... __ Od: [EMAIL PROTECTED] Komu: Martin Ĺ˝iĹžka [EMAIL PROTECTED] CC: avr-gcc List avr-gcc-list@nongnu.org Datum: 20.12.2007 01:12 Předmět: Re: [avr-gcc-list] Howto put constants on fixed address On Dec 19, 2007, at 5:03 PM, Martin Žižka wrote: Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. I think this URL describes the syntax to do what Martin is looking to do: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_21.html#SEC21 More hints here, in that one can edit the . address: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_10.html -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. So what? You are able to reference the location directly by the variable name in the code. Even so, it will always be placed immediately after the interrupt vectors, so you always know where it is for a particular CPU. Since you will need to recompile the code for any new CPU (trust me), your argument is a non-issue. BTW, offset_of(.vectors) is 0 for all AVRs. For example, for my ATmega2560, I know that the variable is *always* at 0xE4. Best regards, Stu Bell DataPlay (DPHI, Inc.) ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
Yes, that's exactly what I need. And yes, I'm used to IAR and others, where this is possible. I wanted to find out if it is possible to do this with gcc, I really did not expect any problem with this. I thought that I just have not found the right documentation... :-( _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of TODD BATZLER Sent: Thursday, December 20, 2007 4:32 PM To: avr-gcc-list@nongnu.org Subject: Re: [avr-gcc-list] Howto put constants on fixed address You've now found yourself exactly where I did. I wanted to bury a software part number at 0x100 in the flash so a 'universal' programming 'pod' could look in this specific location of the hex file and determine if the target was valid for an upgrade regardless of what AVR was implemented on the target board. Best I could do is define my own section at 0x100 leaving the bytes below unused. It appears that the gcc linker is not able to wrap code around this reserved section like the IAR linker can and utilize the space above and below 'my section'. [EMAIL PROTECTED] 12/20/2007 9:09 AM Thanks for the links, but that is not exactly what I am looking for. Using this document I was able to create output like this: 0x-0x008F .vectors 0x0090-0x03FF gap 0x0400-0x041F my section 0x0420- rest of the .text section The gap is empty - it's waste of the flash space. I have not found if it is possible to put my section to any address and let linker to flow the .text section round it, it seems to me that it is not possible, but I don't know why - the linker should be able to do this, it's not a difficult task... __ Od: [EMAIL PROTECTED] Komu: Martin Ĺ̋iĹžka [EMAIL PROTECTED] CC: avr-gcc List avr-gcc-list@nongnu.org Datum: 20.12.2007 01:12 Předmět: Re: [avr-gcc-list] Howto put constants on fixed address On Dec 19, 2007, at 5:03 PM, Martin Žižka wrote: Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. I think this URL describes the syntax to do what Martin is looking to do: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_21.html#SEC21 More hints here, in that one can edit the . address: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_10.html -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] org] On Behalf Of Zizka Sent: Wednesday, December 19, 2007 9:13 AM To: avr-gcc-list@nongnu.org Subject: [avr-gcc-list] Howto put constants on fixed address 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 [0400 - 040a] overlaps section .text [ - 1b7d] 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 AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .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 [0400 - 040a] overlaps section .text [ - 1b7d] 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 AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Howto put constants on fixed address
On Wed, Dec 19, 2007 at 06:07:19PM +0100, [EMAIL PROTECTED] wrote: 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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .foo section 0420-end the rest of .text section I have done this in Introl-C11 where I had external memory mapped I/O registers. I had to manually massage the linker editor script file. For avr-gcc this will be in /usr/local/avr/lib/ldscripts/ (or similar in WinAVR). But you don't want to edit those but to copy one into your project and figure out how to override the default with your own. Due to the memory map I had I/O in the midst of my EPROM space. Once I got the Introl linker working the way I wanted it nicely split my object code around the I/O sections. One must question the need to map constants to a predetermined location in FLASH? -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
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 avrarchitecture.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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 10:07 AM To: avr-gcc-list@nongnu.org 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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .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 [0400 - 040a] overlaps section .text [ - 1b7d] 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 AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Stu Bell Sent: Wednesday, December 19, 2007 10:26 AM To: [EMAIL PROTECTED]; avr-gcc-list@nongnu.org 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 avrarchitecture.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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 10:07 AM To: avr-gcc-list@nongnu.org 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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .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 [0400 - 040a] overlaps section .text [ - 1b7d] 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 AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
Can you send me that linker script? I've tried to alter that script to make it work that way I want with no success. I was only able to give my code place before the whole .text segment (after the vectors) or after the whole .text segment, but I was not able to put my constants to specific address somewhere inside the .text segment. -Original Message- From: David Kelly [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 6:45 PM To: [EMAIL PROTECTED] Cc: avr-gcc-list@nongnu.org Subject: Re: [avr-gcc-list] Howto put constants on fixed address On Wed, Dec 19, 2007 at 06:07:19PM +0100, [EMAIL PROTECTED] wrote: 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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .foo section 0420-end the rest of .text section I have done this in Introl-C11 where I had external memory mapped I/O registers. I had to manually massage the linker editor script file. For avr-gcc this will be in /usr/local/avr/lib/ldscripts/ (or similar in WinAVR). But you don't want to edit those but to copy one into your project and figure out how to override the default with your own. Due to the memory map I had I/O in the midst of my EPROM space. Once I got the Introl linker working the way I wanted it nicely split my object code around the I/O sections. One must question the need to map constants to a predetermined location in FLASH? -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Howto put constants on fixed address
Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. -Original Message- From: Stu Bell [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 6:26 PM To: [EMAIL PROTECTED]; avr-gcc-list@nongnu.org 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 avrarchitecture.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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, December 19, 2007 10:07 AM To: avr-gcc-list@nongnu.org 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: -03FFsome part of .text section (including vectors and so on) 0400-041Fmy .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 [0400 - 040a] overlaps section .text [ - 1b7d] 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 AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Howto put constants on fixed address
On Dec 19, 2007, at 5:03 PM, Martin Žižka wrote: Yes, that will place the .length segment between .vectors and .progmem. But you are unable to place it to some exact address. That will place it to address that is offset_of(.vectors)+length_of(.vectors). That can be different for some cpus. I think this URL describes the syntax to do what Martin is looking to do: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_21.html#SEC21 More hints here, in that one can edit the . address: http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_10.html -- David Kelly N4HHE, [EMAIL PROTECTED] Whom computers would destroy, they must first drive mad. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list