ATtiny817 support on Linux?

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

Hi all,

Is there an AVR toolchain for Linux that supports the ATtiny817? If I compile this minimal example:

// test.c
#include <avr/io.h>

int main(void)
{
    return 0;
}

using the AVR toolchain from Ubuntu20, the result is:

$ /usr/bin/avr-gcc -mmcu=attiny817 -c test.c
In file included from test.c:1:0:
/usr/lib/avr/include/avr/io.h:623:6: warning: #warning "device type not defined" [-Wcpp]
 #    warning "device type not defined"

The latest Linux toolchain Microchip's website, avr8-gnu-toolchain-3.6.2.1778-linux.any.x86_64, gives the same result.

 

Based on the help text, it looks like ATtiny817 support should be available:

$ avr-gcc --target-help
# ...
Known MCU names:
# ...
attiny817

However, a search for __AVR_ATtiny817__ over the toolchain's header files comes up empty. Maybe the tiny817 isn't supported after all?

 

The toolchain specifics are below.

  • Ubuntu20's latest, apt package gcc-avr, version 1:5.4.0+Atmel3.6.1-2build1:
$ /usr/bin/avr-gcc --version
avr-gcc (GCC) 5.4.0
  • Microchip latest, avr8-gnu-toolchain-3.6.2.1778-linux.any.x86_64:
$ avr8-gnu-toolchain-linux_x86_64/bin/avr-gcc --version
avr-gcc (AVR_8_bit_GNU_Toolchain_3.6.2_1778) 5.4.0

 

Context: I bought an Atmel Xplained Mini some ages ago and decided to finally give it a go.

 

Any pointers on what I'm missing or what else I can try?

Thanks for your help!

-Kevin

This topic has a solution.
Last Edited: Sun. Jan 3, 2021 - 10:17 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

See https://www.avrfreaks.net/forum/device-family-packs-are-annoying for how to inject a device from a DFP (or try MPLAB and see how it does it..)

:: Morten

 

