Zephyr uses Kconfig as its primary configuration system to control which features are enabled, how subsystems behave, and how the final firmware image is built. Instead of hardcoding feature choices into source files, developers can use Kconfig to manage configuration in a structured and scalable way, making it easier to adapt applications across boards and use cases. Zephyr applications often need to enable features such as logging, networking, or debugging support while keeping unnecessary code out of the final firmware.
- Each feature, such as a driver, network stack, or logging option, is controlled by a CONFIG_ setting.
- These CONFIG_ settings are enabled or configured in the prj.conf file
The file prj.conf defines project-specific configuration options by setting Kconfig symbols that enable, disable, or customize Zephyr features, drivers, subsystems, and build settings.
Provides the common SoC-level support used by STM32xx-based boards, including Kconfig definitions and defaults, CMake build integration, early SoC initialization, shared headers, and power-management or power-off functionality. It contains code and configuration that are specific to the STM32xx family but shared across multiple STM32xx boards.
└── zephyr/
└── soc/st/stm32/
└── stm32f4x/
├── CMakeLists.txt
├── Kconfig
├── Kconfig.defconfig
├── Kconfig.soc
├── power.c
├── poweroff.c
├── soc.c
└── soc.h
└── stm32f7x/
├── CMakeLists.txt
├── Kconfig
├── Kconfig.defconfig
├── Kconfig.defconfig.stm32f765xx
├── Kconfig.defconfig.stm32f767xx
├── Kconfig.defconfig.stm32f769xx
├── Kconfig.soc
├── soc.c
└── soc.h
└── stm32h7x/
├── CMakeLists.txt
├── Kconfig
├── Kconfig.defconfig
├── Kconfig
├── Kconfig.defconfig.stm32h745xx
├── Kconfig.defconfig.stm32h747xx
├── Kconfig.defconfig.stm32h755xx
├── Kconfig.defconfig.stm32h757xx
├── Kconfig.soc
├── mpu_regions.c
├── sections.ld
├── soc_m4.c
├── soc_m7.c
└── soc.h # GPIO
CONFIG_GPIO=y
# ADC
CONFIG_ADC=y
# I2C
CONFIG_I2C=y
# Serial / UART
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# Console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
# Logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_LOG_MODE_DEFERRED=y
CONFIG_LOG_PROCESS_THREAD=y
CONFIG_ASSERT=y
# C Library
CONFIG_MINIMAL_LIBC=y
CONFIG_PICOLIBC=n
CONFIG_NEWLIB_LIBC=n
# Increase the main thread stack size
CONFIG_MAIN_STACK_SIZE=4096
- CMakeLists.txt: Connects the project to Zephyr’s build system
- Kconfig: Defines application options, their types, defaults, and dependencies
- prj.conf: Configures application, Zephyr, and module features by setting option values
- extra.conf: Optional Kconfig configuration fragment used to add or override settings in prj.conf for a particular build
- <board_name>.conf: Board-specific Kconfig settings
- <board_name>.overlay: Board-specific Devicetree hardware changes
└── apps/
└── project_1
├── CMakeLists.txt
├── Kconfig
├── prj.conf
├── extra_1.conf
├── extra_2.conf
└── boards/
├── <board_name_1>.conf
├── <board_name_1>.overlay
├── <board_name_2>.conf
└── <board_name_2>.overlay
└── src/
└── main.cWhen a Zephyr application is built, the build system first runs the Kconfig configuration phase. During this phase:
- Load Kconfig definitions from Zephyr, modules, and the application
- Load board defaults from <BOARD>_defconfig
- Merge application settings from prj.conf, followed by additional <FRAGMENT>.conf fragments
- Resolve Kconfig defaults, dependencies, and symbol selections
- Save the resolved configuration to .config
- Generate autoconf.h with configuration macros used during compilation
# The resulting configuration is stored in:
<build-dir>/zephyr/.config
# The build system also generates:
<build-dir>/zephyr/include/generated/zephyr/autoconf.h
[1] Zephyr Configuration System (Kconfig)
[2] Zephyr: Setting Kconfig Configuration Values
Back to top of the page