Installation/FromScratch

From PaparazziUAV
Jump to navigation Jump to search

Building the ARM cross-toolchain

The goal of this part is to building an ARM cross-toolchain with binutils gcc newlib and gdb from source. This is needed so we can compile the code that ends up onto the autopilot board. Newlib is a C library intended for use on embedded systems. It is a conglomeration of several library parts, all under free software licenses that make them easily usable on embedded products.

#!/bin/sh

TARGET=arm-none-eabi 		  # Or: TARGET=arm-elf
PREFIX=/tmp/your-arm-toolchain     # Install location of the final toolchain
SPEEDUPCOMPILATION="-j 4"	  # Or: SPEEDUPCOMPILATION=""

BINUTILS=binutils-2.20.1
GCC=gcc-4.4.4
NEWLIB=newlib-1.18.0
GDB=gdb-7.1

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

mkdir build

wget -c http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2
tar xfvj $BINUTILS.tar.bz2 
cd build
../$BINUTILS/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls
make $COMPILEFASTER
make install
cd ..
rm -rf build/* $BINUTILS $BINUTILS.tar.bz2

wget -c ftp://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2
tar xfvj $GCC.tar.bz2 
cd build
../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --enable-languages="c" --with-newlib --without-headers --disable-shared --with-gnu-as --with-gnu-ld
make $SPEEDUPCOMPILATION all-gcc
make install-gcc
cd ..
rm -rf build/* $GCC.tar.bz2

wget -c ftp://sources.redhat.com/pub/newlib/$NEWLIB.tar.gz
tar xfvz $NEWLIB.tar.gz
cd build
../$NEWLIB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --with-gnu-as --with-gnu-ld --disable-nls
make $SPEEDUPCOMPILATION
make install
cd ..
rm -rf build/* $NEWLIB $NEWLIB.tar.gz

# GCC needes to be build again including the real newlib now
cd build
../$GCC/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib --enable-languages="c,c++" --with-newlib --disable-shared --with-gnu-as --with-gnu-ld
make $SPEEDUPCOMPILATION
make install
cd ..
rm -rf build/* $GCC

wget -c ftp://ftp.gnu.org/gnu/gdb/$GDB.tar.bz2
tar xfvj $GDB.tar.bz2
cd build
../$GDB/configure --target=$TARGET --prefix=$PREFIX --enable-interwork --enable-multilib
make $SPEEDUPCOMPILATION
make install
cd ..
rm -rf build $GDB $GDB.tar.bz2