2016年3月24日 星期四

Raspberry Pi - 編譯新核心

1. 在Raspiberry Pi上,將kernel config存成檔案
$ zcat /proc/config.gz > .config
2. 從Git Server中,下載kernel source
$ cd rpi
$ git clone https://github.com/raspberrypi/linux.git

or

$ git clone --depth=1 https://github.com/raspberrypi/linux
3. 轉換kernel source到rpi-3.10.y
$ cd linux
$ git checkout rpi-3.10.y
列出所有branch
$ git branch -a
4. export環境變數
$ export ARCH=arm
$ export CROSS_COMPILE=arm-linux-gnueabihf-
5. 從Raspberry Pi的檔案系統中,取得kernel configuration。
$ make mrproper
$ scp pi@192.168.1.2:/home/pi/.config .
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- oldconfig

或者直接用source tree裡的config
(cd arch/arm/configs/ && ls bcm*)
arch/arm/configs/
./bcmrpi_defconfig
./bcm_defconfig
./bcm2709_defconfig
./bcm2835_defconfig
5.1. RASPBERRY PI 1 (OR COMPUTE MODULE) DEFAULT BUILD CONFIGURATION
cd linux
KERNEL=kernel
make bcmrpi_defconfig

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcmrpi_defconfig
5.2. RASPBERRY PI 2/3 DEFAULT BUILD CONFIGURATION
cd linux
KERNEL=kernel7
make bcm2709_defconfig

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
6. 看需求,修改kernel config
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
7. 編譯kernel
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j 4

‘-j [jobs]’
‘--jobs[=jobs]’
Specifies the number of recipes (jobs) to run simultaneously.
8. 編譯 kernel module
$ mkdir ../modules
$ make modules_install ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../modules/
9. 將kernel image相關檔案放到記憶卡
// RASPBERRY PI 1 (OR COMPUTE MODULE) DEFAULT BUILD CONFIGURATION
$ sudo cp -Rf ~/rpi/linux/arch/arm/boot/zImage ~/sdb1/boot/kernel.img

// RASPBERRY PI 2/3 DEFAULT BUILD CONFIGURATION
$ sudo cp -Rf ~/rpi/linux/arch/arm/boot/zImage ~/sdb1/boot/kernel7.img

// Kernel Modules
$ sudo cp -Rf ~/rpi/modules/lib/firmware/ ~/sdb2/lib/
$ sudo cp -Rf ~/rpi/modules/lib/modules/ ~/sdb2/lib/
10. 進入Raspberry Pi,修改將開機kernel image
$ vi /boot/config.txt
kernel=kernel-new.img

沒有留言:

張貼留言