Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 4, 2005 02:33:16

Colin O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


Hey,

I'm trying to get Mega168 working, and have done something I'm not sure about.
I'm trying to compile a bootloader, and the relevent part of this is:

Linking: tinyloader.elf
avr-gcc tinyloader.o --output tinyloader.elf -Wl,--section-start=.text=0x3E00
-Wl,-Map=tinyloader.map,--cref -nostartfiles
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld: address 0x3f9e of
tinyloader.elf section .text is not within region text
make: *** Error 1

But the flash of the Mega168 runs till 0x3fff I thought.

Regards,

-Colin


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

Offline

#2 Nov. 4, 2005 06:04:30

Joerg W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


"Colin O'Flynn" <> wrote:

> /opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld: address 0x3f9e of
> tinyloader.elf section .text is not within region text
> make: *** Error 1

> But the flash of the Mega168 runs till 0x3fff I thought.

It appears as if the linker script of an ATmega88 has been used here.

--
cheers, J"org .-.-. --... ...-- -.. . DL8DTLhttp://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.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#3 Nov. 4, 2005 15:33:55

Colin O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


Hey,

Any idea how to fix it for real? I just added this linker option:
/opt/avr/avr/lib/ldscripts/avr5.x
to force it to pick up avr5.x and not whatever it was. What might be a related
problem is I had to symlink crtm168.o from /opt/avr/avr/lib/crtm168.o
to /opt/avr/lib/avr5/crtm168.o

Or is it just my installation has a problem?

Warm Regards,

-Colin


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

Offline

#4 Nov. 4, 2005 18:59:37

Joerg W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


"Colin O'Flynn" <> wrote:

> Any idea how to fix it for real?

Seems your compiler is incorrectly patched. When I call avr-gcc with
-v, it gives me:

% avr-gcc -v -mmcu=atmega168 -Wl,--section-start=.text=0x3E00 -o foo foo.c
Reading specs from /usr/local/lib/gcc/avr/3.4.4/specs
Configured with: ./configure --target=avr --disable-nls --prefix=/usr/local
i386-portbld-freebsd5.3
Thread model: single
gcc version 3.4.4
/usr/local/libexec/gcc/avr/3.4.4/cc1 -quiet -v foo.c -quiet -dumpbase foo.c
-mmcu=atmega168 -auxbase foo -version -o /var/tmp//cc6Zs6uF.s
ignoring nonexistent directory
"/usr/local/lib/gcc/avr/3.4.4/../../../../avr/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/avr/3.4.4/include
/usr/local/lib/gcc/avr/3.4.4/../../../../avr/include
End of search list.
GNU C version 3.4.4 (avr)
compiled by GNU C version 3.4.2 20040728.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64436
/usr/local/lib/gcc/avr/3.4.4/../../../../avr/bin/as -mmcu=atmega168 -o
/var/tmp//ccoG61Gn.o /var/tmp//cc6Zs6uF.s
/usr/local/lib/gcc/avr/3.4.4/../../../../avr/bin/ld -m avr5 -Tdata 0x800100 -o
foo /usr/local/lib/gcc/avr/3.4.4/../../../../avr/lib/avr5/crtm168.o
-L/usr/local/lib/gcc/avr/3.4.4/avr5 -L/usr/local/lib/gcc/avr/3.4.4
-L/usr/local/lib/gcc/avr/3.4.4/../../../../avr/lib/avr5
-L/usr/local/lib/gcc/avr/3.4.4/../../../../avr/lib --section-start=.text=0x3E00
/var/tmp//ccoG61Gn.o -lgcc -lc -lgcc

Trying to allocate beyond 0x4000 doesn't give me an error either
(which is expected for avr5).

My GCC patch is:

diff -ur ../gcc-3.4.4.orig/gcc/config/avr/avr.c ./gcc/config/avr/avr.c
--- ../gcc-3.4.4.orig/gcc/config/avr/avr.c Sun Mar 20 22:14:28 2005
+++ ./gcc/config/avr/avr.c Mon Sep 12 22:54:25 2005
@@ -175,6 +175,12 @@
{ "at90c8534", 2, "__AVR_AT90C8534__" },
{ "at90s8535", 2, "__AVR_AT90S8535__" },
{ "at86rf401", 2, "__AVR_AT86RF401__" },
+ /* Classic + MOVW, <= 8K. */
+ { "attiny13", 2, "__AVR_ATtiny13__" },
+ { "attiny2313", 2, "__AVR_ATtiny2313__" },
+ { "attiny25", 2, "__AVR_ATtiny25__" },
+ { "attiny45", 2, "__AVR_ATtiny45__" },
+ { "attiny85", 2, "__AVR_ATtiny85__" },
/* Classic, > 8K. */
{ "avr3", 3, NULL },
{ "atmega103", 3, "__AVR_ATmega103__" },
@@ -185,19 +191,40 @@
/* Enhanced, <= 8K. */
{ "avr4", 4, NULL },
{ "atmega8", 4, "__AVR_ATmega8__" },
+ { "atmega48", 4, "__AVR_ATmega48__" },
+ { "atmega88", 4, "__AVR_ATmega88__" },
{ "atmega8515", 4, "__AVR_ATmega8515__" },
{ "atmega8535", 4, "__AVR_ATmega8535__" },
+ { "at90pwm2", 4, "__AVR_AT90PWM2__" },
+ { "at90pwm3", 4, "__AVR_AT90PWM3__" },
/* Enhanced, > 8K. */
{ "avr5", 5, NULL },
{ "atmega16", 5, "__AVR_ATmega16__" },
{ "atmega161", 5, "__AVR_ATmega161__" },
{ "atmega162", 5, "__AVR_ATmega162__" },
{ "atmega163", 5, "__AVR_ATmega163__" },
+ { "atmega164", 5, "__AVR_ATmega164__" },
+ { "atmega165", 5, "__AVR_ATmega165__" },
+ { "atmega168", 5, "__AVR_ATmega168__" },
{ "atmega169", 5, "__AVR_ATmega169__" },
{ "atmega32", 5, "__AVR_ATmega32__" },
{ "atmega323", 5, "__AVR_ATmega323__" },
+ { "atmega324", 5, "__AVR_ATmega324__" },
+ { "atmega325", 5, "__AVR_ATmega325__" },
+ { "atmega3250", 5, "__AVR_ATmega3250__" },
+ { "atmega329", 5, "__AVR_ATmega329__" },
+ { "atmega3290", 5, "__AVR_ATmega3290__" },
+ { "atmega640", 5, "__AVR_ATmega640__" },
{ "atmega64", 5, "__AVR_ATmega64__" },
+ { "atmega644", 5, "__AVR_ATmega644__" },
+ { "atmega645", 5, "__AVR_ATmega645__" },
+ { "atmega6450", 5, "__AVR_ATmega6450__" },
+ { "atmega649", 5, "__AVR_ATmega649__" },
+ { "atmega6490", 5, "__AVR_ATmega6490__" },
{ "atmega128", 5, "__AVR_ATmega128__" },
+ { "atmega1280",5, "__AVR_ATmega1280__" },
+ { "atmega1281",5, "__AVR_ATmega1281__" },
+ { "at90can128", 5, "__AVR_AT90CAN128__" },

