编译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 ...
随机推荐
- @RequestParam
@MVC另外一个特性是其提取和解析请求参数的能力.让我们继续重构上面的方法,并在其中添加@RequestParam注解: @RequestMapping("/accounts/show&qu ...
- JavaEE Tutorials (5) - 运行企业bean示例
5.1cart示例56 5.1.1业务接口57 5.1.2会话bean类57 5.1.3@Remove方法61 5.1.4辅助类61 5.1.5运行cart示例615.2一个单例会话bean示例:co ...
- 1104--DNA排序
问题描述: 逆序数可以用来描述一个序列混乱程度的量.例如,“DAABEC”的逆序数为5,其中D大于它右边的4个数·,E大于它右边的1的个数,4+1=5,又如,“ZWQM”的逆序数为3+2+1+0=6. ...
- 给EditText中的图片加监听
package com.example.helloword; import android.app.Activity; import android.content.Context; import a ...
- Surround the Trees(凸包求周长)
Surround the Trees Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- APUE学习笔记——10.15 sigsetjmp和siglongjmp
转载自:sigsetjmp使用方法 如侵犯您的权益,请联系:windeal12@qq.com sigsetjmp使用方法 分类: c/c++ linux2012-02-03 12:33 1252人阅读 ...
- 用AS3清空容器下所有子显示对象
容器中的子显示对象分为两类: 处于显示列表中的子显示对象.被numChildren所记录的. 由容器graphics对象绘制出来的矢量图.这个矢量图不属于Shape类型,不在容器的显示列表中,不被nu ...
- c++,纯虚函数与抽象类
1.纯虚函数的定义: (1)虚函数被“初始化”为0的函数.声明纯虚函数的一般形式是virtual 函数类型 函数名(参数表列) =0;(2)纯虚函数没有函数体:(3)最后面的“=0”并不表示函数返回值 ...
- The Hungarian algorithm Template
The Hungarian algorithm with The adjacency matrix : 计算最大匹配问题 int n1, n2, m, ans; int res[MAXN]; bool ...
- 字符串如何判断null.
转http://blog.sina.com.cn/s/blog_48cd37140101awgq.html Java中判断String不为空的问题 一.判断一个字符串str不为空的方法有: 1. st ...