Raspberry Pi development environment

This page describes how to setup a cross compiler on a linux x86 host tailored for the Raspberry Pi cpu's.

The follow libc and libgcc libraries are available :

pi@xubuntu:/opt/gnuarm-hardfp$ arm-none-eabi-gcc -print-multi-lib

.;

armv8-a/cortex-a53/hardfp/fp-armv8;@march=armv8-a@mtune=cortex-a53@mfloat-abi=hard@mfpu=fp-armv8

armv8-a/cortex-a53/hardfp/neon-fp-armv8;@march=armv8-a@mtune=cortex-a53@mfloat-abi=hard@mfpu=neon-fp-armv8

armv7-a/cortex-a7/hardfp/vfpv4;@march=armv7-a@mtune=cortex-a7@mfloat-abi=hard@mfpu=vfpv4

armv7-a/cortex-a7/hardfp/neon-vfpv4;@march=armv7-a@mtune=cortex-a7@mfloat-abi=hard@mfpu=neon-vfpv4

armv6zk/arm1176jzf-s/hardfp/vfp;@march=armv6zk@mtune=arm1176jzf-s@mfloat-abi=hard@mfpu=vfp

pi@xubuntu:/opt/gnuarm-hardfp$ find $PREFIX -name libc.a | sort

./arm-none-eabi/lib/armv6zk/arm1176jzf-s/hardfp/vfp/libc.a

./arm-none-eabi/lib/armv7-a/cortex-a7/hardfp/neon-vfpv4/libc.a

./arm-none-eabi/lib/armv7-a/cortex-a7/hardfp/vfpv4/libc.a

./arm-none-eabi/lib/armv8-a/cortex-a53/hardfp/fp-armv8/libc.a

./arm-none-eabi/lib/armv8-a/cortex-a53/hardfp/neon-fp-armv8/libc.a

./arm-none-eabi/lib/libc.a

pi@xubuntu:/opt/gnuarm-hardfp$ find $PREFIX -name libgcc.a | sort

./lib/gcc/arm-none-eabi/4.9.3/armv6zk/arm1176jzf-s/hardfp/vfp/libgcc.a

./lib/gcc/arm-none-eabi/4.9.3/armv7-a/cortex-a7/hardfp/neon-vfpv4/libgcc.a

./lib/gcc/arm-none-eabi/4.9.3/armv7-a/cortex-a7/hardfp/vfpv4/libgcc.a

./lib/gcc/arm-none-eabi/4.9.3/armv8-a/cortex-a53/hardfp/fp-armv8/libgcc.a

./lib/gcc/arm-none-eabi/4.9.3/armv8-a/cortex-a53/hardfp/neon-fp-armv8/libgcc.a

./lib/gcc/arm-none-eabi/4.9.3/libgcc.a

Install the gcc compiler with extras

sudo -i

apt-get update && apt-get upgrade

apt-get install gcc g++ make bison byacc flex gnat gawk perl zlibc

Create the target directory for the cross compiler.

mkdir /opt/gnuarm-hardfp

chown -R pi:pi /opt/gnuarm-hardfp

exit

Setup the variables

export TARGET=arm-none-eabi

export PREFIX=/opt/gnuarm-hardfp

export PATH=$PATH:$PREFIX/bin

BINUTILS=binutils-2.25

GCC=gcc-4.9.3

NEWLIB=newlib-2.2.0

Get the archives

cd /opt/gnuarm-hardfp

wget http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2

wget http://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.bz2

wget ftp://sourceware.org/pub/newlib/$NEWLIB.tar.gz

Extract the archives

tar xvf $BINUTILS.tar.bz2

tar xvf $GCC.tar.bz2

tar xzvf $NEWLIB.tar.gz

Remove the archives

rm -rf $BINUTILS.tar.bz2 $GCC.tar.bz2 $NEWLIB.tar.gz

Download the gcc prerequisites

cd /opt/gnuarm-hardfp/$GCC

./contrib/download_prerequisites

cd -

Make sure that all configure files have execute rights

find /opt/gnuarm-hardfp/$GCC -name configure | xargs chmod a+x

Copy the multilib config file

cp t-arm-elf $GCC/gcc/config/arm/

Build the binutils

mkdir build-binutils

cd build-binutils

../$BINUTILS/configure --target=$TARGET --prefix=$PREFIX

make -j 4 all

make install

Build the GCC minimum configuration

mkdir ../build-gcc

cd ../build-gcc

../$GCC/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --enable-languages="c,c++" --with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 --with-mode=arm --with-float=hard

make -j 4 all-gcc

make install-gcc

Build the newlib

mkdir ../build-newlib

cd ../build-newlib

../$NEWLIB/configure --target=$TARGET --prefix=$PREFIX --disable-newlib-supplied-syscalls

make -j 4

make install

Build GCC again with newlib

cd ../build-gcc

../$GCC/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib --enable-languages="c,c++" --with-gcc --with-gnu-ld --with-gnu-as --with-dwarf2 --with-mode=arm --with-float=hard

make -j 4 all

make install

Build the gcc libraries

make -j 4 all-target-libgcc CFLAGS_FOR_TARGET="-g -O3"

make install-target-libgcc

Display the build results and remove the build directories

arm-none-eabi-gcc -print-multi-lib

cd $PREFIX

rm -rf build-*

find -name libc.a | sort

find -name libgcc.a | sort

Add the bin path to the pi profile

vi ~pi/.profile

export PATH=/opt/gnuarm-hardfp/bin:$PATH