--
cheers, J"org .-.-. --... ...-- -.. . DL8DTLhttp://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.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#5 Nov. 4, 2005 22:32:36

Colin O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


Hello,


> Seems your compiler is incorrectly patched. When I call avr-gcc with
> -v, it gives me:

I used the patch athttps://savannah.nongnu.org/patch/?func=detailitem&item_id=2923for 3.4.4. As
well I can call it like:

~]$ avr-gcc -v -mmcu=atmega168
-Wl,--section-start=.text=0x4000 -o foo foo.c

Reading specs from /opt/avr/lib/gcc/avr/3.4.4/specs
Configured with: ../configure --prefix=/opt/avr --target=avr
--enable-languages=c,c++ --disable-nls : (reconfigured) ../configure
--prefix=/opt/avr --target=avr --enable-languages=c --disable-nls
Thread model: single
gcc version 3.4.4
/opt/avr/libexec/gcc/avr/3.4.4/cc1 -quiet -v foo.c -quiet -dumpbase foo.c
-mmcu=atmega168 -auxbase foo -version -o /tmp/ccNSNRkd.s
ignoring nonexistent directory
"/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/opt/avr/lib/gcc/avr/3.4.4/include
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/include
End of search list.
GNU C version 3.4.4 (avr)
compiled by GNU C version 3.4.4 20050721 (Red Hat 3.4.4-2).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129224
foo.c:3:26: warning: no newline at end of file
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/as -mmcu=atmega168
-o /tmp/ccGpfgqi.o /tmp/ccNSNRkd.s
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld -m avr5 -Tdata 0x800100 -o
foo /opt/avr/lib/gcc/avr/3.4.4/../../../../avr/lib/crtm168.o
-L/opt/avr/lib/gcc/avr/3.4.4 -L/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/lib
--section-start=.text=0x4000 /tmp/ccGpfgqi.o -lgcc -lc -lgcc


Where foo.c is just a basic C program that does nothing. So it doesn't seem to
complain?

Binutils is 2.16, unpatched. Does that need a patch as well, it looked to me
like support got integrated into 2.16. When run from my makefile I see the
following:

Linking: tinyloader.elf
avr-gcc tinyloader.o --output tinyloader.elf -Wl,--section-start=.text=0x3E00
-Wl,-Map=tinyloader.map,--cref -nostartfiles -v
Reading specs from /opt/avr/lib/gcc/avr/3.4.4/specs
Configured with: ../configure --prefix=/opt/avr --target=avr
--enable-languages=c,c++ --disable-nls : (reconfigured) ../configure
--prefix=/opt/avr --target=avr --enable-languages=c --disable-nls
Thread model: single
gcc version 3.4.4
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld -m avr2 -o tinyloader.elf
-L/opt/avr/lib/gcc/avr/3.4.4 -L/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/lib
tinyloader.o --section-start=.text=0x3E00 -Map=tinyloader.map --cref -lgcc
-lc -lgcc
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld: address 0x3f9e of
tinyloader.elf section .text is not within region text
make: *** Error 1

The key line being:
/opt/avr/lib/gcc/avr/3.4.4/../../../../avr/bin/ld -m avr2 -o tinyloader.elf
Which has avr2, whereas before it was avr5. When does this get set?

Regards,

-Colin

Regards,

-Colin


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

Offline

#6 Nov. 5, 2005 07:17:26

Joerg W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


"Colin O'Flynn" <> wrote:

> Linking: tinyloader.elf
> avr-gcc tinyloader.o --output tinyloader.elf
> -Wl,--section-start=.text=0x3E00
> -Wl,-Map=tinyloader.map,--cref -nostartfiles -v

Ah, now I see it. You forgot to add the -mmcu option into that
command.

--
cheers, J"org .-.-. --... ...-- -.. . DL8DTLhttp://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.orghttp://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Offline

#7 Nov. 5, 2005 12:51:09

Colin O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[avr-gcc-list] mega168 Support


Hey,

> Ah, now I see it. You forgot to add the -mmcu option into that
> command.

Ah.. I must have missed that obviously, not sure how I dropped it from my
Makefile as it's the standard one.

Thanks for pointing that out though, all works now!

Regards,

-Colin


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

Offline

Board footer

Moderator control

Enjoy the 20th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support