(yes, I work for Microchip, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

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

Say, I have my own avr-gcc (v 8.3.0, see here) installed w/ packs for ATtiny_DFP.2.0.10 (all in Ubuntu20.10 fwiw).  I tried "avr-gcc -mmcu=attiny817 -B/...tiny-2.0.10 main.c" and get "cannot find -lattiny817".  Apparently it's not looking in the "short-calls" lib subdirectories.   I wonder how that is not working.

 

$ avr-gcc main.c -v -mmcu=attiny817 -B/opt/local/avr/packs/tiny
Using built-in specs.
Reading specs from /opt/local/avr/packs/tiny/device-specs/specs-attiny817
rename spec link to prev_link
rename spec link to old_link
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/avr/8.3.0/lto-wrapper
Target: avr
Configured with: ../gcc-8.3.0/configure --prefix=/opt/local --program-prefix=avr- --enable-languages=c,c++ --target=avr
Thread model: single
gcc version 8.3.0 (GCC) 
COLLECT_GCC_OPTIONS='-v'  '-B' '/opt/local/avr/packs/tiny' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /opt/local/libexec/gcc/avr/8.3.0/cc1 -quiet -v -imultilib avrxmega3/short-calls -isystem /opt/local/avr/packs/tiny/include -D__AVR_ATtiny817__ -D__AVR_DEVICE_NAME__=attiny817 -D__AVR_DEV_LIB_NAME__=tn817 main.c -mn-flash=1 -mno-skip-bug -quiet -dumpbase main.c -mmcu=avrxmega3 -mshort-calls -auxbase main -version -o /tmp/ccI4cdBv.s
GNU C17 (GCC) version 8.3.0 (avr)
	compiled by GNU C version 7.4.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
 /opt/local/avr/packs/tiny/include
 /opt/local/lib/gcc/avr/8.3.0/include
 /opt/local/lib/gcc/avr/8.3.0/include-fixed
 /opt/local/lib/gcc/avr/8.3.0/../../../../avr/sys-include
 /opt/local/lib/gcc/avr/8.3.0/../../../../avr/include
End of search list.
GNU C17 (GCC) version 8.3.0 (avr)
	compiled by GNU C version 7.4.0, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: e754341fb6d4a88f2a771fea0aa442b1
COLLECT_GCC_OPTIONS='-v'  '-B' '/opt/local/avr/packs/tiny' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/as -mmcu=avrxmega3 -mgcc-isr -mno-skip-bug -o /tmp/ccuytGSr.o /tmp/ccI4cdBv.s
COMPILER_PATH=/opt/local/avr/packs/tiny/:/opt/local/libexec/gcc/avr/8.3.0/:/opt/local/libexec/gcc/avr/8.3.0/:/opt/local/libexec/gcc/avr/:/opt/local/lib/gcc/avr/8.3.0/:/opt/local/lib/gcc/avr/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/
LIBRARY_PATH=/opt/local/lib/gcc/avr/8.3.0/avrxmega3/short-calls/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/avrxmega3/short-calls/:/opt/local/avr/packs/tiny/:/opt/local/lib/gcc/avr/8.3.0/:/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/
COLLECT_GCC_OPTIONS='-v'  '-B' '/opt/local/avr/packs/tiny' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /opt/local/libexec/gcc/avr/8.3.0/collect2 -plugin /opt/local/libexec/gcc/avr/8.3.0/liblto_plugin.so -plugin-opt=/opt/local/libexec/gcc/avr/8.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccsVMwWu.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lattiny817 -mavrxmega3 -Tdata 0x803E00 --pmem-wrap-around=8k -L/opt/local/avr/packs/tiny-2.0.10/lib/avrxmega3 -L/opt/local/avr/packs/tiny-2.0.10/lib --defsym=__RODATA_PM_OFFSET__=0x8000 /opt/local/avr/packs/tiny-2.0.10/lib/avrxmega3/crtattiny817.o -L/opt/local/lib/gcc/avr/8.3.0/avrxmega3/short-calls -L/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib/avrxmega3/short-calls -L/opt/local/avr/packs/tiny -L/opt/local/lib/gcc/avr/8.3.0 -L/opt/local/lib/gcc/avr/8.3.0/../../../../avr/lib /tmp/ccuytGSr.o --start-group -lgcc -lm -lc -lattiny817 --end-group
/opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/ld: cannot find /opt/local/avr/packs/tiny-2.0.10/lib/avrxmega3/crtattiny817.o: No such file or directory
/opt/local/lib/gcc/avr/8.3.0/../../../../avr/bin/ld: cannot find -lattiny817
collect2: error: ld returned 1 exit status

 

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

Awesome, thanks! That link gave enough information; compilation was successful.

 

Specifically, the solution was:

 

The specific compilation command was:

avr-gcc -mmcu=attiny817 -B /path/to/dfp/gcc/dev/attiny817 -I /path/to/dfp/include/ test.c

Alternatively, -B seems to automatically search for an include/ directory:

avr-gcc -mmcu=attiny817 -B /path/to/dfp/gcc/dev/attiny817 -B /path/to/dfp/ test.c

This solved both compilation and linking.

 

Thanks again!

 

-Kevin

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

Kevin,

Could you post the output of the same avr-gcc command but adding "-v"?

Thanks,

Matt

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

In this case, the "/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229" directory is simply the uncompressed pack file from Microchip...

 

 avr-gcc -mmcu=attiny817 test.c -B /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817 -I /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/ -v
Using built-in specs.
Reading specs from /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/device-specs/specs-attiny817
rename spec link to old_link
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/lto-wrapper
Target: avr
Configured with: /Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/src/gcc/configure LDFLAGS=-L/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64-hostlibs/lib CPPFLAGS= --target=avr --host=x86_64-apple-darwin14.0.0 --build=x86_64-apple-darwin14.0.0 --prefix=/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64 --libdir=/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64/lib --enable-languages=c,c++ --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-avrlibc=yes --with-mpfr=/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64-hostlibs --with-gmp=/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64-hostlibs --with-mpc=/Volumes/build_disk/jenkins_mcu/workspace/avr8-gnu-toolchain-osx/avr8-gnu-toolchain-darwin_x86_64-hostlibs --with-pkgversion=AVR_8_bit_GNU_Toolchain_3.6.1_495 --with-bugurl=http://www.atmel.com
Thread model: single
gcc version 5.4.0 (AVR_8_bit_GNU_Toolchain_3.6.1_495)
COLLECT_GCC_OPTIONS= '-B' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817' '-I' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/' '-v' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/cc1 -quiet -v -I /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/ -imultilib avrxmega3/short-calls -iprefix /usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/ -D__AVR_ATtiny817__ -D__AVR_DEVICE_NAME__=attiny817 -D__AVR_DEV_LIB_NAME__=tn817 test.c -mn-flash=1 -mno-skip-bug -quiet -dumpbase test.c -mmcu=avrxmega3 -mshort-calls -auxbase test -version -o /var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T//ccI4QHIY.s
GNU C11 (AVR_8_bit_GNU_Toolchain_3.6.1_495) version 5.4.0 (avr)
        compiled by GNU C version 5.4.0, GMP version 5.0.2, MPFR version 3.0.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/sys-include"
ignoring duplicate directory "/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/../../lib/gcc/avr/5.4.0/include"
ignoring duplicate directory "/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/../../lib/gcc/avr/5.4.0/include-fixed"
ignoring nonexistent directory "/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/../../lib/gcc/avr/5.4.0/../../../../avr/sys-include"
ignoring duplicate directory "/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/../../lib/gcc/avr/5.4.0/../../../../avr/include"
#include "..." search starts here:
#include <...> search starts here:
 /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/
 /usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/include
 /usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/include-fixed
 /usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/include
End of search list.
GNU C11 (AVR_8_bit_GNU_Toolchain_3.6.1_495) version 5.4.0 (avr)
        compiled by GNU C version 5.4.0, GMP version 5.0.2, MPFR version 3.0.0, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 71f5c77e4280b70690b27560b586a3d1
COLLECT_GCC_OPTIONS= '-B' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817' '-I' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/' '-v' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/as -mmcu=avrxmega3 -mno-skip-bug -o /var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T//cc8IuSQk.o /var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T//ccI4QHIY.s
COMPILER_PATH=/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/:/usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/:/usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/
LIBRARY_PATH=/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/avrxmega3/short-calls/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avrxmega3/short-calls/:/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/:/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/
COLLECT_GCC_OPTIONS= '-B' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817' '-I' '/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/include/' '-v' '-specs=device-specs/specs-attiny817' '-mmcu=avrxmega3' '-mshort-calls'
 /usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/collect2 -plugin /usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/liblto_plugin.so -plugin-opt=/usr/local/avr8-atmel-3.6.1.495/bin/../libexec/gcc/avr/5.4.0/lto-wrapper -plugin-opt=-fresolution=/var/folders/gv/zn3wcml52jq0vvjnd95j8g6h0000gp/T//cc94uP0e.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lattiny817 -mavrxmega3 -Tdata 0x803E00 --pmem-wrap-around=8k --defsym=__RODATA_PM_OFFSET__=0x8000 /Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/avrxmega3/short-calls/crtattiny817.o -L/Volumes/MacOS/HD-Downloads/Downloads/Atmel.ATtiny_DFP.1.3.229/gcc/dev/attiny817/avrxmega3/short-calls -L/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/avrxmega3/short-calls -L/usr/local/avr8-atmel-3.6.1.495/bin/../lib/gcc/avr/5.4.0/../../../../avr/lib/avrxmeg

 

 

Atmel Studio produces:

 

        "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"  -x c -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.5.315\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=attiny817 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATtiny_DFP\1.5.315\gcc\dev\attiny817" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.c"

 

So I think perhaps the -B path you specified wasn't specific enough (though I'm puzzled that it worked as far as it did...)

 

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

