diff --git a/cmake/modules/kconfig.cmake b/cmake/modules/kconfig.cmake index 8aed0a828eef..b1917249ea35 100644 --- a/cmake/modules/kconfig.cmake +++ b/cmake/modules/kconfig.cmake @@ -27,8 +27,10 @@ if(CONFIG_NCS_IS_VARIANT_IMAGE) import_kconfig("CONFIG" ${DOTCONFIG}) else() + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/sysbuild/bootloader_dts_utils.cmake) + dt_chosen(code_partition PROPERTY "zephyr,code-partition") - dt_reg_addr(code_partition_offset PATH "${code_partition}" REQUIRED) + dt_partition_addr(code_partition_offset PATH "${code_partition}" REQUIRED) dt_reg_size(code_partition_size PATH "${code_partition}" REQUIRED) set(preload_autoconf_h ${PRELOAD_BINARY_DIR}/zephyr/include/generated/zephyr/autoconf.h) diff --git a/cmake/sysbuild/bootloader_dts_utils.cmake b/cmake/sysbuild/bootloader_dts_utils.cmake index 9567120a60b4..789118fd24ad 100644 --- a/cmake/sysbuild/bootloader_dts_utils.cmake +++ b/cmake/sysbuild/bootloader_dts_utils.cmake @@ -5,20 +5,115 @@ # data coming from the devicetree for configurations using # a bootloader. -function(get_address_from_dt_partition_nodelabel label address) - dt_nodelabel(partition_node TARGET ${DEFAULT_IMAGE} NODELABEL ${label} REQUIRED) - dt_reg_addr(partition_offset TARGET ${DEFAULT_IMAGE} PATH ${partition_node}) +function(dt_get_parent node) + string(FIND "${${node}}" "/" pos REVERSE) + + if(pos EQUAL -1) + message(FATAL_ERROR "Unable to get parent of node: ${${node}}") + endif() + + string(SUBSTRING "${${node}}" 0 ${pos} ${node}) + set(${node} "${${node}}" PARENT_SCOPE) +endfunction() + +# Usage: +# dt_partition_addr( [LABEL