最新uboot的Kbuild系统 3 .config的生成
前面的工作產生了一個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的規則。
總結
以上是生活随笔為你收集整理的最新uboot的Kbuild系统 3 .config的生成的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 撸代码更有劲了(这应该算是福利吧)
- 下一篇: 移动互联网关键技术