uracoli logo Home - Downloads - Docs - Hardware - Source - News - Blog tiny230 photo


To compile the examples and application the following tools are required:

  • avr-gcc
    AVR GCC C-compiler which we need to compile the libraries and the test examples

  • avr-libc
    Standard C library which provides a good set of C standard functions

  • avr-binutils
    Linker, Object File Converter, ..

  • avrdude
    Tool to Transfer the machine code (.hex files) via ISP or JTAG AVR interface to the internal Flash memory

To be able to do debugging in addition the following packages should be installed as well:

  • avr-gdb
    GNU debugger to debug AVR programs

    This tool interfaces the AVR GNU debugger with the AVR JTAG interface which allows real in-circuit debugging


AVR libc version 1.7.0 is broken. Use the delay.h file mentioned above until 1.7.1 comes out

If you use an AVR Dragon programmer you may first upgrade its firmware using AVR Studio. Otherwise some of the AVR devices exceeding 32 kByte Flash may not be supported by the Dragon board.


AVR Studio and WinAVR

If you are developing on the Windows platform the easiest way to start is to download the ATMEL Studio. This is a complete IDE with compiler and integrated debugger. It supports all the standard programming Hardware.

Atmel also offers also a standalone version of the toolchain without the GUI at http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORWINDOWS.aspx Note that this package includes no programming tool like avrdude. A precompiled version of avrdude can be obtained from http://tomeko.net.


There are seperate options to install an AVR tool chain for Linux. To get started, the official AVR Linux Packages should be good enough. If you have the need to compile code for very new MCU devices then either the wrightflyer packages, the Bingo Scripts or the Atmel toolchain are available

The Latest Atmel Toolchain


The Official AVR Linux Packages (Ubuntu)

If you are using one of the latest versions of Ubuntu (10.04 and 10.10) it is quite easy to install the AVR build toolchain:

sudo apt-get install avr-libc binutils-avr gcc-avr avrdude avarice gdb-avr

The "wrightflyer" Packages

If you have a Debian based distribution or you would like to install a newer toolchain you could check http://www.wrightflyer.co.uk/avr-gcc for available packages.

