我试图在this Code/Guide上使用ATmega1284p。
我遇到的问题是链接器无法工作,执行后会收到以下错误消息(代码为ATmega88构建得很好):
avr-ld -o main.elf main.o -g
avr-ld: avr:51 architecture of input file `main.o' is incompatible with avr outputFor 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完整构建说明
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.elfavr-objdump输出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发布于 2018-07-25 16:52:44
有一个解决办法可以强制avr-ld使用链接脚本。
解决办法
如果avr给出了错误:
avr-ld: avr:51 architecture of input file 'main.o' is incompatible with avr output
您必须使用选项-m添加所需的体系结构,例如:
avr-ld -o main.elf main.o -g -mavr51如果这不起作用,您将得到以下错误:
avr-ld: cannot open linker script file ldscripts/avr51.xn: No such file or directory必须强制使用正确的链接脚本和-T选项:
avr-ld -o main.elf main.o -g -mavr51 -T /usr/lib/avr/ldscripts/avr51.xn链接器应该能工作。
https://stackoverflow.com/questions/51505057
复制相似问题