Skip to content

Commit a5d79cf

Browse files
MarekPietanvlsianpu
authored andcommitted
boot: zephyr: Fix build issue for multiple conf files
Change fixes build issue that occurs if CONF_FILE contains multiple file paths instead of single file path. Signed-off-by: Marek Pieta <[email protected]> Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 4804219 commit a5d79cf

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

boot/zephyr/CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,17 +231,30 @@ if(CONFIG_MCUBOOT_SERIAL)
231231
)
232232
endif()
233233

234-
# CONF_FILE points to the KConfig configuration file of the bootloader
235-
get_filename_component(CONF_DIR ${CONF_FILE} DIRECTORY)
234+
# CONF_FILE points to the KConfig configuration files of the bootloader.
235+
foreach (filepath ${CONF_FILE})
236+
file(READ ${filepath} temp_text)
237+
string(FIND "${temp_text}" ${CONFIG_BOOT_SIGNATURE_KEY_FILE} match)
238+
if (${match} GREATER_EQUAL 0)
239+
if (NOT DEFINED CONF_DIR)
240+
get_filename_component(CONF_DIR ${filepath} DIRECTORY)
241+
else()
242+
message(FATAL_ERROR "Signature key file defined in multiple conf files")
243+
endif()
244+
endif()
245+
endforeach()
236246

237247
if(NOT CONFIG_BOOT_SIGNATURE_KEY_FILE STREQUAL "")
238248
if(IS_ABSOLUTE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
239249
set(KEY_FILE ${CONFIG_BOOT_SIGNATURE_KEY_FILE})
240-
elseif(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
250+
elseif((DEFINED CONF_DIR) AND
251+
(EXISTS ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE}))
241252
set(KEY_FILE ${CONF_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
242253
else()
243254
set(KEY_FILE ${MCUBOOT_DIR}/${CONFIG_BOOT_SIGNATURE_KEY_FILE})
244255
endif()
256+
message("MCUBoot bootloader key file: ${KEY_FILE}")
257+
245258
set(GENERATED_PUBKEY ${ZEPHYR_BINARY_DIR}/autogen-pubkey.c)
246259
add_custom_command(
247260
OUTPUT ${GENERATED_PUBKEY}

0 commit comments

Comments
 (0)