Please note that the revision avr-gcc-4.3.4-avrfreaks-30-jun-2010-u10.04 requires to additionally use a corrected delay.h file (link:http://www.wrightflyer.co.uk/avr-gcc/avr-libc-1.7.0-delay.h).

The following steps are required to install the package. The installation requires admministrator privileges, either use the sudo command or login as user root:

Latest Version

# for 32 bit Linux
wget ${baseurl}/${package}-u10.04.i386.deb
sudo dpkg -i ${package}-u10.04.i386.deb

# or for 64 bit Linux
wget ${baseurl}/${package}-u10.04.x64.deb
sudo dpkg -i ${package}-u10.04.x64.deb
Version 30-jun-2010 needs patching of delay.h
wget ${baseurl}/avr-gcc-4.3.4-avrfreaks-30-jun-2010-u10.04.i386.deb
wget ${baseurl}/avr-libc-1.7.0-delay.h
sudo dpkg -i avr-gcc-4.3.4-avrfreaks-30-jun-2010-u10.04.i386.deb
sudo cp --backup avr-libc-1.7.0-delay.h /usr/local/avr/avr/include/util/delay.h

Now add the directory /usr/local/avr/bin to the PATH of your shell. This can be done with the following lines to your $HOME/.bashrc:

if [[ -d /usr/local/avr/bin ]] ;
   export PATH="/usr/local/avr/bin:$PATH"

Bingo Scripts - Self compiling the Tool Chain

This script is absolutely needed if you need for some reason the tools with the latest patches.

There is a script from user Bingo600 in the AVR-GCC forum at http://www.avrfreaks.net that compiles a AVR toolchain from scratch.

unzip build-avr-gcc-4.3.4-binutils-2.20-libc-1.6.8-insight6.8-1-dude-5.10-insight-patch.zip
cd build-avr-gcc-4.3.4-binutils-2.20-libc-1.6.8-insight6.8-1-dude-5.10-insight-patch/make-avr-gcc/

Otherwise then stated in the article,it is not necessarry to be "root" for building the scripts, it is sufficient if you have write permissions in the install directory.

If you want to change the install prefix from /usr/local/avr to another path, change the prefix variable in the scripts buildinsight.sh and buildavr-no-insight.sh

Before you now start with executing the scripts, some words of caution are needed.


Don’t try to call the scripts from another directory location, always execute from same directory where the scripts are located.

It is recommended to run the scripts explicitely with bash before the script name. In Ubuntu the default shell is dash, which causes none or malfunction when running the scripts.

With keeping this in mind you can start with building the toolchain following the instruction in the article.

Self Compiling AVRDUDE on Debian/Raspbian

$ sudo apt-get install build-essential flex  bison gcc libusb-dev
$ sudo apt-get install libftdi-dev libhidapi-dev libpthread-stubs0-dev libelf-dev
$ wget http://download.savannah.gnu.org/releases/avrdude/avrdude-6.3.tar.gz
$ tar xvzf avrdude-6.3.tar.gz
$ cd avrdude-6.3/
$ ./configure --enable-linuxgpio

DO HAVE    libelf
DO HAVE    libusb
DON'T HAVE libusb_1_0
DON'T HAVE libftdi1
DO HAVE    libftdi
DON'T HAVE libhid
DO HAVE    pthread
DISABLED   parport
ENABLED    linuxgpio

$ make
$ sudo make install

In order to use the self compiled avrdude, add /usr/local/bin in your $PATH variable, before /usr/bin (where the version from apt-get install avrdude resides).

(Todo: check what is needed for libhid? why libusb_1/libusb and libftdi/libftd1?).

Atmel AVR Toolchain

A eqivalent Linux version of the Windows AVR studio toolchain can be found here: http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORLINUX.aspx. This package does also not contain avrdude, so that it needs to be installed or self compiled seperately.

Using avrdude with USB devices

In order to access the programming devices Atmel AVRISP MkII, JTAG-ICE MkII and AVR Dragon as user and not as root, the following steps have to be done:


Create a file /etc/udev/rules.d/42-atmel_usb.rules and add the following lines:

# File /etc/udev/rules.d/42-atmel_usb.rules before Ubuntu 12.04
# Atmel AVR ISP mkII
SUBSYSTEM=="usb", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2104", GROUP="plugdev", MODE="0660"
SUBSYSTEM=="usb", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2103", GROUP="plugdev", MODE="0660"
SUBSYSTEM=="usb", SYSFS{idVendor}=="03eb", SYSFS{idProduct}=="2107", GROUP="plugdev", MODE="0660"

With Ubuntu 12.04 you will find the following lines in /var/log/syslog

Mar  8 17:30:50 smarti udevd[662]: unknown key 'SYSFS{idVendor}' in /etc/udev/rules.d/42-atmel_usb.rules:2
Mar  8 17:30:50 smarti udevd[662]: invalid rule '/etc/udev/rules.d/42-atmel_usb.rules:2'

Exchange the keyword "SYSFS" with "ATTR" or use this file:

# File /etc/udev/rules.d/42-atmel_usb.rules for Ubuntu 12.04
# Atmel AVR ISP mkII
SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2104", GROUP="plugdev", MODE="0660"
SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2103", GROUP="plugdev", MODE="0660"
SUBSYSTEM=="usb", ATTR{idVendor}=="03eb", ATTR{idProduct}=="2107", GROUP="plugdev", MODE="0660"
  • Check that the number in the filename does not collide with other files.

  • If the group "plugdev" does not exist on your system, use a group name, where normal users have a membership, e.g. dialout.

After creating this file, restart the udev deamon with the command:

sudo /sbin/udevadm control --reload-rules

If the access for normal users does not work, check the group memberships of the user using the id command.


A precompiled version of avrdude can be found at http://tomeko.net. It assumes a specific version of libusb. However, if you want to use avrdude together with Atmel Studio install the package libusb-win32-devel-filter-<version>.exe.


The regular way to debug an AVR application is

avrdude -P usb -c jtag2 -p m128rfa1 -U myprog.hex
avarice -I -P atmega128rfa1 -2j usb --detach :4242
avr-gdb myprog.elf

Recently when running avarice on Ubuntu 10.10 after an update the following error happened:

avarice -I -P atmega128rfa1 -2j usb --detach :4242
avarice: error while loading shared libraries: libbfd-2.20.1-system.20100303.so: \
         cannot open shared object file: No such file or directory

With ldd you will see that the library is missing:

axel@dellbox:~/Work/uracoli-aw/uracoli-appnotes/linuxtag2012/Src/Test$ ldd `which avarice`
        linux-gate.so.1 =>  (0x00193000)
        libusb-0.1.so.4 => /lib/libusb-0.1.so.4 (0x00806000)
        libbfd-2.20.1-system.20100303.so => not found

The fix for this is to make a symlink from your existing libbfd*.so to libbfd-2.20.1-system.20100303.so, e.g.

sudo ln -sfv /usr/lib/libbfd-2.20.51-system.20100908.so  /usr/lib/libbfd-2.20.1-system.20100303.so

more topics

Last modified: 2017-06-04 Visitor Counter