Cross Compiling Linux Kernel on Debian for Raspberry Pi

The ArchLinux  is a good starting point for a linux platform due to its simplicity. The system though does not have a gui and you might need to install one if you require. The linux kernel that came off with the archlinux image did not have a support for 12C or TWI and SPI interface which prompted be to compile a new kernel with support for these two interfaces.

To compile a kernel you will need a cross compile that will be running on a Debian host machine, I had code sourcery arm compiler ,arm-2009q3 or alternatively  install it from emdebian respository by issuing the following command from debian console

aptitude install gcc-4.4-arm-linux-gnueabi

Next we need the kernel source so head to rpi git and download the latest tar source tree. you can alternatively  clone using git

git clone

CD into the cloned directory or directory where you untarred the kernel source and issue the following command to generate a configuration file

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- bcmrpi_defconfig

Once you are done we are now ready to start the build, run the following command

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi

and after a successful compilation you will be greeted by a message “zImage created”.  We need to install the brand new modules so create a folder outside the kernel source folder and run the following command

make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- INSTALL_MOD_PATH=/Folder path/

This will create and install files into two folder i.e modules and firmware folders. Remove existing similar folders from the Archlinux rootfs and copy the two folders to:

  /usr/lib/modules and /usr/lib/firmware

We are now ready to install the kernel by copying and replacing the existing kernel.img file with the newly created zImage  in the boot partion (first FAT partition)of the SD card.

  cp arch/arm/boot/zImage      /mnt/partion #1/kernel.img

You will also need to update the boot loader firmware available from,  grab and replace the following files, in the boot partition of the SD card.

  arm128_start.elf arm192_start.elf arm224_start.elf bootcode.bin loader.bin start.elf

That’s it! Reboot the rpi and the  processor will boot your brand new kernel. Enjoy !!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: