Difference between revisions of "Cross-compiling for the RaspberryPi"
From AIRWiki
AndreaSalvi (Talk | contribs) m |
AndreaSalvi (Talk | contribs) m (→Step One: installing the cross-compiler) |
||
Line 19: | Line 19: | ||
* Download the "official" cross-compiler of the Raspberry Pi project through <code>git</code>: | * Download the "official" cross-compiler of the Raspberry Pi project through <code>git</code>: | ||
− | <code> | + | <code>git clone git://github.com/raspberrypi/tools.git</code> |
This will create, among other things, a <code>tools/arm-bcm2708</code> subfolder containing three different compiler toolchains: | This will create, among other things, a <code>tools/arm-bcm2708</code> subfolder containing three different compiler toolchains: | ||
** arm-bcm2708-linux-gnueabi | ** arm-bcm2708-linux-gnueabi |
Revision as of 11:24, 8 January 2013
This page will guide you to setup a complete cross-compiling environment for the RaspberryPi board. This procedure is tailored for and tested on Ubuntu 12.10, but it can be easily adapted for the use on other distributions.
Contents
Prerequisites
- Install all the required software packages:
sudo apt-get install git
- If you are using a 64-bit version of Ubuntu, also install the 32-bit compatibility libraries:
sudo apt-get install ia32-libs
- The guide will take for granted that you are using the official Raspbian OS image, downloadable from the RaspberryPi website.
- Moreover, you will need a working SSH connection between the Raspberry and your computer (not covered by this guide).
Step One: installing the cross-compiler
- Select a directory in which you will install everything. For the purposes of this guide, I will consider a subdirectory of your home folder,
~/raspberrypi
. Create it and then access it:
cd
mkdir raspberrypi
cd raspberrypi
- Download the "official" cross-compiler of the Raspberry Pi project through
git
:
git clone git://github.com/raspberrypi/tools.git
This will create, among other things, a tools/arm-bcm2708
subfolder containing three different compiler toolchains:
- arm-bcm2708-linux-gnueabi
- arm-bcm2708hardfp-linux-gnueabi
- gcc-linaro-arm-linux-gnueabihf-raspbian
We are going to use the third of these toolchains, since it's the most optimized and supports the FPU that is available on the RaspberryPi board.
- Go back to your home directory, and open your
.bashrc
configuration file with any text editor, likenano
,gedit
orleafpad
, and add this string at the bottom:
PATH=$PATH:$HOME/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
- Now, either logout and login back again, or just close and reopen the terminal window, and type:
arm-linux-gnueabihf-gcc -v
If all goes well, you should see something like
tudhalyas@gondor:~$ arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/tudhalyas/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../libexec/gcc/arm-linux-gnueabihf/4.7.2/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/src/gcc-linaro-4.7-2012.08/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install --with-sysroot=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --disable-multilib --with-arch=armv6 --with-tune=arm1176jz-s --with-fpu=vfp --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-ppl=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-host-libstdcxx='-L/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static/lib -lpwl' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gold --with-local-prefix=/cbuild/slaves/oort61/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08)
Step Two: set-up your compiling environment
... to be continued ...