Skip to content

Commit

Permalink
sysbuild: partition manager provide image file information
Browse files Browse the repository at this point in the history
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 <Torsten.Rasmussen@nordicsemi.no>
  • Loading branch information
tejlmand committed Nov 13, 2023
1 parent c19ee18 commit 33f0c6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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;<ncs_version.h> 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)
Expand Down
21 changes: 17 additions & 4 deletions cmake/sysbuild/partition_manager.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down

0 comments on commit 33f0c6b

Please sign in to comment.