Howto Build a GCC Toolchain for Atmel AVR Controllers

I succeded to build a working gcc toolchain for Atmel's AVR microcontrollers on an OpenSuSE 11.4 by following the recipe at www.nongnu.org/avr-libc/user-manual/install_tools.html.

At time of this writing (2012-07-25) binutils and gcc I used were not the most recent ones (binutils-2.22, gcc-4.7.1) as I came into troubles with those (possibly only caused by my lack of experience and dumb faults).

As a test for the functioning of the toolchain I built ethersex.

Define a prefix for the configure processes and include the avr binary location into the execution path

export PREFIX=/usr/local/avr
export PATH=$PREFIX/bin:$PATH
    

Create the directory $PREFIX if not already existing.

To build the gcc compiler you need to have installed the devel packages of
gmp (The GNU Multiple Precision Arithmetic Library),
mpfr (MPFR multiple-precision floating-point computation shared library) and
mpc (MPC multiple-precision complex library).
My gcc used for the build was version 4.5.1.

GNU Binutils

Download the sources from http://ftp.gnu.org/gnu/binutils.
I used version 2.21.1a

tar xvjf binutils-2.21.1a.tar.bz2
cd binutils-2.21.1
mkdir build-avr
cd build-avr
../configure --prefix=$PREFIX --target=avr --disable-nls
make
sudo make install
    

GCC

Download the sources from from a reasonable mirror of http://gcc.gnu.org/ like ftp://ftp.gwdg.de/pub/misc/gcc.
I downloaded gcc-core 4.6.3
and gcc-g++ 4.6.3

tar xvjf gcc-core-4.6.3.tar.bz2
tar xvjf gcc-g++-4.6.3.tar.bz2
cd gcc-4.6.3
mkdir build-avr
cd build-avr
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
make
sudo make install
    

AVR libc

Download the sources from http://savannah.nongnu.org/projects/avr-libc/.
I used version 1.8.0

tar xvjf avr-libc-1.8.0.tar.bz2 
cd avr-libc-1.8.0
./configure --prefix=$PREFIX --build=`./config.guess` --host=avr
make
sudo -E make install
    

AVR Downloader/UploaDEr (avrdude)

Download the sources from http://savannah.nongnu.org/projects/avrdude/.
I used version 5.11.1

tar xvzf avrdude-5.11.1.tar.gz
cd avrdude-5.11.1
mkdir build
cd build
../configure --prefix=$PREFIX
make
sudo make install
    

Permanently add $PREFIX/bin to the shell's execution path

Add e.g. to ~/.bashrc:

export PATH=/usr/local/avr/bin:$PATH

Useful References

line
last updated: 2012-07-25
line
This site maintained by:
lukas.zimmermann@unibas.ch
My public PGP key
HOME Valid CSS! Valid XHTML 1.0 Strict