Linking Architecture Mismatch with atmega128

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

On a certain project I'm working on using the atmega128, I'm updating the toolchain to newer avr-gcc and avr-libc versions. I'm experiencing a weird error in linking and was hoping you guys might be able to help:

I compile my code targeting the atmega128:

avr-gcc -O1 -g -mmcu=atmega128 -save-temps -c -v   -D__AVR_LIBC_DEPRECATED_ENABLE__   -c -o SOME_SOURCE.o SOME_SOURCE.c

I use avr-objcopy to create an object file from a wav file as follows:

avr-objcopy --rename-section .data=.progmem.data,contents,alloc,load,readonly,data  -I binary -O elf32-avr SOME_AUDIO.wav SOME_AUDIO.o

However, linking dies with the following error:

/usr/local/lib/gcc/avr/4.9.1/../../../../avr/bin/ld -plugin /usr/local/libexec/gcc/avr/4.9.1/liblto_plugin.so -plugin-opt=/usr/local/libexec/gcc/avr/4.9.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cc6643tx.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lc -m avr51 -Tdata 0x800100 -o a.out /usr/local/lib/gcc/avr/4.9.1/../../../../avr/lib/avr51/crtm128.o -L/usr/local/lib/gcc/avr/4.9.1/avr51 -L/usr/local/lib/gcc/avr/4.9.1/../../../../avr/lib/avr51 -L/usr/local/lib/gcc/avr/4.9.1 -L/usr/local/lib/gcc/avr/4.9.1/../../../../avr/lib -Map=the.map --cref -v SOME_SOURCE.o SOME_AUDIO.o -lm --start-group -lgcc -lm -lc --end-group
GNU ld (GNU Binutils) 2.24
/usr/local/lib/gcc/avr/4.9.1/../../../../avr/bin/ld: avr architecture of input file `SOME_AUDIO.o' is incompatible with avr:51 output

The following is the output of avr-objdump on the object files in question:

SOME_AUDIO.o:     file format elf32-avr
architecture: avr:51, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000


SOME_SOURCE.o:     file format elf32-avr
architecture: avr, flags 0x00000010:
HAS_SYMS
start address 0x00000000

The funny thing is, this worked without a problem on my old toolchain, the only difference being that the architecture of the compiled object files was avr:5.

Any ideas?
Thanks for reading & any help is much appreciated!

Tony

-------------------------------

The current versions I'm using are:
- avr-gcc 4.9.1
- avr-libc 1.8.1
- binutils 2.24

The old versions I'm migrating from are:
- avr-gcc 4.2.2
- avr-libc 1.6.2
- binutils 2.18

This topic has a solution.
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Curious. I just tried the same test here on a .bin file (didn't have a .wav to hand) and I get:

$ avr-objdump -f test.o

test.o:     file format elf32-avr
architecture: avr, flags 0x00000010:
HAS_SYMS
start address 0x00000000

so it seems to have defaulted to "avr" architecture anyway.

Anyway if it is the wrong architecture the magic you want is -B. Use something like "-B avr3" or "-B avr" or whatever to control the architecture setting.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Awesome, worked perfectly - thanks @clawson !