你可以使用RPi本來進行compile,或者在你自己的linux system上執行cross-compiler.這篇文章是以後者的方式(使用Ubuntu PC)進行
步驟
0.以下所寫RPi上的路徑(/home/me/RPi),請記得依你實際的環境修改1. Get the latest raspberrypi compiler:
可以從Git Hub上下載pre-build bmc2708 compiler
git clone git://github.com/raspberrypi/tools.git
或者從此連結下載tarball2. Get the raspberrypi kernel source
git hub上有很多branch版本,你可以特別指定想要的branch,我下載時master版本是rpi-3.10.y,因此以此為例
git clone git://github.com/raspberrypi/linux.git rpi-3.10.y
3. 取得一個能正常使用的kernel configuration
可以取出你手邊正在運行的RPi的把config
zcat /proc/config.gz > .config
或者可以從raspberrypi kernel source(arch/arm/configs/)取出一個來(例如bcmrpi_defconfig)修改使用 4. 設定環境變數 CCPREFIX 指向cross-compile tool
這步可做可不做,不做就是之後的指令打長一點
export CCPREFIX=/home/me/RPi/tools-master/arm-bcm2708/arm-bcm2708-linux-gnueabi/bin/arm-bcm2708-linux-gnueabi-
5. 清除所有 generated files、config 和 various backup files
make mrproper
6. 從 RPi 上複製 .config 至 第三步下載的kernel source 的root
7. 進行config
make ARCH=arm CROSS_COMPILE=${CCPREFIX} oldconfig
這步有很多的設定可以選,如果沒有特別修改需求的可以一直按enter下去8. start building kernel
make ARCH=arm CROSS_COMPILE=${CCPREFIX}
如果電腦有多核心的話,可以下-j (-j<N> where <N> is the number of cores on your system plus one (i.e. -j3 for 2 cores).)編譯完成後,會產生 arch/arm/boot/Image 檔案,這支Image就是kernel
9. 重編Kernel Module
mkdir /home/me/RPi/new_kernel/modules
make ARCH=arm CROSS_COMPILE=${CCPREFIX} INSTALL_MOD_PATH=/home/me/RPi/new_kernel/modules modules_install
編譯完成後的檔案會在/home/me/RPi/new_kernel/modules/lib 下10. 更新kernel跟module
kernel: 複製arch/arm/boot/Image檔案到SD卡的boot partition並且rename成kernel.img
module: 把/home/me/RPi/new_kernel/modules下的lib目錄,複製到SD卡的root partition(直接蓋掉原本的lib內的檔案)
11. 如果你build的kernel跟你原本SD卡所使用的kernel版本差異太大,建議下載firmware並更新
git://github.com/raspberrypi/firmware.git
12. 重新啟動RPi並確定系統正常運作
0 意見:
張貼留言