手中的红色树莓派已经买来许久,但还没怎么玩。最近想学习内核的知识,所以开始拿出手中的Pi。从内核编译开始,于是有了这篇文章。内核的编译主要参考这篇博客古作坊和官方教程。下面是根据回忆记录,有错误请指出。
$ git clone git://github.com/raspberrypi/firmware.git firmware
$ git clone git://github.com/raspberrypi/linux.git linux
$ git clone git://github.com/raspberrypi/tools.git tool
izobs$ gunzip config.gz
izobs$ mv config .config
izobs$ cp .config ../linux
接下来:
izobs$ make ARCH=arm CROSS_COMPILE=../tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- oldconfig
izobs$ make ARCH=arm CROSS_COMPILE=../tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- menuconfig
配置完自己想要的模块,接下来就是编译了。
izobs$ make ARCH=arm CROSS_COMPILE=../tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- -j4
等待编译完成后,将zImage 打包成kernel.img
izobs$ cd git-version/tool/mkimage
izobs$ ./imagetool-uncompressed.py ../../linux/arch/arm/boot/zImage
在mkimage目录下着会生成kernel.img啦!
izobs$ cd ../git-version
izobs$ mkdir modules
izobs$ cd git-verison/linux
izobs$ make modules_install ARCH=arm CROSS_COMPILE=../tools/arm-bcm2708/arm-bcm2708hardfp-linux-gnueabi/bin/arm-bcm2708hardfp-linux-gnueabi- INSTALL_MOD_PATH=../modules
到此,编译工作完成,下面进行新内核的安装。
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda6 19G 11G 7.6G 58% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 1.9G 4.0K 1.9G 1% /dev
tmpfs 376M 948K 375M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.9G 3.0M 1.9G 1% /run/shm
none 100M 16K 100M 1% /run/user
/dev/sda8 45G 39G 4.0G 91% /home
/dev/sda4 9.1G 7.5G 1.6G 83% /media/izobs/zob
/dev/sda3 21G 19G 2.5G 89% /media/izobs/zob2
/dev/sda1 51G 37G 14G 73% /media/izobs/26608333608308AF
/dev/sda5 140G 126G 14G 91% /media/izobs/软件
/dev/mmcblk0p1 56M 18M 39M 31% /media/izobs/boot
/dev/mmcblk0p2 7.3G 1.8G 5.2G 26% /media/izobs/41cd5baa-7a62-4706-b8e8-02c43ccee8d9
假如你的linux系统能自动挂载的话,df -h后,你将看到上面的东东。如果不能自动挂载,则手动
izobs-HP# cd /media/izobs/boot
izobs-HP# ls
bootcode.bin fixup_cd.dat issue.txt kernel_new.img
cmdline.txt fixup.dat kernel_emergency.img start.elf
config.txt fixup_x.dat kernel.img
izobs-HP#
izobs$ mv *.elf *.bin
+kernel=kernel_new.img
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
建用git拉下来的firmware中的
bootcode.bin fixup.dat fixup_cd.dat start.elf复制到此处
izobs$ cp /home/izobs/workspace/Ra-Pi/git-version/firmware/boot bootcode.bin fixup.dat fixup_cd.dat start.elf