最新uboot的Kbuild系统 3 .config的生成

来源:互联网 发布:淘宝怎么上怎么刷信用 编辑:程序博客网 时间:2024/04/30 00:04

前面的工作产生了一个conf

关键点是由conf产生.config的过程

最后是通过执行

scripts/kconfig/conf  --defconfig=arch/../configs/rpi_defconfig Kconfig 生成的


Kconfig包含了当前目录中可以进行的一些配置信息。

rpi_defconfig包含了默认的配置信息。

conf根据rpi_defconfig的一些配置,参考Kconfig产生最终的.config

如果是make menuconfig。那么就直接读取Kconfig。用户通过界面来配置产生.config


conf通过

conf_parse(Kconfig);来解析可选的配置信息,保存到一个链表中。

随后通过

conf_read(rpi_defconfig)读取默认的设置文件,并且生成新的配置文件

调用

conf_set_all_new_symbols更新关系链表

最后调用

conf_write写入到.config中


首先看Kconfig的构成


Kconfig的基本构成是

1 config项目

config symbolname

options

symbolname 配置名称,options是选项


config LOCALVERSION_AUTO
bool "Automatically append version information to the version string"
default y
help
 This will try to automatically determine if the current tree is a
 release tree by looking for Git tags that belong to the current
 top of tree revision.

LOCALVERSION_AUTO 就是配置名称



bool是变量类型,变量类型有五种。

分别是bool string tristate int hex

bool 只能是y或者n (选择或者不选择)

tristate 可以是y n m (选择或者不选择或者编译为模块)

string就是字符串


"Automatically append version information to the version string"  就是对于该菜单的简单描述。同promote选项

比如

bool "config for cpu"

bool

promote "config for cpu"是一个意思




default y 表示默认是选中y的


help 的内容是详细的解释。在menuconfig的时候使用使用?可以打开帮助


depend on XXX 表示只有XXX配置被选中的时候,当前选项才能够被配置。




2menu项目

通常是

menu  "menu A"

config cfgA

......

config cfgB

....

endmenu


显示后就是

menu--->

[] cfgA 

[] cfgB


3choice选项

choice包含了一组可以被选择的集合,选择只能是bool和tristate类型。并且不能同时存在两种。是bool就全部是bool。是tristate就都是tristate

也就是所有的choice里面bool只选中某一种。



choice

promote "select cpu"

config A

bool "cpu A"

config B

bool "cpu B"

config C

bool "cpu C"

endchoice

那么就是可以选择一个合适的cpu

select cpu---> (cpu A cpu B cpu C)




4 select 选项是反向依赖 dependson是正向依赖

dependson XXX 是如果该选项可以被配置,前提是XXX已经被选中。

而select XXX是如果选中了该选项。那么XXX选项也被选中。









后续menuconfig或者conf qconf 等根据用户选择或者xxx_defconfig将这些选项写入.config文件中

配置后的.confg文件将根据不同的选项分别写入。写入的时候在配置名称前面加上CONFIG_


比如

config ARM

bool

default y

写入.config以后就变成了

CONFIG_ARM=y

还有 CONFIG_MODULEA=m 表明该配置MODULEB被配置编译到模块中

CONFIG_XXX=n或者没有这个配置就表示选择为n


而string就变成了

CONFIG_SYS_ARCH="arm"
CONFIG_SYS_CPU="arm1176"
CONFIG_SYS_SOC="bcm283x"
CONFIG_SYS_VENDOR="raspberrypi"


int变成了

CONFIG_SYS_MALLOC_F_LEN=0x400


所以conf也就是根据rpi_defconfig以及各个目录以及Kconfig里面的一些默认配置,最后产生.config

CONFIG_ARM=y
CONFIG_ARCH_BCM283X=y
CONFIG_TARGET_RPI=y
CONFIG_OF_BOARD_SETUP=y
CONFIG_HUSH_PARSER=y
CONFIG_SYS_PROMPT="U-Boot> "
CONFIG_CMD_BOOTZ=y
# CONFIG_CMD_IMLS is not set
# CONFIG_CMD_FLASH is not set
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
# CONFIG_CMD_FPGA is not set
CONFIG_CMD_GPIO=y
CONFIG_CMD_DHCP=y
CONFIG_CMD_MII=y
CONFIG_CMD_PING=y
CONFIG_CMD_EXT2=y
CONFIG_CMD_EXT4=y
CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_USB=y
CONFIG_USB_STORAGE=y
CONFIG_PHYS_TO_BUS=y
CONFIG_OF_LIBFDT=y

比如根据 TARGET_RPI

config TARGET_RPI
bool "Raspberry Pi (all BCM2835 variants)"
help
 Support for all ARM1176-/BCM2835-based Raspberry Pi variants, such as
 the A, A+, B, B+, Compute Module, and Zero. This option cannot
 support BCM2836/BCM2837-based Raspberry Pis such as the RPi 2 and
 RPi 3 due to different peripheral address maps.


 This option creates a build targetting the ARM1176 ISA.
select BCM2835

自动选中了BCM2835

config BCM2835
bool "Broadcom BCM2835 SoC support"
depends on ARCH_BCM283X
select CPU_ARM1176

随后自动选择了CPU_ARM_1176,又由于依赖了 ARCH_BCM283X。rpi_defconfg中还有一个配置CONFIG_ARCH_BCM283X=y


.config就是这样生成的。至于conf由于功能不变。所以就不解析了,东西太多,只要看成一个黑盒子,作用就是按照一定的规则将defconfig和Kbuild输入变成.config输出就行了 ,这个规则就是kconfig的规则。



0 0