From 33f0c6bd991d1e6d81436314aca7a86d21b9df21 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 13 Nov 2023 13:54:44 +0100 Subject: [PATCH] sysbuild: partition manager provide image file information Partition manager CMake code defines runner image file as sysbuild cache variable. This ensures the image file is propagated to the Zephyr image build system where the nRF Connect SDK CMake code will specify the image file on the runner's yaml properties. Signed-off-by: Torsten Rasmussen --- CMakeLists.txt | 10 ++++++++++ cmake/sysbuild/partition_manager.cmake | 21 +++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eaa0fea27ad7..fdcac39b2a9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,16 @@ set(CONF_FILE_BUILD_TYPE ${CONF_FILE_BUILD_TYPE} CACHE INTERNAL "The build type" # Customize the Zephyr kernel version.h using nRF Connect SDK ncs_version.h. set(KERNEL_VERSION_CUSTOMIZATION \#include; PARENT_SCOPE) +foreach(runner_ext BIN HEX ELF) + zephyr_get(NCS_RUNNER_${runner_ext} SYSBUILD) + if(DEFINED NCS_RUNNER_${runner_ext}) + string(TOLOWER "${runner_ext}" type) + set_target_properties(runners_yaml_props_target PROPERTIES + "${type}_file" "${NCS_RUNNER_${runner_ext}}" + ) + endif() +endforeach() + include(cmake/extensions.cmake) include(cmake/version.cmake) include(cmake/multi_image.cmake) diff --git a/cmake/sysbuild/partition_manager.cmake b/cmake/sysbuild/partition_manager.cmake index 9699dbac0531..07cee5cfb966 100644 --- a/cmake/sysbuild/partition_manager.cmake +++ b/cmake/sysbuild/partition_manager.cmake @@ -299,21 +299,34 @@ function(update_runner) set(runners_content_update) file(STRINGS ${runners_file} runners_content) - foreach(line ${runners_content}) - if(DEFINED RUNNER_ELF AND ${line} MATCHES "^.*elf_file: .*$") + foreach(line IN LISTS runners_content) + if(DEFINED RUNNER_ELF AND "${line}" MATCHES "^.*elf_file: .*$") string(REGEX REPLACE "(.*elf_file:) .*" "\\1 ${RUNNER_ELF}" line ${line}) + set(${RUNNER_IMAGE}_NCS_RUNNER_ELF "${RUNNER_ELF}" CACHE INTERNAL + "nRF Connect SDK partition managere controlled elf file" + ) endif() - if(DEFINED RUNNER_HEX AND ${line} MATCHES "^.*hex_file: .*$") + if(DEFINED RUNNER_HEX AND "${line}" MATCHES "^.*hex_file: .*$") string(REGEX REPLACE "(.*hex_file:) .*" "\\1 ${RUNNER_HEX}" line ${line}) + set(${RUNNER_IMAGE}_NCS_RUNNER_HEX "${RUNNER_HEX}" CACHE INTERNAL + "nRF Connect SDK partition managere controlled hex file" + ) endif() - if(DEFINED RUNNER_BIN AND ${line} MATCHES "^.*bin_file: .*$") + if(DEFINED RUNNER_BIN AND "${line}" MATCHES "^.*bin_file: .*$") string(REGEX REPLACE "(.*bin_file:) .*" "\\1 ${RUNNER_BIN}" line ${line}) + set(${RUNNER_IMAGE}_NCS_RUNNER_BIN "${RUNNER_BIN}" CACHE INTERNAL + "nRF Connect SDK partition managere controlled bin file" + ) endif() list(APPEND runners_content_update "${line}\n") endforeach() file(WRITE ${runners_file} ${runners_content_update}) + + # NCS has updated the cache with an NCS_RUNNER file, thus re-create the sysbuild cache. + # No need for CMAKE_RERUN in this case, as runners.yaml has been updated above. + sysbuild_cache(CREATE APPLICATION ${RUNNER_IMAGE}) endfunction()