2013年6月7日 星期五

Compile Raspberry Pi Linux Kernel

This article record how I compile a usable Linux kernel with Emdebian cross-compiler.

Platform: Debian Wheezy
Cross Compiler: arm-linux-gnueabihf-gcc-4.7

  1. Set Emdebian apt repo.
    vi /etc/apt/sources.list

    deb http://www.emdebian.org/debian sid main
  2. Update apt repo. and then add Emdebian keyring. Last, install the cross compiler.

    >> sudo apt-get update
    >> sudo apt-get install emdebian-archive-keyring
    >> sudo apt-get install gcc-4.7-arm-linux-gnueabihf
  3. Set symbolic link of arm-linux-gnueabihf-gcc

    >> sudo ln -s /usr/bin/arm-linux-gnueabihf-gcc-4.7 /usr/bin/arm-linux-gnueabihf-gcc
  4. Download Raspberry Pi Linux kernel source code from github

    >> git clone https://github.com/raspberrypi/linux.git
  5. Clean the build directory

    >>ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make mrproper
  6. Copy Raspberry Pi kernel config file

    >> cp arch/arm/configs/bcmrpi_defconfig .config
  7. Check or Modify kernel features (need libncurses5-dev)

    >>ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make menuconfig
  8. Build kernel Image

    >>ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make Image
  9. If already has a bootable SD card, copy file to replace kernel.img in the SD card.

    >> cp arch/arm/boot/Image /media/SD_CARD/kernel.img
  10. Finish. 
The other kernel config can use and build OK: bcmrpi_cutdown_defconfig