运行基于终端的menuconfig界面
#进入zephyr的根目录下
west build -t menuconfig
或者
#进入zephyr根目录下生成的build目录下
ninja menuconfig
注意前提是一定要有应用程序编译了,才能打开界面
运行图形用户界面guiconfig
#进入zephyr的根目录下
west build -t guiconfig
或者
#进入zephyr根目录下生成的build目录下
ninja guiconfig
1、source
用于调用其它路径下的Kconfig
source "xxx/Kconfig"
eg: source "arch/Kconfig" /*也就是引用arch文件下的Kconfig*/
source "boards/Kconfig"
source "soc/Kconfig"
source "arch/Kconfig"
source "kernel/Kconfig"
source "dts/Kconfig"
source "drivers/Kconfig"
source "lib/Kconfig"
source "subsys/Kconfig"
2、menu和endmenu
menu用于生成菜单,endmenu菜单结束标志,两者一般成对出现;
例如:
menu "Compatibility"
config COMPAT_INCLUDES
bool "Suppress warnings when using header shims"
default y
help
Suppress any warnings from the pre-processor when including
deprecated header files.
endmenu
menu "Modules"
source "modules/Kconfig"
endmenu
3、config
比如在modules/Kconfig.civetweb中:
config CIVETWEB
bool "Civetweb Support" /*bool类型*/
# The CONFIG_NET_TCP_ISN_RFC6528 option would pull in mbedtls,
# and there are include file issues if CONFIG_POSIX_API is set.
# Because Civetweb sets the POSIX API option in the samples,
# make sure that we do not try to use Civetweb if the TCP ISN
# option is set.
depends on !NET_TCP_ISN_RFC6528
help
This option enables the civetweb HTTP API.
在modules/Kconfig.telink
config HAS_TELINK_DRIVERS
bool "Telink Drivers"
help
This option enables Telink Drivers APIs.
在menuconfig界面中可以看到
[]表示bool,通过键入Y/N选择使能/禁止(通过Enter也可以选择或取消)
类型可以是bool、 tristate、 string、 hex 和 int
常见的是bool、string、tristate
bool类型有两种值:y和n,分别表示使能这个配置项,n表示禁止使用这个配置项;
string类型为字符串;
tristate类型有三种:y、m、n,其中y、n与bool含义相同,m表示将这个配置项编译为模块。
help 表示帮助信息,当我们按“?”时会弹出相关解释。以modules/Kconfig.civetweb为例:
4、depends on与select
depends on表示一种依赖关系,比如在顶层Kconfig.zephyr中:
config CUSTOM_LINKER_SCRIPT
string "Path to custom linker script"
depends on HAVE_CUSTOM_LINKER_SCRIPT
help
表示CUSTOM_LINKER_SCRIPT依赖于HAVE_CUSTOM_LINKER_SCRIPT,只有HAVE_CUSTOM_LINKER_SCRIPT被选中,CUSTOM_LINKER_SCRIPT才能被选中。
select表示选择,比如:
config BOOTLOADER_BOSSA
bool "BOSSA bootloader support"
select USE_DT_CODE_PARTITION
表示选中BOOTLOADER_BOSSA时,也会选中USE_DT_CODE_PARTITION。
5、choice与endchoice
将多个类似的配置项组合在一起,然后用户可以在menuconfig界面中进行选择:
在zephyr顶层的Kconfig.zephyr中
menu "Build and Link Features"
menu "Linker Options"
choice
prompt "Linker Orphan Section Handling"
default LINKER_ORPHAN_SECTION_WARN
config LINKER_ORPHAN_SECTION_PLACE
bool "Place"
config LINKER_ORPHAN_SECTION_WARN
bool "Warn"
config LINKER_ORPHAN_SECTION_ERROR
bool "Error"
endchoice
6、comment
menuconfig界面注释,比如zephyr-zephyr-v3.0.0\drivers\serial\Kconfig
comment "Capabilities"
...
config SERIAL_INIT_PRIORITY
int "Serial init priority"
default KERNEL_INIT_PRIORITY_DEVICE
config UART_USE_RUNTIME_CONFIGURE
bool "Enable runtime configuration for UART controllers
config UART_ASYNC_API
bool "Enable asynchronous UART API"
depends on SERIAL_SUPPORT_ASYNC
...
comment "Serial Drivers"
...
source "drivers/serial/Kconfig.ns16550"
...
source "drivers/serial/Kconfig.it8xxx2"