You need the "packs" for linux tool chain. Look at my vusb tinyavr1 port on github for bash compile scripts for that toolchain. My compile scripts show how to use the Packs, it's not really documented in the Linux tool chain.
https://www.avrfreaks.net/forum/v-usb-tinyavr0-tinyavr1-series

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

Matt,

The output for my avr-gcc command is similar to what westfw provided. I'll omit it for now to avoid cluttering the thread, but let me know if you still think it's useful.

As suggested, checking the -B path is probably the place to start.

For reference, on my system the DFP the folder contains this after extracting (among other things):

include
├── avr
│   ├── iotn817.h

gcc/dev/attiny817
├── avrxmega3
│   └── short-calls
│       ├── crtattiny817.o
│       └── libattiny817.a

Those are the directories that I used for the -I and -B options.

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

You can also simply download Arduino, extract the hardware/tools/avr folder which will be avr-gcc-7.3.0. Everything is already in there for the avr0/1.

 

cd somewhere

wget https://downloads.arduino.cc/ard...
tar --strip-components=3 -xf arduino-1.8.13-linux64.tar.xz arduino-1.8.13/hardware/tools/avr/
mv avr avr-gcc-7.3.0
PATH=$PATH:$(pwd)/avr-gcc-7.3.0/bin
printf "#include <avr/io.h>\nint main(){ USART0.TXDATAL = 1; }\n" > test.c
avr-gcc -Os -mmcu=attiny817 test.c -o test.elf
avr-objdump -d test.elf

Last Edited: Mon. Jan 4, 2021 - 07:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have automated the setup of the AVR toolchain on Linux,

 

https://github.com/MarkR42/robot...

 

The build.sh contains some comments about what to do. It downloads the correct versions of libc binutils and gcc, patches with a patch, builds and installs. It does seem to support 817 but I've not tried that chip.

 

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

, patches with a patch,

A setup script that automatically installs from a set of .ATPACK files would probably be better than 16M of manual patches...

 

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

Yes but it wasn't my patch, it was published here

 

https://savannah.nongnu.org/patc...

 

I think it's based on the same internal (to Microchip) sources that their official toolchain is built from.

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

PS: your script works nicely, even on my Mac. (and so far, even for gcc 10.2)

 

I changed the existence checks to allow for adding multiple versions, or compiling a new avr-gcc even if you have the standard atmel version already installed:

 

if $PREFIX/bin/avr-ar -V; then
    echo "Avr binutils already working ok"
else
    set -e # error on
    echo "Building and installing avr-binutils"