simavr icon indicating copy to clipboard operation
simavr copied to clipboard

ATMega328PB support fails to compile

Open maxgerhardt opened this issue 3 years ago • 0 comments

When building simavr, at the start it informs about not being able to give ATMega328PB support.

cc -E -Werror -O2 -Wall -Wextra -Wno-unused-parameter -Wno-unused-result -Wno-missing-field-initializers -Wno-sign-compare -g -I/include -DNO_COLOR --std=gnu99 -Wall -I/include -Isim -I. -I../../shared -I../simavr/cores cores/sim_mega328pb.c
WARNING cores/sim_mega328pb.c did not compile, check your avr-gcc toolchain

Inspecting the invocation and compiler output closer, it's missing the I/O header file.

# 35 "cores/sim_megacores/sim_mega328pb.c:45:10: fatal error: avr/iom328pb.h: No such file or directory
   45 | #include "avr/iom328pb.h"
      |          ^~~~~~~~~~~~~~~~

which seems to be supplied by Atmel in their device header pack. Even in recent AVR-GCC versions, this file is missing (https://stuvel.eu/post/2021-04-27-atmega328pb-on-gcc/), but can be added.

When I follow above instructions to download the device pack and copy the appropriate files into my AVR-GCC toolchain as well as in the SimAVR directory

cp /c/Users/Max/Downloads/Atmel.ATmega_DFP.1.6.364/gcc/dev/atmega328pb/avr5/* /mingw64/avr/lib/avr5
cp /c/Users/Max/Downloads/Atmel.ATmega_DFP.1.6.364/include/avr/iom328pb.h /mingw64/avr/include/avr/
cp /mingw64/avr/include/avr/iom328pb.h cores/avr/.

After make clean and make build-simavr, that now gives simavr ATMega328PB support.

$ ./simavr/run_avr --list-cores
Supported AVR cores:
[...]
       atmega324a atmega324pa
       atmega328 atmega328p
       atmega328pb
[...]

The issue would be fixed by PR #353.

maxgerhardt avatar Jul 21 '21 09:07 maxgerhardt