Skip to content

Commit decaf00

Browse files
tejlmandcarlescufi
authored andcommitted
cmake: add elf dependencies to multi image builds
This commit add elf file dependencies to merged.hex target for multi image builds. The elf file dependency will be reflected in the generated ninja file and thus allowing IDE/Debuggers to obtain relation of hex-file to elf-file relation for symbol loading during a debug session. Signed-off-by: Torsten Rasmussen <[email protected]>
1 parent 245d265 commit decaf00

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cmake/multi_image.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ endfunction()
2222

2323
if(IMAGE_NAME)
2424
share("set(${IMAGE_NAME}KERNEL_HEX_NAME ${KERNEL_HEX_NAME})")
25+
# Share the elf file, in order to support symbol loading for debuggers.
26+
share("set(${IMAGE_NAME}KERNEL_ELF_NAME ${KERNEL_ELF_NAME})")
2527
share("list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${KERNEL_HEX_NAME})")
28+
share("list(APPEND ${IMAGE_NAME}BUILD_BYPRODUCTS ${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME})")
2629

2730
file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/shared_vars.cmake
2831
CONTENT $<TARGET_PROPERTY:zephyr_property_target,shared_vars>
@@ -181,6 +184,7 @@ function(add_child_image_from_source name sourcedir)
181184

182185
# Increase the scope of this variable to make it more available
183186
set(${name}_KERNEL_HEX_NAME ${${name}_KERNEL_HEX_NAME} CACHE STRING "" FORCE)
187+
set(${name}_KERNEL_ELF_NAME ${${name}_KERNEL_ELF_NAME} CACHE STRING "" FORCE)
184188

185189
if(MULTI_IMAGE_DEBUG_MAKEFILE AND "${CMAKE_GENERATOR}" STREQUAL "Ninja")
186190
set(multi_image_build_args "-d" "${MULTI_IMAGE_DEBUG_MAKEFILE}")

cmake/partition_manager.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ if(PM_IMAGES OR (EXISTS ${static_configuration_file}))
106106
foreach(part ${PM_ALL_BY_SIZE})
107107
string(TOUPPER ${part} PART)
108108
get_property(${part}_PM_HEX_FILE GLOBAL PROPERTY ${part}_PM_HEX_FILE)
109+
get_property(${part}_PM_ELF_FILE GLOBAL PROPERTY ${part}_PM_ELF_FILE)
109110

110111
# Process container partitions (if it has a SPAN list it is a container partition).
111112
if(DEFINED PM_${PART}_SPAN)
@@ -120,6 +121,7 @@ if(PM_IMAGES OR (EXISTS ${static_configuration_file}))
120121
else()
121122
if(${part} IN_LIST images)
122123
set(${part}_PM_HEX_FILE ${CMAKE_BINARY_DIR}/${part}/zephyr/${${part}_KERNEL_HEX_NAME})
124+
set(${part}_PM_ELF_FILE ${CMAKE_BINARY_DIR}/${part}/zephyr/${${part}_KERNEL_ELF_NAME})
123125
set(${part}_PM_TARGET ${part}_subimage)
124126
elseif(${part} IN_LIST containers)
125127
set(${part}_PM_HEX_FILE ${PROJECT_BINARY_DIR}/${part}.hex)
@@ -141,6 +143,7 @@ if(PM_IMAGES OR (EXISTS ${static_configuration_file}))
141143
foreach(part ${PM_${CONTAINER}_SPAN})
142144
string(TOUPPER ${part} PART)
143145
list(APPEND ${container}hex_files ${${part}_PM_HEX_FILE})
146+
list(APPEND ${container}elf_files ${${part}_PM_ELF_FILE})
144147
list(APPEND ${container}targets ${${part}_PM_TARGET})
145148
endforeach()
146149

@@ -161,6 +164,10 @@ if(PM_IMAGES OR (EXISTS ${static_configuration_file}))
161164
DEPENDS
162165
${${container}targets}
163166
${${container}hex_files}
167+
# SES will load symbols from all elf files listed as dependencies to ${PROJECT_BINARY_DIR}/merged.hex.
168+
# Therefore we add ${${container}elf_files} as dependency to ensure they are loaded by SES even though
169+
# it is unnecessary for building the application.
170+
${${container}elf_files}
164171
)
165172

166173
# Wrapper target for the merge command.

0 commit comments

Comments
 (0)