编译内核文件 Kconfig .config 和 Makefile 之间的联系

在内核编译时,主Makefile调用 .config文件来获取用户的选择。

 

.config的内容是基于各个Kconfig配置文件以及平台配置文件,由 make menuconfig 和 make firefly_deconfig 的结果。

每个Kconfig描述了所属目录的源文件的相关内核配置;

每个平台配置文件描述了该平台所支持到基本配置;

Kconfig 菜单项类型:

1. bool 布尔类型               选择是或非;

2. tristate 三态                   内建,模块,移除;

3. string 字符串      hex十六进制       integer 整型;

以drivers/rtc/Kconfig 中的源码为例:

/* bool 类型,默认选择是 */
config RTC_HCTOSYS
    bool "Set system time from RTC on startup and resume"
    default y
    help
      If you say yes here, the system time (wall clock) will be set using
      the value read from a specified RTC device. This is useful to avoid
      unnecessary fsck runs at boot time, and to network better.

/*rk808 模块配置*/
config RTC_DRV_RK808                                                                                                                           
    tristate "Rockchip RK808 RTC"
    depends on MFD_RK808
    help
      If you say yes here you will get support for the
      RTC of RK808 PMIC.

      This driver can also be built as a module. If so, the module
      will be called rk808-rtc.

在编译内核的模块时,将模块的编译划分为三类,对应于Kconfig 中 tristate类,内建,模块,移除

在Makefile文件中:

obj-y    代表以静态的方式编译进内核中

obj-m   代表模块化编译进内核

obj-      代表不被编译(一般不作配置默认为不编译该模块)

其中,obj -y +=rk808.o 相当于 obj -$(RTC_DRV_RK808) +=rk808.o (Makefile中模块的编译)

总结:

 .config 基于 Kconfig 和 平台配置文件生成 ,Makefile 调用 .config 编译内核,三者之间的宏都打开才能被编译。

下面贴出一个编译脚本来体现内核编译步骤:

#!/bin/bash

export ARCH=arm
export PATH=$PATH:/opt/arm-eabi-4.8/bin
export CROSS_COMPILE=arm-eabi-

make firefly_deconfig  /* 先编译平台配置文件 */
make firefly.img

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Caso_卡索

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值