树莓派论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5208|回复: 5
收起左侧

树莓派的内核编译教程

[复制链接]
发表于 2013-3-17 21:40:17 | 显示全部楼层 |阅读模式
如题,首先在https://github.com/raspberrypi/linux/上下载最新的内核源代码,连接如下:https://github.com/raspberrypi/linux/archive/rpi-3.2.27.zip

然后安装编译工具如gcc、make、patch等,可以使用apt-get install gcc make命令

然后检查系统时间,如果时间不对,可以手动设置一下时间,也可以重新启动ntp服务,自动对时

将下载的内核文件放在随便找个目录放着,并用unzip解压它,

unzip rpi-3.2.27.zip

如果命令不成功则可能是没有安装unzip,可以使用apt-get install unzip命令安装就行了

开始编译内核,首先使用以下命令对内核进行配置

make menuconfig

载图太麻烦了,所以我直接用鼠标选了图,大家将就的看看吧。

需要说明的是在System Type  --->这一项里,一定要选择合适的cpu也就是armBCM2708这个型号,其它的东西大家可以自己选择,需要什么用星号表示将这一项编译进内核,M表示编译成模块。
  1. .config - Linux/arm 3.2.27 Kernel Configuration
  2. qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
  3. lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq System Type qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
  4. x Arrow keys navigate the menu. <Enter> selects submenus --->. Highlighted letters are x
  5. x hotkeys. Pressing <Y> includes, <N> excludes, <M> modularizes features. Press <Esc><Esc> x
  6. x to exit, <?> for Help, </> for Search. Legend: [*] built-in [ ] excluded <M> module < > x
  7. x module capable x
  8. x lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk x
  9. x x [*] MMU-based Paged Memory Management Support x x
  10. x x ARM system type (Broadcom BCM2708 family) ---> x x
  11. x x *** System MMU *** x x
  12. x x Broadcom BCM2708 Implementations ---> x x
  13. x x *** Processor Type *** x x
  14. x x -*- Support ARM V6 processor x x
  15. x x *** Processor Features *** x x
  16. x x [*] Support Thumb user binaries x x
  17. x x [ ] Disable I-Cache (I-bit) x x
  18. x x [ ] Disable D-Cache (C-bit) x x
  19. x x [ ] Disable branch prediction x x
  20. x x [*] Use non-cacheable memory for DMA x x
  21. x x [ ] ARM errata: FSR write bit incorrect on a SWP to read-only memory x x
  22. x x -*- ARM errata: Invalidation of the Instruction Cache operation can fail x x
  23. x x [ ] ARM errata: Possible cache data corruption with hit-under-miss enabled x x
  24. x x x x
  25. x x x x
  26. x x x x
  27. x x x x
  28. x x x x
  29. x x x x
  30. x x x x
  31. x x x x
  32. x x x x
  33. x x x x
  34. x x x x
  35. x x x x
  36. x x x x
  37. x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
  38. tqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqu
  39. x <Select> < Exit > < Help > x
  40. mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
复制代码
选择完了后可以使用左右键来进行选择<Select> < Exit > < Help >,退出时会自己保存配置

如果你的在做make menuconfig时没有看到上面的画面,而是看到一堆英文,则一般是没有安装libncurses5-dev开发库,使用apt-get install libncurses5-dev来安装就行了

当选择完成后直接make就可以了

make程序会自己编译内核以及模块。

安装模块使用make modules_install命令

在make运行完成后需要重新生成一个镜像。这需要使用其它的工具。

https://github.com/raspberrypi/tools上面有一个目录mkimage,这个目录下存有这些工具,将这里面的文件全部下载下来,存放在一个目录中,然后执行下面的命令:

python imagetool-uncompressed.py 你的源代码目录/arch/arm/boot/Image

很快这个命令就会执行完成,你会发现在目录下有一个kernel.img的文件,这个就是你的新内核,将它覆盖boot目录下的kernel.img文件,现在你可以使用新内核来启动你的pi了。

回复

使用道具 举报

发表于 2013-3-23 14:15:02 | 显示全部楼层
建议交叉编译 时间就是金钱~
回复 支持 反对

使用道具 举报

发表于 2013-4-15 21:46:03 | 显示全部楼层
如何交叉编译?
回复 支持 反对

使用道具 举报

发表于 2013-6-16 12:37:02 | 显示全部楼层
手工建立交叉编译链太恐怖了...俩星期没搞出来,只好暂时放弃
回复 支持 反对

使用道具 举报

发表于 2013-8-22 15:39:12 | 显示全部楼层
如何交叉编译呢?
回复 支持 反对

使用道具 举报

发表于 2014-12-16 21:52:45 | 显示全部楼层
就是说还是像嵌入式那样,要宿主机要交叉编译链。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|树莓派论坛 ( 粤ICP备15075382号-1  

GMT+8, 2024-11-25 18:27 , Processed in 1.093750 second(s), 28 queries , Gzip On.

Powered by Shumeipai.net! X3.2

© 2001-2015 树莓派论坛安全联盟

快速回复 返回顶部 返回列表