Closed burnpanck closed 3 years ago
In your example you're using avr-gcc 9.2.0.
Have you tried installing avr-gcc 8.x.x to see if it works?
brew install avr-gcc@8
I had not, as support for new devices is usually cumulative; no reason to remove support for recent devices after they have just been added. Also, the presence of the specs file indicates that GCC thinks that the device is supported - the install is just broken in that it does not contain all the necessary files.
Anyway, I have now tried it withavr-gcc@8
and I do get the exact same picture:
~ find /usr/local/Cellar/avr-gcc@8/ -iname "*attiny817*"
/usr/local/Cellar/avr-gcc@8//8.3.0_1/lib/avr-gcc/8/gcc/avr/8.3.0/device-specs/specs-attiny817
versus e.g.
~ find /usr/local/Cellar/avr-gcc@8/ -iname "*atxmega64a3u*"
/usr/local/Cellar/avr-gcc@8//8.3.0_1/avr/lib/avrxmega4/libatxmega64a3u.a
/usr/local/Cellar/avr-gcc@8//8.3.0_1/avr/lib/avrxmega4/crtatxmega64a3u.o
/usr/local/Cellar/avr-gcc@8//8.3.0_1/lib/avr-gcc/8/gcc/avr/8.3.0/device-specs/specs-atxmega64a3u
To be concrete, compilation of a simple empty loop main()
with avr-g++ -mmcu=attiny817 main.cpp -o main.elf
fails as follows:
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find crtattiny817.o: No such file or directory
/usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc/9.2.0_1/lib/avr-gcc/9/gcc/avr/9.2.0/../../../../../../avr/lib/libm.a when searching for -lm
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lm
/usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc/9.2.0_1/lib/avr-gcc/9/gcc/avr/9.2.0/../../../../../../avr/lib/libm.a when searching for -lm
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lm
/usr/local/opt/avr-binutils/bin/avr-ld: skipping incompatible /usr/local/Cellar/avr-gcc/9.2.0_1/lib/avr-gcc/9/gcc/avr/9.2.0/../../../../../../avr/lib/libc.a when searching for -lc
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lc
/usr/local/opt/avr-binutils/bin/avr-ld: cannot find -lattiny817
collect2: error: ld returned 1 exit status
The same file compiles successfully with e.g. -mmcu=atxmega64a3u
.
Compilation against a random unsupported MCU fails differently:
~ avr-g++ -mmcu=atdoesnotexist1 main.cpp -o main.elf
avr-g++: fatal error: cannot read spec file 'device-specs/specs-atdoesnotexist1': No such file or directory
compilation terminated.
It might be the same kind of issue than the ones #105 fixed. I've also found this, maybe it can be helpful:
Could you try the patch and if it works make a PR? The one I referenced is a good example.
Hi
If you need help i can support.
Greetings Chris
Thanks a lot @Feuerwerk! :)
@ladislas: Thanks for identifying the patch! So it really seems like an upstream bug, not a packaging problem. Unfortunately, I'm quite tight on time these days. I probably won't be able to give it a try before April.
I found the same today when I tried to use avr-gcc 5.5. With avr-gcc 8+ it is working.
ze-mac:Downloads ze$ avr-gcc -v
Using built-in specs.
Reading specs from /usr/local/Cellar/avr-gcc@5/5.5.0/lib/avr-gcc/5/gcc/avr/5.5.0/device-specs/specs-avr2
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/local/Cellar/avr-gcc@5/5.5.0/libexec/gcc/avr/5.5.0/lto-wrapper
Target: avr
Configured with: ../configure --target=avr --prefix=/usr/local/Cellar/avr-gcc@5/5.5.0 --libdir=/usr/local/Cellar/avr-gcc@5/5.5.0/lib/avr-gcc/5 --enable-languages=c,c++ --with-ld=/usr/local/opt/avr-binutils/bin/avr-ld --with-as=/usr/local/opt/avr-binutils/bin/avr-as --disable-nls --disable-libssp --disable-shared --disable-threads --disable-libgomp --with-dwarf2
Thread model: single
gcc version 5.5.0 (GCC)
ze-mac:Downloads ze$ avr-gcc -mmcu=attiny202 -B ~/Downloads/Atmel.ATtiny_DFP.1.4.310/gcc/dev/attiny202 -I ~/Downloads/Atmel.ATtiny_DFP.1.4.310/include/ -x c -c -DATtiny202 -funsigned-char -funsigned-bitfields -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -Wall -o main.o main.c
main.c:1:0: error: unknown core architecture 'avrxmega3' specified with '-mmcu='
/*
^
main.c:1:0: note: supported core architectures: avr2 avr25 avr3 avr31 avr35 avr4 avr5 avr51 avr6 avrxmega2 avrxmega4 avrxmega5 avrxmega6 avrxmega7 avrtiny avr1
ze-mac:Downloads ze$
That seems like a different issue to me. The new atxmega3 have really been added to avr-gcc around version 8 as you observed. The issue I encountered was in fact in avr-libc
, where those devices are still not supported, except for a hanging pull-request. So I'm surprised that you say it does work for you with avr-gcc 8. Could you post the command-line you used there? I do note that you add include paths to some Atmel download related to DFPs - could it be possible that the missing crt files are found there? Also, are you using the upstream avr-gcc or the Atmel distribution?
The Atmel toolchain comes with GCC 5.4.0 https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers and I can run the above code. From what I understand you can give the compiler a device_specs with -B.
avr-gcc@8 works if I pass the -B option.
Hey @metropt, thank you for your answer! Could you nonetheless please post the exact full command-line that did work for you?
Note that the -B
flag does not actually set device specs, but rather it prepends a number of directories to the compiler's search paths in the various build passes - including when looking for specs.
I was able to download the device pack from atmel from packs.download.atmel.com. With that, I was able to compile my source with a command-line as follows:
avr-g++ -Batmel-DFP/gcc/dev/attiny817 -Iatmel-DFP/include -Os -save-temps -g -gdwarf-3 -gstrict-dwarf -fno-exceptions -mmcu=attiny817 -std=gnu++17 -o main.cpp.obj -c main.cpp
However, this does only compile (-c
flag), so it will never show the link problems I posted above. If I try
avr-g++ -Batmel-DFP/gcc/dev/attiny817 -Iatmel-DFP/include -Os -save-temps -g -gdwarf-3 -gstrict-dwarf -fno-exceptions -mmcu=attiny817 -std=gnu++17 -o main.elf main.cpp
instead, the missing crtattiny817.o
and libattiny817
are indeed found, but I still get skipping incompatible ...
for -lm
and -lc
.
Indeed, gcc tries to locate libm.a
and libc.a
in the usual way, and only finds those for other architectures (because avrxmega3
is currently missing from avr-libc). Of course, within atmel's gcc 5.4 download, there are also libm.a
and libc.a
for avrxmega3
. Maybe these are the ones your build found? In any case, the approach here is re-using binaries downloaded from unknown origin (atmel) - it might very well not work together with our version of gcc and lead to silently and fatally failing code.
I would avoid at all costs mixing toolchains. Either go all the way with Atmel toolchain or with with this one.
Thank you, with this toolchain I'm able to build the code only with GCC 9+, is that correct?
GCC 10 added some of them:
ATtiny202, ATtiny204, ATtiny402, ATtiny404, ATtiny406, ATtiny804, ATtiny806, ATtiny807, ATtiny1604, ATtiny1606, ATtiny1607, ATmega808, ATmega809, ATmega1608, ATmega1609, ATmega3208, ATmega3209, ATmega4808, ATmega4809
@luqasz: GCC 8 added the 1-series long before:
The AVR port now supports the following XMEGA-like devices: ATtiny212, ATtiny214, ATtiny412, ATtiny414, ATtiny416, ATtiny417, ATtiny814, ATtiny816, ATtiny817, ATtiny1614, ATtiny1616, ATtiny1617, ATtiny3214, ATtiny3216, ATtiny3217 The new devices are listed under -mmcu=avrxmega3.
The problem discussed in this issue is that avr-libc, which is a separate project often bundled with avr-gcc (for example here in this homebrew
package), was last released at version 2.0 four years ago and therefore does not support those new devices.
@ladislas has identified an open patch to libc adding that support, which, after my failed previous attempts to include here, have recently been updated.
Now, the chances might be much better - someone just needs to find the time for it :-).
Any news on this? I'll close the issue for now, feel free to reopen and submit a PR. :)
Since AVR-GCC 8, the new tiny are supported: https://gcc.gnu.org/gcc-8/changes.html If I do a
find /usr/local/Cellar/avr-gcc -iname "*attiny817*"
I do get the following:That specs file refers to a
crtattiny817.o
which seems to be missing. If I instead search e.g. for the "ATxmega64a3u", I getIn fact,
/usr/local/Cellar/avr-gcc/9.2.0_1/avr/lib/avrxmega3
seems to be completely missing.