How to: Kconfig
This chapter will demonstrate how to use Kconfig in your project.
Kconfig is a system inherited from the Linux kernel to the Zephyr project. It allows the definition of build-time options (also called symbols), their types, constraints, and relationships.
You can define your custom Kconfig option in your application by creating the
Kconfig file in the application root directory.
Kconfig file, you can create a boolean yes/no option using this template:
bool "Enable bar"
menu "Zephyr Kernel"
This will create a menu tree called
Application. The tree will have one option
APP_FOO, which is enabled by default, and can be disabled in your
When pre-processing all Kconfig options, this will result in one of these macros:
/* When CONFIG_APP_FOO=y */
#define CONFIG_APP_FOO 1
/* When CONFIG_APP_FOO=n */
#define CONFIG_APP_FOO 0
You can debug the generated Kconfig options by looking into the file
build/zephyr/include/autoconf.h. This file is automatically injected into all source/header files.
If you need more details on Kconfig, see the Zephyr Kconfig documentation: https://docs.zephyrproject.org/latest/build/kconfig/index.html