NCS: Select pm_static.yml dependent on Config

I have two project configurations one for debug and one for release. Dependent on configuration I want to select pm_static_board.yml or use default flash layout.

For this I created Kconfig file and added new config:

source "Kconfig.zephyr"

config BUILD_CONFIGURATION_PRODUCT_DEBUG
	bool "Select MCU Flash Layout for Debug / Release"

In CMakeLists.tx added the following:

if(NOT CONFIG_BUILD_CONFIGURATION_PRODUCT_DEBUG)
  set(PM_STATIC_YML_FILE
    ${CMAKE_CURRENT_SOURCE_DIR}/boards/pm_static_${BOARD}.yml
    )
endif()

And in corresponding prj.conf I set or reset CONFIG_BUILD_CONFIGURATION_PRODUCT_DEBUG.

However seems that pm_static is added independent on config. If I comment out changes in CMakeLists.txt then pm_static is not added.

Parents Reply
  • I have the same problem and used the following solution:

    Renamed the file "pm_static.yml" to "pm_static_release.yml".
    Then in the build configuration for release (not debug) under "Extra CMake arguments" added the following:

    -DPM_STATIC_YML_FILE="pm_static_release.yml"

    (with "-" at the beginning!)

    To simplify things, I then saved the debug and release configuration in the configuration preset (CMakePresets.json).

Children
No Data
Related