Arm Linux Kernel 构建 情景分析
时间:11-09
来源:互联网
点击:
概述
构建一个内核,一般是先配置,后编译。这里以构建 Nexus5 内核为例,代号为hammerhead。
配置
通常做法是以厂商预置的配置为基础,根据自己需要进行配置。命令:
make ARCH=arm hammerhead_defconfig执行完毕后,"arch/arm/configs/hammerhead_defconfig" 文件会被到 ".config" ,作为默认配置。
然后运行以下命令根据自己需要进行配置:
make ARCH=arm menuconfig编译
通常,需要生成 zImage 和 内核模块。如果不指定目标,这两个都会默认生成。命令:
- # CROSS_COMPILE 的值根据自己情况设定
make ARCH=arm CROSS_COMPILE=arm-linux-androideabi-这条命令做了什么呢,把 make 输出到控制台的信息贴出来(省略中间相似的信息):
make ARCH=arm CROSS_COMPILE=arm-linux-androideabi- CONFIG_DEBUG_SECTION_MISMATCH=yscripts/kconfig/conf --silentoldconfig KconfigWRAP arch/arm/include/generated/asm/auxvec.hWRAP arch/arm/include/generated/asm/bitsperlong.hWRAP arch/arm/include/generated/asm/cputime.h...WRAP arch/arm/include/generated/asm/siginfo.hWRAP arch/arm/include/generated/asm/sizes.hCHK include/linux/version.hUPD include/linux/version.hCHK include/generated/utsrelease.hUPD include/generated/utsrelease.hGenerating include/generated/mach-types.hCC kernel/bounds.sGEN include/generated/bounds.hCC arch/arm/kernel/asm-offsets.sGEN include/generated/asm-offsets.hCALL scripts/checksyscalls.shHOSTCC scripts/dtc/checks.oHOSTCC scripts/dtc/data.o...HOSTCC scripts/conmakehashHOSTCC scripts/recordmcountCC init/main.oCHK include/generated/compile.hUPD include/generated/compile.hCC init/version.oCC init/do_mounts.oCC init/do_mounts_rd.oCC init/do_mounts_initrd.oLD init/mounts.oCC init/initramfs.oCC init/calibrate.oLD init/built-in.o...AR lib/lib.aLD vmlinux.oMODPOST vmlinux.oGEN .versionCHK include/generated/compile.hUPD include/generated/compile.hCC init/version.oLD init/built-in.oLD .tmp_vmlinux1KSYM .tmp_kallsyms1.SAS .tmp_kallsyms1.oLD .tmp_vmlinux2KSYM .tmp_kallsyms2.SAS .tmp_kallsyms2.oLD vmlinuxSYSMAP System.mapSYSMAP .tmp_System.mapOBJCOPY arch/arm/boot/ImageKernel: arch/arm/boot/Image is readyAS arch/arm/boot/compressed/head.oGZIP arch/arm/boot/compressed/piggy.gzipAS arch/arm/boot/compressed/piggy.gzip.oCC arch/arm/boot/compressed/misc.oCC arch/arm/boot/compressed/decompress.oCC arch/arm/boot/compressed/string.oAS arch/arm/boot/compressed/lib1funcs.oAS arch/arm/boot/compressed/ashldi3.oLD arch/arm/boot/compressed/vmlinuxOBJCOPY arch/arm/boot/zImageKernel: arch/arm/boot/zImage is readyDTC arch/arm/boot/msm8974-hammerhead-rev-11.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-11j.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-10.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-c.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-b.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-bn.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-a.dtbDTC arch/arm/boot/msm8974-hammerhead-rev-f.dtbCAT arch/arm/boot/zImage-dtbKernel: arch/arm/boot/zImage-dtb is readymake[1]:没有什么可以做的为`arch/arm/boot/dtbs。简单分析一下,大致做了这么几件事情:
而我们最终需要的文件就是 zImage-dtb(注意:这里没有生成内核模块,因为所有的内核功能都被配置为 built-in ,编译进 zImage-dtb 了)。
- 根据配置信息,生成了一些头文件
- 编译了一些小工具
- 根据配置信息,有选择性地编译一些源码,将输出的 obj 链接成对应的 built-in.o
- 生成符号表文件
- 将所有的 built-in.o 和符号表链接成内核 vmlinux
- 使用 BOJCOPY 从 vmlinux 生成 Image
- 生成压缩过的内核 arch/arm/boot/compressed/vmlinux
- 使用 OBJCOPY 从 压缩过的内核 vmlinux 生成 zImage
- 生成 dtb(device tree blob)
- 将 zImage 和 dtb 连接成一个文件:zImage-dtb
要点分析
内核配置和编译,依靠的是 make 和 kbuild 系统。无论是 make 还是 kbuild,都只是工具,我们并不一定要完全弄清其内部工作原理,只需要熟悉和工作相关的部分即可。
这里涉及到的有如下几点:
- vml
ArmLinuxKernel情景分 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)