编译kernel:编译
韦东山Linux视频第1期_裸板_UBoot_文件系统_驱动初步第10课第3节 内核启动流程分析之Makefile.WMV
1. 编译内核分三步:
make xxx_defconfig [linux/arch/arm/configs/s3c2410_defconfig]
make menuconfig 或者使用厂商配置好的ok_config即可, cp ok_config linux/.config
执行该命令时,从Kconfig里面读取菜单选项,形成可视化菜单。 执行后,根据用户自己配置,改写 .config文件。如果厂商已经配置好ok_config,可以不经过这一步选配,直接拷贝过来即可,cp ok_config linux/.config.
到此时, 生成了几个.cmd文件和.c以及.config,从而指导后面的编译选择.【各级子Makefile一般根据.config 里面的宏定义选项,选择是否编译以及是否编译为模块 。】
试下make distclean{
CLEAN scripts/basic
CLEAN scripts/kconfig
CLEAN include/config
CLEAN .config
}
make
主Makefile以及各级Makefile 引用.config 里面的宏定义选项(同时还要引用各级写好的Kbuild/kconfig),生成宏定义头文件( 如 /include/linux/autoconf.h :#define CONFIG_ARM 1 )并编译内核。
==================================================
2. 根据Makefile, vmlinux.lds文件,分析编译文件是哪些:
/* linux-2.6.22.6\arch\arm\Makefile */
zImage Image xipImage bootpImage uImage: vmlinux /* linux-2.6.22.6\Makefile ; include $(srctree)/arch/$(ARCH)/Makefile*/
all: vmlinux
vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE >>>
vmlinux-lds := arch/$(ARCH)/kernel/vmlinux.lds
{
lds和代码分析示例: in lds:
.text.head : {
_stext = .;
_sinittext = .;
*(.text.head)
} in head.S:
.section ".text.head", "ax"
.type stext, %function
code...
} vmlinux-init := $(head-y) $(init-y)
{
head-y := arch/arm/kernel/head.o arch/arm/kernel/init_task.o /* linux-2.6.22.6\arch\arm\Makefile */
init-y := init/built-in.o ; /*init/文件夹下面的所有代码被编译成init/built-in.o */
} vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y)
{
core-y := usr/built-in.o kernel/built-in.o mm/built-in.o fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o block/built-in.o
libs-y := $(libs-y1) $(libs-y2)
libs-y1 := lib/lib.a
libs-y2 := lib/built-in.o
drivers-y := drivers/built-in.o sound/built-in.o
net-y := net/built-in.o
}
==================================================
3. 关于编译选项的格式:
.如果一个驱动直接编译进内核,直接按照以下方式书写:
obj-y += generic_serial.o vme_scc.o
obj-y += a.o
.如果一个驱动要编译成模块,且一个模块由1个源文件编译而成:
obj-m += a.o
.如果一个驱动要编译成模块,且一个模块由多个源文件编译而成, 其编译过程为:
obj-m += ab.o
ab-objs := a.o b.o
编译过程:
a.c -> a.o
b.c -> b.o
a.o b.o -> ab.o -> ab.ko
参考:\linux-2.6.22.6\Documentation\kbuild
Example:
#drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN) += isdn.o
isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o $(obj-m) specify object files which are built as loadable
kernel modules. A module may be built from one source file or several source
files. In the case of one source file, the kbuild makefile
simply adds the file to $(obj-m). Example:
#drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' If a kernel module is built from several source files, you specify
that you want to build a module in the same way as above. Kbuild needs to know which the parts that you want to build your
module from, so you have to tell it by setting an
$(<module_name>-objs) variable. Example:
#drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN) += isdn.o
isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o In this example, the module name will be isdn.o. Kbuild will
compile the objects listed in $(isdn-objs) and then run
"$(LD) -r" on the list of these files to generate isdn.o.
编译kernel:编译的更多相关文章
- hi3531 SDK 编译 kernel, 修改 参数
开发环境用户指南上这么写的 3.1 内核源代码 成功安装Hi3531 SDK后,内核源代码已存放于SDK目录下的osdrv/目录中,用户可 直接进入目录进行相关操作. 3.2 配置内核 如果对内核和H ...
- am335x uboot, kernel 编译
一.设置环境变量 // 写在家目录下面的 .bashrc 里面 export KERNEL_PATH=~/aplex/kernel3.2.0 // kernel 路径 export UBOOT_PAT ...
- I.MX6 linux kernel编译错误处理
/******************************************************************************** * I.MX6 linux kern ...
- Android6.0内核移植(2):kernel编译内核
普通步骤是:用来编译整个Android源码 source build/envsetup.sh lunch sabresd_6dq-user make -j20 不过每次这样太繁琐,下面来单独编译ker ...
- linux 编译kernel与svn版本冲突解决方法 [drivers/gpu/mali/mali/common/mali_kernel_core.o] 错误 1
问题: 系统正常编译linux系统kernel,安装svn后,kernel编译出错. 错误: CHK include/linux/version.h CHK include/gene ...
- JIT(动态编译)和AOT(静态编译)编译技术比较
Java 应用程序的性能经常成为开发社区中的讨论热点.因为该语言的设计初衷是使用解释的方式支持应用程序的可移植性目标,早期 Java 运行时所提供的性能级别远低于 C 和 C++ 之类的编译语言.尽管 ...
- 预编译加速编译(precompiled_header),指定临时文件生成目录,使项目文件夹更干净(MOC_DIR,RCC_DIR, UI_DIR, OBJECTS_DIR),#pragma execution_character_set("UTF-8")"这个命令是在编译时产生作用的,而不是运行时
预编译加速编译 QT也可以像VS那样使用预编译头文件来加速编译器的编译速度.首先在.pro文件中加入: CONFIG += precompiled_header 然后定义需要预编译的头文件: PREC ...
- apktool 反编译 回编译
下载apktool 安装好Java环境 拷贝apk 拷贝game.apk到当前文件夹.apk随便指定 反编译 反编译完成.生成game目录 game目录内容 回编译 回编译完成.生成build和dis ...
- Apache 安装 静态编译 动态编译
2014-09-19 09:53 (分类:Linux) 排名第一的web服务器. (linux环境:CentOS release 6.5 (Final)) 安装出错:如下 configure: err ...
- Build Android-x86 ICS 4 Virtualbox from Google Virtualbox Target and Intel Kernel 编译体验
最近一直在研究android源码的编译,应该说研究的很辛苦,最难的是下源码,总是不停的断掉,最后感谢公司的高网速,找到方法后12G的源码只花了1个小时就下完了. 参考以下网址:http://softw ...
随机推荐
- fieldset效果
<form> <fieldset> <legend>健康信息</legend> 身高:<input type="text" / ...
- day1作业脚本
1.编写登录接口: - 输入用户名和密码 - 认证成功后显示欢迎信息 - 输错三次后锁定 2.编写多级菜单 - 三级菜单 - 可依次进入子菜单 第一次写python脚本,因为没有学到函数,所以写的有点 ...
- Python3 将configparser从ini文件中读取的内容转换成字典格式
因为写脚本的用到了,所以研究了下怎么将configparser从ini文件中读取的内容转换成字典格式. 整理一下,希望能对大家有帮助. 从http://stackoverflow.com/questi ...
- ios7状态栏属性的设置
/* 状态栏的管理: 1> iOS7之前:UIApplication进行管理 2> iOS7开始:交给对应的控制器去管理 */ // 设置状态栏的样式 - (UIStatusBarStyl ...
- UVA 1619 Feel Good(DP)
Bill is developing a new mathematical theory for human emotions. His recent investigations are dedic ...
- Automatic Preferred Max Layout Width is not available on iOS versions prior to 8.0
今天在真机调试低版本系统的时候出现如题类似Layout Max Width在ios 8 之前不适用的问题, 初步估计是autolayout 所导致的 查找资料解决方法如下: 将label下Preffe ...
- c++隐藏实例
隐藏:是指派生类的函数屏蔽了与其同名的基类函数,规则如下:(1)如果派生类的函数与基类的函数同名,但是参数不同.此时,不论有无virtual关键字,基类的函数将被隐藏(注意别与重载混淆). 很简单略去 ...
- 应用之间进行跳转,ComponentName的方式
从应用A跳转到应用B, 关键代码如下: 有以下几个注意点: 1.ComponentName cn = new ComponentName("com.terry", "co ...
- Easyui datagrid 批量编辑和提交
<script type="text/javascript"> $(function() { var $dg = $("#dg"); $dg.dat ...
- CodeForces 276D – Little Girl and Maximum XOR 贪心
整整10个月后第二次搞这个问题才搞懂........第一次还是太随意了. 解题思路: 经过打表可得规律答案要么是0 要么是2的N次 - 1 要得到最大的XOR值,其值一定是2的N次 - 1 即在 l ...