Kconfig syntax error on set default
Posted: Sat Dec 27, 2025 7:30 pm
I'm trying to use the set default construct in my Kconfig.projbuild file, but getting the error esp-idf kconfig error couldn't parse set default syntax error.
The set default construct is defined in the online Kconfig documentation:
https://docs.espressif.com/projects/esp ... lt-options
I've tried several things to troubleshoot the syntax error, and here is my ESP-IDF 5.5.1 command:
Diagnosis
It seems there are two version of Kconfig used by ESP-IDF, the versions v2 and v3. Maybe v3 added the set default construct, and maybe ESP-IDF 5.5.1 by default only uses v2?
Question
If the set default construct is only available in Kconfig v3 and later, then how can I force my ESP-IDF installation to use Kconfig v3 instead of v2?
Workaround
I only need the set default construct to build a configuration for several device models, is there another way to do this?
The set default construct is defined in the online Kconfig documentation:
Code: Select all
set_default ::= "set default" + assignment [+ "if" + expression ]https://docs.espressif.com/projects/esp ... lt-options
I've tried several things to troubleshoot the syntax error, and here is my ESP-IDF 5.5.1 command:
Code: Select all
user@host:~/myproj$ idf.py menuconfig
Executing action: menuconfig
Running ninja in directory /home/user/myproj/build
Executing "ninja menuconfig"...
kconfiglib.core.KconfigError: /home/user/myproj/main/Kconfig.projbuild:53: error: couldn't parse 'set default APP_I2C_GPIO_SCL=21': syntax error
CMake Error at /home/user/myproj/esp-idf-551/tools/cmake/kconfig.cmake:237 (message):
Failed to run kconfgen
-- Configuring incomplete, errors occurred!
FAILED: build.ninjaIt seems there are two version of Kconfig used by ESP-IDF, the versions v2 and v3. Maybe v3 added the set default construct, and maybe ESP-IDF 5.5.1 by default only uses v2?
Question
If the set default construct is only available in Kconfig v3 and later, then how can I force my ESP-IDF installation to use Kconfig v3 instead of v2?
Workaround
I only need the set default construct to build a configuration for several device models, is there another way to do this?
Code: Select all
menu "Device Version"
help
Select the hardware revision of the device.
comment "Find the hardware revision number on the back of the PCB."
config APP_HW_VERSION_0_8_22
bool "0.8.22"
default n
set default APP_I2C_GPIO_SCL=21
set default APP_I2C_GPIO_SDA=20
set default APP_BUTTON_1_NUM_GPIO=9
set default APP_BUTTON_2_NUM_GPIO=10
config APP_HW_VERSION_0_8_21
bool "0.8.21"
default n
set default APP_I2C_GPIO_SCL=12
set default APP_I2C_GPIO_SDA=13
set default APP_BUTTON_1_NUM_GPIO=19
set default APP_BUTTON_2_NUM_GPIO=20
endmenu