Kconfig Initial Configuration not taking CMakeLists settings

I am trying to set a couple of Kconfig settings in my CMakeLists.txt file so that I can make use of some CMakeLists.txt variables.

I have been successful in setting Kconfig variables for MCUboot, however I can't seem to get it to work for the application. Based on the documentation here (https://docs.zephyrproject.org/latest/build/kconfig/setting.html#the-initial-configuration) it seems like anything I set in CMake that begins with CONFIG_ should be added to the initial configuration, but that isn't working.

Here is what I have in my CMakeLists.txt:

cmake_minimum_required(VERSION 3.20.0)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 23)

set(CONFIG_SHELL y)  ## NOT ADDED TO APPLICATION CONFIGURATION (an test)
set(mcuboot_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 y) ## PROPERLY ADDED TO MCUBOOT CONFIG
set(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE \"${CMAKE_CURRENT_SOURCE_DIR}/key/witricity_key.pem\")

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(my_app VERSION 0.3.3)
set(TARGET_NAME app)
target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)

configure_file("${PROJECT_SOURCE_DIR}/src/version.h.in"
               "${PROJECT_SOURCE_DIR}/src/version.h"
               @ONLY
)

target_sources(${TARGET_NAME} PRIVATE
  ${CMAKE_CURRENT_SOURCE_DIR}/src/main.c
  <and the rest of my source files>
)

The resulting .config file does not have CONFIG_SHELL=y - in fact, CONFIG_SHELL is not set at all.

Why is this working for some parameters and not others? Is this not supported for the application? If not supported, is there another way to do this? Specifically, I want to pull the version number from the CMake project and use it to version my images for MCUboot XIP. Is there a better way to do that? Maybe I can just have them increment each time they are built?

Thanks for the support!

Parents Reply Children
  • Ah yes, that was it!  It makes me wonder why my mcuboot_CONFIG_* options were taking effect, but the others were not?

    Either way, I added those to the cache as well and things are working well.

    Here is the relevant snippet from my final CMakeLists.txt, for anyone interested.

    set(JLINK_FLASH_BUILD TRUE CACHE INTERNAL "Automatically confirm application for initial flash images")
    set(APP_VERSION 0.3.3)
    
    list(APPEND IMGTOOL_ARGS "--version ${APP_VERSION}")
    
    if(JLINK_FLASH_BUILD)
      list(APPEND IMGTOOL_ARGS "--confirm")
    endif(JLINK_FLASH_BUILD)
    
    string(REPLACE ";" " " IMGTOOL_ARGS "${IMGTOOL_ARGS}")
    
    set(CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS \"${IMGTOOL_ARGS}\" CACHE INTERNAL "")

Related