2015年5月18日 星期一

raspberry pi cross compile kernel

Cross compile platform: Ubuntu x64
Target: Raspberry pi

1. Download tool chain and configuration
  • Get from git
git clone https://github.com/raspberrypi/tools.git
  • Add tool chain gcc path to /etc/profile, it will take effect when next login.
PATH="$PATH:/usr/local/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin" >> /etc/profile

2. Download kernel source
git clone https://github.com/raspberrypi/linux.git
  
3. Get raspberry pi config


  • Login to raspberry pi console and:
zcat /proc/config.gz > .config
  • Back to download source code location
  • Copy config file 
scp pi@:~/.config .
4. Make kernel and module0
  • Make config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig
  • kernel compile
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  • module install
mkdir ../modules
make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../modules/
  •  Generate image
cd ~/tools/mkimage
./imagetool-uncompressed.py ~/linux/arch/arm/boot/zImage"

5. Copy image and modules to pi
scp ~/tools/mkimage/kernel.img pi@:~/
scp -r ~/modules ~/ pi@:~/

6. Login pi console and move image and modules to system boot path

  • Backup original kernel if needed
mv /boot/kernel.img /boot/kernel.img.bak
  • Move new kernel image to boot partition
mv kernel.img /boot/kernel.img
  • Move corresponding modules to lib
mv modules/lib/modules/3.18.x /lib/modules/

7. Reboot pi and check the it uses new kernel
uname -r

沒有留言:

張貼留言