Note: This article is based on u-boot.2016.03.
1. Device driver menu configuration
root/drivers/Kconfig
menu "Device Drivers" #菜单项(开始),这个名字会在图形界面的最上面显示
source "drivers/core/Kconfig" #把下级目录的kconfig文件给包含进来,会在原地展开
# types of drivers sorted in alphabetical order #注示,表明这些菜单是按字母排序的
source "drivers/adc/Kconfig"
source "drivers/block/Kconfig"
source "drivers/clk/Kconfig"
source "drivers/cpu/Kconfig"
source "drivers/crypto/Kconfig"
source "drivers/demo/Kconfig"
source "drivers/dfu/Kconfig"
source "drivers/dma/Kconfig"
source "drivers/gpio/Kconfig"
source "drivers/hwmon/Kconfig"
source "drivers/i2c/Kconfig"
source "drivers/input/Kconfig"
source "drivers/led/Kconfig"
source "drivers/misc/Kconfig"
source "drivers/mmc/Kconfig"
source "drivers/mtd/Kconfig"
source "drivers/net/Kconfig"
source "drivers/pci/Kconfig"
source "drivers/pcmcia/Kconfig"
source "drivers/pinctrl/Kconfig"
source "drivers/power/Kconfig"
source "drivers/pwm/Kconfig"
source "drivers/ram/Kconfig"
source "drivers/remoteproc/Kconfig"
source "drivers/rtc/Kconfig"
source "drivers/serial/Kconfig"
source "drivers/sound/Kconfig"
source "drivers/spi/Kconfig"
source "drivers/thermal/Kconfig"
source "drivers/timer/Kconfig"
source "drivers/tpm/Kconfig"
source "drivers/usb/Kconfig"
source "drivers/video/Kconfig"
source "drivers/watchdog/Kconfig"
config PHYS_TO_BUS #配置项 会自动在这个名称的前面加上“CONFIG_”
bool "Custom physical to bus address mapping"#用户可见的提示信息,bool表示,可以选择编进内核或不编译,只能选中或不选中。
help#帮助信息,这个信息可以在界面的底部选择并展开
Some SoCs use a different address map for CPU physical addresses and
peripheral DMA master accesses. If yours does, select this option in
your platform's Kconfig, and implement the appropriate mapping
functions in your platform's support code.
endmenu #菜单(结束)
u-boot.2016.03, the device driver configuration interface of make menuconfig.
2. Kconfig configuration type syntax
Tristate:
Indicates whether the item is compiled into the kernel or as a module. Shown as <>, if you choose to compile into a kernel module, a configuration with CONFIG_HELLO_MODULE=m will be generated in .config, and if you choose Y, it will be directly compiled into the kernel, and a configuration item with CONFIG_HELLO_MODULE=y will be generated in .config. The string after Tristate is the name of the configuration item displayed during make menuconfig.
bool:
This type can only be selected or not. It is displayed as [] when make menuconfig, that is, it cannot be configured as a module.
depended on:
This option depends on another option. Only when the dependent item is selected, the prompt message of the current configuration item will appear, and the current configuration item can be set.
select:
Reverse dependency. When this option is selected, the item defined after select is selected at the same time. You can see it in the help information.
3. The relationship between makefile and Kconfig
After using the Kbuild system, the Makefile of the subdirectory is relatively simple, which is used to define what content is compiled as a module and which conditional compilation is just fine.
A: Direct compilation
obj-y + = xxx.o
It means that xxx.o is compiled by xxx.c or xxx.s and compiled directly into the kernel.
B: Conditional compilation
obj -$(CONFIG_HELLO) +=xxx.o
According to the CONFIG_XXX of the .config file, determine whether the file is compiled into the kernel.
C: Module compilation
obj-m +=xxx.o
Indicates that xxx is compiled as a module, that is, it will be compiled when make modules is executed.
The relationship between the three files is as follows:
root/.config
root/drivers/adc/makefile
root/drivers/adc/kconfig