topamax once a day

Raspberry Pi Kernel Compile


This tutorial will demonstrate how to cross compile the kernel for the Raspberry Pi on Ubuntu 12.04 LTS. The kernel is functional with both the Debian and Arch Linux Raspberry Pi images.

UPDATE: Alternatively, you can use the following Ansible playbook playbook-raspi_kernel_crosscompile. Note that you have to edit host_vars/localhost.yml file with your local sudo password.

git clone
ansible-playbook -i localhost.yml site.yml -vvvv

First, install the package dependencies, git and the cross-compilation toolchain:

sudo apt-get install git-core gcc-4.6-arm-linux-gnueabi

Create a symlink for the cross compiler:

sudo ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-gcc

Make a directory for the sources and tools, then clone them with git:

mkdir raspberrypi
cd raspberrypi
git clone
git clone
cd linux

Generate the .config file from the pre-packaged raspberry pi one:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- bcmrpi_cutdown_defconfig

If you want to make changes to the configuration, run make menuconfig (optional):

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- menuconfig

Once you have made the desired changes, save and exit the menuconfig screen. Now we are ready to start the build. You can speed up the compilation process by enabling parallel make with the -j flag. The recommended use is ‘processor cores + 1′, e.g. 5 if you have a quad core processor:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- -k -j5

Assuming the compilation was sucessful, create a directory for the modules:

mkdir ../modules

Then compile and ‘install’ the loadable modules to the temp directory:

make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/

Now we need to use from the tools repo to get the kernel ready for the Pi.

cd ../tools/mkimage/
./ ../../linux/arch/arm/boot/Image

This creates a kernel.img in the current directory. Plug in the SD card of the existing Debian image that you wish to install the new kernel on. Delete the existing kernel.img and replace it with the new one, substituting “boot-partition-uuid” with the identifier of the partion as it is mounted in Ubuntu.

sudo rm /media/boot-partition-uuid/kernel.img
sudo mv kernel.img /media/boot-partition-uuid/

Next, remove the existing /lib/modules and lib/firmware directories, substituting “rootfs-partition-uuid” with the identifier of the root filesystem partion mounted in Ubuntu.

sudo rm -rf /media/rootfs-partition-uuid/lib/modules/
sudo rm -rf /media/rootfs-partition-uuid/lib/firmware/

Go to the destination directory of the previous make modules_install, and copy the new modules and firmware in their place:

cd ../../modules/
sudo cp -a lib/modules/ /media/rootfs-partition-uuid/lib/
sudo cp -a lib/firmware/ /media/rootfs-partition-uuid/lib/

That’s it! Exject the SD card, and boot the new kernel on the Raspberry Pi!



  1. if you copt the boot directory from the firmware github onto the sdcard boot partition, you can just copy the kernel image arch/arm/boot/bzImage to sdcard/boot_partitiion/kernel.img – it will work straight away.

  2. sokkaaj

    What is the modification you’re talking about on the external USB rootfs page?

    • The modification allows you to move the root filesystem (ie ‘/’) from the SD card to a USB drive. I have several USB drives in excess of 16GB, but only a 4GB SD card. Moving ‘/’ to the USB drive gives me much more space.

  3. iqzer0++

    is there any way to change the root password ?

  4. Moin dear Michel and interrogators!
    Thank You for detailed instruction which I was looking for since I found no direct ADSL connection over PPPoE provided for on RP.
    Perhaps some more advice available in this direction?
    Greetings from Hamburg, North Germany!

    • Hi Ludolf,
      It looks like PPP is supported by default, but PPPoE is not. For kernel support, you will need to enable the PPPoE module. In the .config file, change:
      # CONFIG_PPPOE is not set
      Then you should be able to follow the official Debian instructions to configure PPPoE here:

  5. hey, i’ve followed all the steps above and the new kernel runs, but a can’t load modules and getting Exec format error after modprobe

  6. Hey ,

    All steps are very clear to me. I successfully built the kernel and run on the board. but it fails to load any module as even mouse and keyboard attached to board stop responding. Please guide me through this…Thanks.


  7. make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi- INSTALL_MOD_PATH=../modules/

    should be

    make modules_install ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-gcc-4.6 INSTALL_MOD_PATH=../modules/

  8. Thank you very much for this tutorial please help me I cannot locate xorg.conf file.
    I’m using raspbmc and compiling went well but I’m missing xorg.conf.
    Touch is now working but I cannot do anything until edit this file.

  9. Very nice tutorial!

  10. 110202820

    Whenever I try to move the kernel to the sd card, it tells me that kernel.img doesnt exist. Help?

  11. When I type in the first line it says “could not locate package” please help

  12. Ramesh

    I followed the above steps and It worked fine for me..Thanks a lot

  13. Worked for me; thanks very much!

  14. Thank you very much for the tutorial, it the easiest out there to follow. Maybe you can add how to calibrate it in the end. This tutorial dose almost as you do (You do it better) but in the end there are some calibration instructions.

    Ok. to my question :) I have followed your tutorial and the touch screen is working perfectly. But my WiFi USB dongle is stop working… Is it some thing in the configuration file that is missing or some bad communication between the injected kernel.img and the drivers? have suggestions?



  15. I also got the failed message on the first step. Has the version number been updated since 12.04ls?

    • JL,
      Give the Ansible playbook a try. It automates the process. You can read the playbook if you wish to instead execute the commands manually.

  16. Snake Hi, I have not had luck with the instructions. I am trying to use a AOC usb monitor with my Pi. Can you provide instruction for copying the kernel.


  1. Raspberry Pi Root FS on USB Drive | MitchTech - [...] This tutorial will demonstrate how to install the Debian root filestem (ie. ‘/’) on a USB drive instead of …
  2. Compile Kernel on CentOS/RHEL for Raspberry Pi at 爱折腾 - [...] [...]
  3. Raspberry PI and AOC e1649Fwu USB powered LED monitor « imkiyoung - [...] Follow instructions in [...]
  4. Recompiler le kernel du Raspi avec les outils Linaro | Le blog d'Androme - [...] Sources : [...]
  5. How to fully encrypt your Raspberry Pi (CryptoPi) : ROAB/sec - [...] [...]
  6. Raspberry piにDisplayLinkのUSBディスプレイを接続する | tetro - [...] Mimo USB Monitor and Raspberry Pi – anuk nurkhede Raspberry Pi Kernel Compile – MitchTech これでダメなら諦めた方が良い程度にRasberry [...]
  7. วิธีการคอมไพล์ kernel ของ raspberry pi | Ayarafun Factory - [...] เพิ่มเติม [...]
  8. RaspberryPiでdisplaylink | ITでGameなMusic! - […] 【ココと ココと ココと ココと ココと ココと ココ 参照】 […]
  9. eGalax Touch (Cross compiling Pi) - 李小华的博客 - […] first step in getting this done is to compile the raspbian kernel with necessary kernel module. Here is a nice …
  10. Cross-compile Raspberry pi linux kernel | baldd - […] […]
  11. How do I cross-compile the Kernel on a Ubuntu host? | CL-UAT - […] […]
  12. How do I cross-compile the Kernel on a Ubuntu host? | XL-UAT - […] […]
  13. How do I cross-compile the kernel on a Ubuntu host? | DL-UAT - […] […]
  14. cross compiling fail. No rule to make 'modules install' - BlogoSfera - […] I am trying to cross compile a linux kernel for my raspberry pi on my host. Like this: …

Leave a Reply