Chapter 2. API Reference
2.8 Project Configuration
2.8.1 Introduction
ESP-IDF uses
kconfiglib
which is a Python-based extension to the
project configuration mechanism. Kconfig is based around options of several types: integer, string, boolean. Kconfig
files specify dependencies between options, default values of the options, the way the options are grouped together,
etc.
For the complete list of available features please see
2.8.2 Project Configuration Menu
Application developers can open a terminal-based project configuration menu with the idf.py menuconfig
build target.
After being updated, this configuration is saved inside sdkconfig file in the project root directory. Based on sd-
kconfig, application build targets will generate sdkconfig.h file in the build directory, and will make sdkconfig
options available to the project build system and source files.
(For the legacy GNU Make build system, the project configuration menu is opened with make menuconfig.)
2.8.3 Using sdkconfig.defaults
In some cases, such as when sdkconfig file is under revision control, the fact that sdkconfig file gets changed
by the build system may be inconvenient. The build system offers a way to avoid this, in the form of sdkconfig.
defaults file. This file is never touched by the build system, and must be created manually. It can contain all
the options which matter for the given application. The format is the same as that of the sdkconfig file. Once
sdkconfig.defaults is created, sdkconfig can be deleted and added to the ignore list of the revision control
system (e.g. .gitignore file for git). Project build targets will automatically create sdkconfig file, populated
with the settings from sdkconfig.defaults file, and the rest of the settings will be set to their default values.
Note that the build process will not override settings that are already in sdkconfig by ones from sdkconfig.
defaults. For more information, see
2.8.4 Kconfig Formatting Rules
The following attributes of Kconfig files are standardized:
• Within any menu, option names should have a consistent prefix. The prefix length is currently set to at least 3
characters.
• The indentation style is 4 characters created by spaces. All sub-items belonging to a parent item are indented
by one level deeper. For example, menu is indented by 0 characters, the config inside of the menu by 4
characters, the help of the config by 8 characters and the text of the help by 12 characters.
• No trailing spaces are allowed at the end of the lines.
• The maximum length of options is set to 40 characters.
• The maximum length of lines is set to 120 characters.
• Lines cannot be wrapped by backslash (because there is a bug in earlier versions of conf-idf which causes
that Windows line endings are not recognized after a backslash).
Format checker
tools/check_kconfigs.py is provided for checking the Kconfig formatting rules. The checker checks all
Kconfig and Kconfig.projbuild files in the ESP-IDF directory and generates a new file with suffix .new
with some recommendations how to fix issues (if there are any). Please note that the checker cannot correct all
rules and the responsibility of the developer is to check and make final corrections in order to pass the tests. For
Espressif Systems
Kconfig
and
kconfiglib
Custom sdkconfig
defaults.
1058
Submit Document Feedback
Kconfig
system which provides a compile-time
extentions.
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?