Difference between revisions of "AVR toolchain compilation"

From DiLab
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Note for MacOSX users''': alternative to manual compilation is to use a pre-built [http://www.obdev.at/products/crosspack/index.html CrossPack package] created by [http://www.obdev.at/index.html Objective Development].

This document is an adapted version of [http://www.cs.mun.ca/~paul/cs4723/material/atmel/avr-libc-user-manual-1.6.5/install_tools.html AVR libc tutorial].
This document is an adapted version of [http://www.cs.mun.ca/~paul/cs4723/material/atmel/avr-libc-user-manual-1.6.5/install_tools.html AVR libc tutorial].


Line 10: Line 12:
# will be installed under /usr/local. Change here, if other destination is needed
# will be installed under /usr/local. Change here, if other destination is needed
export PREFIX=/usr/local
export PREFIX=/usr/local

PATH="$PREFIX/bin:$PATH"
PATH="$PREFIX/bin:$PATH"

# Exit on first error
set -e


# GCC and GAS patches
# GCC and GAS patches
Line 21: Line 25:
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
bunzip2 -c gmp-4.3.2.tar.bz2 | tar xf -
bunzip2 -c gmp-4.3.2.tar.bz2 | tar xf -
mkdir gmp-4.3.2/obj
mkdir -p gmp-4.3.2/obj
cd gmp-4.3.2/obj
cd gmp-4.3.2/obj
echo "Building GMP..."
echo "Building GMP..."
Line 33: Line 37:
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
bunzip2 -c mpfr-2.4.2.tar.bz2 | tar xf -
bunzip2 -c mpfr-2.4.2.tar.bz2 | tar xf -
mkdir mpfr-2.4.2/obj
mkdir -p mpfr-2.4.2/obj
cd mpfr-2.4.2/obj
cd mpfr-2.4.2/obj
echo "Building MPFR..."
echo "Building MPFR..."
Line 45: Line 49:
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar -xzf mpc-0.8.1.tar.gz
tar -xzf mpc-0.8.1.tar.gz
mkdir mpc-0.8.1/obj
mkdir -p mpc-0.8.1/obj
cd mpc-0.8.1/obj
cd mpc-0.8.1/obj
echo "Building MPC..."
echo "Building MPC..."
Line 55: Line 59:
# BINUTILS:
# BINUTILS:
echo "Fetching binutils..."
echo "Fetching binutils..."
wget -c http://ftp.gnu.org/gnu/binutils/binutils-2.20.tar.gz
wget -c http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.bz2
tar -xzf binutils-2.20.tar.gz
bunzip2 -c binutils-2.20.1.tar.bz2 | tar xf -
cd binutils-2.20
cd binutils-2.20.1
cp ../gas-patch-newdevices.patch ./
cp ../gas-patch-newdevices.patch ./
echo "Building binutils..."
echo "Building binutils..."
patch -p0 < gas-patch-newdevices.patch
patch -p0 < gas-patch-newdevices.patch
mkdir obj-avr
mkdir -p obj-avr
cd obj-avr
cd obj-avr
../configure --prefix=$PREFIX --target=avr --disable-nls --disable-werror
../configure --prefix=$PREFIX --target=avr --disable-nls --disable-werror
Line 71: Line 75:
echo "Fetching GCC…"
echo "Fetching GCC…"
wget -c http://ftp.gnu.org/gnu/gcc/gcc-4.5.0/gcc-4.5.0.tar.gz
wget -c http://ftp.gnu.org/gnu/gcc/gcc-4.5.0/gcc-4.5.0.tar.gz
tar -xzf gcc-core-4.5.0.tar.gz
tar -xzf gcc-4.5.0.tar.gz
cd gcc-4.5.0
cd gcc-4.5.0
cp ../gcc-new-device-support.patch ./
cp ../gcc-new-device-support.patch ./
echo "Building GCC..."
echo "Building GCC..."
patch -p0 < gcc-new-device-support.patch
patch -p0 < gcc-new-device-support.patch
mkdir obj-avr
mkdir -p obj-avr
cd obj-avr
cd obj-avr
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
Line 87: Line 91:
tar xjf avr-libc-$LIBCVERS.tar.bz2
tar xjf avr-libc-$LIBCVERS.tar.bz2
cd avr-libc-$LIBCVERS
cd avr-libc-$LIBCVERS
mkdir obj
mkdir -p obj
cd obj
cd obj
../configure --prefix=$PREFIX --build=`../config.guess` --host=avr
../configure --prefix=$PREFIX --build=`../config.guess` --host=avr

Latest revision as of 17:37, 26 October 2011

Note for MacOSX users: alternative to manual compilation is to use a pre-built CrossPack package created by Objective Development.

This document is an adapted version of AVR libc tutorial.

Create a new directory, where the toolchain source files will be stored temporarily.

Run the following script! You will be asked for a password, as sudo command is used. User account with administrator (sudo) rights is required. wget tool is required to fetch source files from GNU sites. You can compile wget from sources on both: Linux and MacOS platforms.

#!/bin/bash

# will be installed under /usr/local. Change here, if other destination is needed
export PREFIX=/usr/local
PATH="$PREFIX/bin:$PATH"

# Exit on first error
set -e

# GCC and GAS patches
wget -c http://jupiter.cs.fmf.lu.lv/kursi/bst/avr-new-device-patch.tar.gz
tar -xvzf avr-new-device-patch.tar.gz

# GMP: 
echo "Fetching GMP, required by GCC..."
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
bunzip2 -c gmp-4.3.2.tar.bz2 | tar xf -
mkdir -p gmp-4.3.2/obj
cd gmp-4.3.2/obj
echo "Building GMP..."
../configure --prefix=$PREFIX
make
sudo make install
cd ../..

# MPFR:
echo "Fetching MPFR, required by GCC..."
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
bunzip2 -c mpfr-2.4.2.tar.bz2 | tar xf -
mkdir -p mpfr-2.4.2/obj
cd mpfr-2.4.2/obj
echo "Building MPFR..."
../configure --prefix=$PREFIX
make
sudo make install
cd ../..

# MPC:
echo "Fetching MPC, required by GCC..."
wget -c ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
tar -xzf mpc-0.8.1.tar.gz
mkdir -p mpc-0.8.1/obj
cd mpc-0.8.1/obj
echo "Building MPC..."
../configure --prefix=$PREFIX
make
sudo make install
cd ../..
 
# BINUTILS:
echo "Fetching binutils..."
wget -c http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.bz2
bunzip2 -c binutils-2.20.1.tar.bz2 | tar xf -
cd binutils-2.20.1
cp ../gas-patch-newdevices.patch ./
echo "Building binutils..."
patch -p0 < gas-patch-newdevices.patch
mkdir -p obj-avr
cd obj-avr
../configure --prefix=$PREFIX --target=avr --disable-nls --disable-werror
make
sudo make install
cd ../..

# GCC:
echo "Fetching GCC…"
wget -c http://ftp.gnu.org/gnu/gcc/gcc-4.5.0/gcc-4.5.0.tar.gz
tar -xzf gcc-4.5.0.tar.gz
cd gcc-4.5.0
cp ../gcc-new-device-support.patch ./
echo "Building GCC..."
patch -p0 < gcc-new-device-support.patch
mkdir -p obj-avr
cd obj-avr
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2
make
sudo make install

# AVR LIBC:
export LIBCVERS=1.6.7
wget -c http://download.savannah.gnu.org/releases/avr-libc/avr-libc-$LIBCVERS.tar.bz2
tar xjf avr-libc-$LIBCVERS.tar.bz2
cd avr-libc-$LIBCVERS
mkdir -p obj
cd obj
../configure --prefix=$PREFIX --build=`../config.guess` --host=avr
make
sudo make install