Compiling_AVR-GCC

If you want to use an uptodate AVR-GCC toolchain on linux, e.g. because you need support for new devices, you must compile it yourself.
This page covers the minimal version of the toolchain without many addons.

see also: Compiling_AVR-GCC-cvs

Not all devices, that are supported by avr-libc-1.4.3 are already supported by my patch set.
a list of the patches for new devices that are included you find at the bottom
of this page: Patching_AVR_GCC

Download the source

mkdir /usr/src/avr-toolchain-src
cd /usr/src/avr-toolchain-src
wget http://ftp.gnu.org/gnu/binutils/binutils-2.16.1.tar.bz2 \
     http://ftp.gnu.org/gnu/gcc/gcc-3.4.5/gcc-3.4.5.tar.bz2 \
     http://savannah.nongnu.org/download/avr-libc/avr-libc-1.4.3.tar.bz2 \
     http://www.kieltech.de/~ufechner/patch-2005-05.zip \
     http://www.kieltech.de/~ufechner/avr-mem.sh.gz     

Apply the patches

unzip patch-2005-05.zip
gunzip avr-mem.sh.gz
chmod +x avr-mem.sh
tar --bzip2 -xvf binutils-2.16.1.tar.bz2
tar --bzip2 -xvf gcc-3.4.5.tar.bz2
tar --bzip2 -xvf avr-libc-1.4.3.tar.bz2
patch binutils-2.16.1/gas/config/tc-avr.c patch/binutils-2.16.1-2005-5.diff
patch -d gcc-3.4.5/gcc/config/avr avr.c ../../../../patch/gcc-3.4.4-2005-5.diff

See also: Patching_AVR_GCC

Set up the environment

export MAJVERSION="2006"
export SUBVERSION="1"
export VERSION="$MAJVERSION.$SUBVERSION"
export PREFIX="/usr/local/avr-toolchain-$VERSION"
export PROGPREFIX="avr-"
export TARGET="avr"
export PATH="$PREFIX/bin:$PATH"

Build and install binutils

cd /usr/src/avr-toolchain-src
cd binutils-2.16.1
mkdir obj-avr
cd obj-avr
../configure --target=$TARGET \
             --prefix=$PREFIX \
             --program-prefix=$PROGPREFIX
make
make install

Build and install avr-gcc

cd /usr/src/avr-toolchain-src
cp avr-mem.sh $PREFIX/bin
cd gcc-3.4.5
mkdir obj-avr
cd obj-avr
../configure --target=$TARGET \
             --prefix=$PREFIX \
             --program-prefix=$PROGPREFIX \
             --enable-languages=c \
             --disable-nls
make
make install

If you want support for c++, write: --enable-languages=c, c++

Build and install avr-libc

cd /usr/src/avr-toolchain-src
cd avr-libc-1.4.3
./configure --build=`./config.guess` --host=avr --prefix=$PREFIX
make
make install

optional: The programmer AVRDUDE

cd /usr/src/avr-toolchain-src
wget   http://savannah.nongnu.org/download/avrdude/avrdude-5.1.tar.gz 
tar -zxvf avrdude-5.1.tar.gz  
cd avrdude-5.1
mkdir obj-avr
cd obj-avr
../configure --prefix=$PREFIX
make
make install

optional: The debugger GDB

cd /usr/src/avr-toolchain-src
wget   http://gd.tuwien.ac.at/gnu/gnusrc/gdb/gdb-6.3.tar.gz 
tar -zxvf gdb-6.3.tar.gz
cd gdb-6.3
mkdir obj-avr
cd obj-avr
../configure --prefix=$PREFIX --program-prefix=$PROGPREFIX
make
make install

optional: The JTAG in circuit emulator AVaRICE

cd /usr/src/avr-toolchain-src
wget   http://mesh.dl.sourceforge.net/sourceforge/avarice/avarice-2.3.tar.bz2
bzip2 -d avarice-2.3.tar.bz2
tar xvf avarice-2.3.tar
cd avarice-2.3
mkdir obj-avr
cd obj-avr
../configure --prefix=$PREFIX
make
make install

optional: Insight GDB GUI

cd /usr/src/avr-toolchain-src
wget   ftp://sourceware.org/pub/insight/releases/insight-6.5.tar.bz2
bzip2 -d insight-6.5.tar.bz2
tar xvf insight-6.5.tar
cd insight-6.5
mkdir obj-avr
cd obj-avr
../configure --prefix=$PREFIX
make
make install

Final steps

Add the toolchain directory to your path. You could add the following lines to /etc/profile:

PATH="$PATH:/usr/local/avr-toolchain-2006.1/bin"
export PATH

Check, if your installation was successfull:

avr-gcc --version
avr-ld --version

Display the supported cpus:

avr-gcc -dumpspecs

Links

This page is based on:

Back to AVR-GCC

KielTech: Compiling_AVR-GCC (last edited 2008-06-07 15:13:50 by localhost)