- Installing some prerequisites:
- git (use to access the source code repositories)
On SuSE, useYaSTto install if it’s not already there
On Debian, useapt-get gitto install - Create your base directory: we will use ~/Projects
- git (use to access the source code repositories)
- Installing a cross-compiler:
- Download and compile the latest crosstool-ng from crosstool-ng.org (you will need to be root for the final
make install)
wget crosstool-ng.org/download/crosstool-ng/crosstool-ng-1.17.0.tar.bz2
tar -xvz crosstool-ng-1.17.0.tar.bz2
cd crosstool-ng-1.17.0
./configure
make
make install - Configure a cross compiler
mkdir ~/Projects/souce/ccc;cd ~/Projects/souce/ccc
ct-ng menuconfig
The cross compiler configuration requires the following settings:Section Setting Paths and misc [x] Try features marked as EXPERIMENTAL)
(/tools/x-tools/${CT_TARGET}) Prefix directoryTarget options Target Architecture (arm)
Endianness: (Little endian)
Bitness: (32-bit)Operating System Target OS (linux)
Linux kernel version (3.?.?) – use the correct value!Binary utilities binutils version: choose the latest not marked EXPERIMENTAL C Compiler [x] Show Linaro vesions (EXPERIMENTAL)
gcc version – choose one of the Lenaro versions: 4.6-2-12.04 does workExit from ct-ng menu configuration. - Build a cross-compiler.
As root (or with sudo prefix):
ct-ng buidNote: if build fails with a message about Static linking impossible, edit the .config file and change CT_WANTS_STATIC_LINKING=n and try again.
The compiler will be in /tools/x-tools/arm-unknown-linux-gnueabi
The build takes quite a while… (42 minutes on a single core of i5-2500 at 3.3GHz)
- Download and compile the latest crosstool-ng from crosstool-ng.org (you will need to be root for the final
- Installing the Linux Kernel Sources (which are required for compiling modules and drivers):
- Create a source directory ~/Projects/source an running the following commands from that directory:
git clone git://github.com/raspberrypi/linux.gitgit clone git://github.com/raspberrypi/firmware.gitgit clone git://github.com/raspberrypi/tools.git
You will now have three directories under ~/Projects/source: linux, firmware and tools. - Set the right version of the Linux Kernel – which needs to be the same version you are using on the RaspberryPi.
You can find the version RaspberryPi is running using the command:raspberrypi:~> uname -sr Linux 3.2.27+
You can see the available versions of the Linux kernel by:rpidev:~> cd ~/Projects/source/linux rpidev:linux> git branch -r origin/HEAD -> origin/rpi-3.6.y origin/master origin/rpi-3.2.27 origin/rpi-3.6.y origin/rpi-patches
You can set the version to rpi-3.2.27 using:
git checkout rpi-3.2.27- ARM System Type=Broadcom BCM2708 family
- Copy from your backup:
cp ../linux.config .config - Get it from the Raspberry Pi
ssh root@rpi zcat /proc/config > .config - Check the configuration:
make ARCH=arm CROSS_COMPILE=/tools/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- oldconfig
This will prompt you to confirm any new options – use the default except for: - Edit the configuration:
make ARCH=arm CROSS_COMPILE=/tools/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- menuconfig
Some areas you might want to configure (especially if you’re planning to use this kernel on the device):- Floating Point emulation: you need one emulation set
- Networking support (enable for more, disable for smaller)
- Device drivers (enable for more, disable for smaller)
- Build the kernel using: (-j2 means use 2 core in parallel)
make ARCH=arm CROSS_COMPILE=/tools/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- -j2 - To compile my_module, use the following makefile:
obj-m:=mymodule.o
And compile with:
make ARCH=arm CROSS_COMPILE=/tools/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- -C ~/Projects/source/linux SUBDIRS=`pwd` modules
make mrpropermake kernelversion