I tried to use this Code/Guide on an ATmega1284p
.
The problem that I encounter is that the linker does not work, and I get following error message after executing (code builds well for ATmega88
):
avr-ld -o main.elf main.o -g
avr-ld: avr:51 architecture of input file `main.o' is incompatible with avr output
For information
avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/avr/4.8.2/lto-wrapper
Target: avr
Configured with: ../src/configure -v --enable-languages=c,c++ --prefix=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --enable-shared --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-libssp --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=avr
Thread model: single
Complete build instructions
avr-gcc -std=c99 -g -Os -mmcu=atmega1284p -DF_CPU=8000000 -I. -DUART_BAUDRATE=57600 -Wstrict-prototypes -Wextra -ffunction-sections -fdata-sections -Wl,-gc-sections -o main.o -o main.o *.c
avr-ld -o main.elf main.o -g
avr-objcopy -j .text -j .data -O ihex main.o main.hex
avr-size -C --mcu=atmega1284p main.elf
avr-objdump output of main.o
avr-objdump -f main.o
main.o: Dateiformat elf32-avr
Architektur: avr:51, Flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
Startadresse 0x00000000
There is a workaround to force avr-ld
to use an linkerscript.
If avr-ld is giving the error:
avr-ld: avr:51 architecture of input file 'main.o' is incompatible with avr output
You must add the desired architecture with the option -m
, for example:
avr-ld -o main.elf main.o -g -mavr51
If this does not work you get following error:
avr-ld: cannot open linker script file ldscripts/avr51.xn: No such file or directory
You must force using the right linkerscript with the -T
option:
avr-ld -o main.elf main.o -g -mavr51 -T /usr/lib/avr/ldscripts/avr51.xn
And the linker should work.
User contributions licensed under CC BY-SA 3.0