Page 1 of 1

Kconfig syntax error on set default

Posted: Sat Dec 27, 2025 7:30 pm
by espmich
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:

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.ninja
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?

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

Re: Kconfig syntax error on set default

Posted: Sun Dec 28, 2025 7:49 am
by nopnop2002

Code: Select all

menu "Application Configuration"

  choice
    prompt "Select the hardware revision of the device."
    default APP_HW_VERSION_0_8_22
    help
        Select the hardware revision of the device
    config APP_HW_VERSION_0_8_22
        bool "APP_HW_VERSION_0_8_22"
    config APP_HW_VERSION_0_8_21
        bool "APP_HW_VERSION_0_8_21"
  endchoice

  config APP_I2C_GPIO_SCL
    int
    default 21 if APP_HW_VERSION_0_8_22
    default 12 if APP_HW_VERSION_0_8_21

endmenu