编译内核

内核下载地址
https://www.kernel.org/

交叉编译工具链安装

# sudo apt-get install gcc-arm-linux-gnueabi

删除源代码目录中残留的.o文件和其它从属文件

# make mrproper

配置内核

# make menuconfig

也可以拷贝一个准备好的配置文件到.config,然后make menuconfig选择"Load an Alternate Configuration File"选项,选择.config文件,OK

默认配置

# ls arch/arm/configs/
assabet_defconfig        h7201_defconfig       neponset_defconfig
at91rm9200dk_defconfig   h7202_defconfig       netwinder_defconfig
at91rm9200ek_defconfig   hackkit_defconfig     netx_defconfig
at91sam9260ek_defconfig  integrator_defconfig  ns9xxx_defconfig
at91sam9261ek_defconfig  iop13xx_defconfig     omap_h2_1610_defconfig
at91sam9263ek_defconfig  iop32x_defconfig      onearm_defconfig
at91sam9rlek_defconfig   iop33x_defconfig      picotux200_defconfig
ateb9200_defconfig       ixp2000_defconfig     pleb_defconfig
badge4_defconfig         ixp23xx_defconfig     pnx4008_defconfig
carmeva_defconfig        ixp4xx_defconfig      pxa255-idp_defconfig
cerfcube_defconfig       jornada720_defconfig  realview_defconfig
clps7500_defconfig       kafa_defconfig        realview-smp_defconfig
collie_defconfig         kb9202_defconfig      rpc_defconfig
corgi_defconfig          ks8695_defconfig      s3c2410_defconfig
csb337_defconfig         lart_defconfig        shannon_defconfig
csb637_defconfig         lpd270_defconfig      shark_defconfig
ebsa110_defconfig        lpd7a400_defconfig    simpad_defconfig
edb7211_defconfig        lpd7a404_defconfig    spitz_defconfig
ep93xx_defconfig         lubbock_defconfig     trizeps4_defconfig
footbridge_defconfig     lusl7200_defconfig    versatile_defconfig
fortunet_defconfig       mainstone_defconfig
h3600_defconfig          mx1ads_defconfig

# make xxx_defconfig

编译内核

# make dep

清除内核编译的目标文件

# make clean 

编译内核

# make zImage
# make uImage LOADADDR=xxx

区别:uIamge是由mkimage制作而来;uIamge是zIamge压缩而成,bootm需要先对uIamge解压,解压地址为内核入口地址;uboot目前只能支持uImage启动,不支持zImage启动

注:uImage要指定load地址,否则报错

Specify LOADADDR on the commandline to build an uImage

可选编译参数

# make -jn

j代表同时编译的进程,可以加快编译速度。n由用户计算机的配置与性能决定,当前的典型值为10

编译可加载模块

# make modules 
# make modelus_install 

生成目录在/lib/modules

如果出现以下错误:

"mkimage" command not found

原因:没有找到mkimage这个工具,而mkimage是在编译uboot后产生的
解决办法:

export PATH:=$PATH:/u-boot/tools

Ubuntu下可以使用命令安装

# apt-get install uboot-mkimage
原文地址:https://www.cnblogs.com/zhangxuechao/p/11709794.html