sysbuild: refactor image_config.cmake handling
Refactor image_config.cmake so that it is no longer sourced unconditionally for all images. Instead image_config.cmake has been split into BOOTLOADER_image_default.cmake and MAIN_image_default.cmake and is set as property on the image. This means the code in image_config.cmake can be split into dedicated files which depends on the image type. Furthermore it allows sysbuild modules to append extra config snippets to process for sysbuild kconfig overwrite, or even remove the default snippet and have full control. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
5e4710ce68
commit
f380f8200c
|
@ -86,7 +86,6 @@ endwhile()
|
|||
|
||||
sysbuild_module_call(PRE_CMAKE MODULES ${SYSBUILD_MODULE_NAMES} IMAGES ${IMAGES})
|
||||
foreach(image ${IMAGES})
|
||||
include(image_config.cmake)
|
||||
ExternalZephyrProject_Cmake(APPLICATION ${image})
|
||||
endforeach()
|
||||
sysbuild_module_call(POST_CMAKE MODULES ${SYSBUILD_MODULE_NAMES} IMAGES ${IMAGES})
|
||||
|
|
|
@ -271,6 +271,11 @@ function(ExternalZephyrProject_Add)
|
|||
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES MAIN_APP True)
|
||||
endif()
|
||||
|
||||
if(DEFINED ZBUILD_APP_TYPE)
|
||||
set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake")
|
||||
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT ${image_default})
|
||||
endif()
|
||||
|
||||
if(DEFINED ZBUILD_BOARD)
|
||||
# Only set image specific board if provided.
|
||||
# The sysbuild BOARD is exported through sysbuild cache, and will be used
|
||||
|
@ -349,6 +354,10 @@ function(ExternalZephyrProject_Cmake)
|
|||
get_target_property(${ZCMAKE_APPLICATION}_BOARD ${ZCMAKE_APPLICATION} BOARD)
|
||||
get_target_property(${ZCMAKE_APPLICATION}_MAIN_APP ${ZCMAKE_APPLICATION} MAIN_APP)
|
||||
|
||||
get_property(${ZCMAKE_APPLICATION}_CONF_SCRIPT TARGET ${ZCMAKE_APPLICATION}
|
||||
PROPERTY IMAGE_CONF_SCRIPT
|
||||
)
|
||||
|
||||
# Update ROOT variables with relative paths to use absolute paths based on
|
||||
# the source application directory.
|
||||
foreach(type MODULE_EXT BOARD SOC ARCH SCA)
|
||||
|
@ -400,6 +409,10 @@ function(ExternalZephyrProject_Cmake)
|
|||
${${ZCMAKE_APPLICATION}_CACHE_FILE} ONLY_IF_DIFFERENT
|
||||
)
|
||||
|
||||
foreach(script ${${ZCMAKE_APPLICATION}_CONF_SCRIPT})
|
||||
include(${script})
|
||||
endforeach()
|
||||
|
||||
set(dotconfigsysbuild ${BINARY_DIR}/zephyr/.config.sysbuild)
|
||||
get_target_property(config_content ${ZCMAKE_APPLICATION} CONFIG)
|
||||
string(CONFIGURE "${config_content}" config_content)
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
# Copyright (c) 2023 Nordic Semiconductor
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# This sysbuild CMake file sets the sysbuild controlled settings as properties
|
||||
# on Zephyr images.
|
||||
|
||||
get_target_property(image_board ${image} BOARD)
|
||||
if((NOT image_board) OR ("${image_BOARD}" STREQUAL "${BOARD}"))
|
||||
get_target_property(${image}_APP_TYPE ${image} APP_TYPE)
|
||||
if(NOT "${${image}_APP_TYPE}" STREQUAL "BOOTLOADER")
|
||||
set_config_bool(${image} CONFIG_BOOTLOADER_MCUBOOT "${SB_CONFIG_BOOTLOADER_MCUBOOT}")
|
||||
set_config_string(${image} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
|
||||
"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}"
|
||||
)
|
||||
else()
|
||||
set(keytypes CONFIG_BOOT_SIGNATURE_TYPE_NONE
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_RSA
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
|
||||
if(SB_CONFIG_BOOT_SIGNATURE_TYPE_NONE)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_NONE)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_RSA)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
endif()
|
||||
|
||||
foreach(loopkeytype ${keytypes})
|
||||
if("${loopkeytype}" STREQUAL "${keytype}")
|
||||
set_config_bool(${image} ${loopkeytype} y)
|
||||
else()
|
||||
set_config_bool(${image} ${loopkeytype} n)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
|
||||
if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
|
||||
set_config_bool(${image} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
|
||||
else()
|
||||
set_config_bool(${image} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,37 @@
|
|||
# Copyright (c) 2023 Nordic Semiconductor
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# This sysbuild CMake file sets the sysbuild controlled settings as properties
|
||||
# on Zephyr MCUboot / bootloader image.
|
||||
|
||||
set(keytypes CONFIG_BOOT_SIGNATURE_TYPE_NONE
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_RSA
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256
|
||||
CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
|
||||
if(SB_CONFIG_BOOT_SIGNATURE_TYPE_NONE)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_NONE)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_RSA)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_RSA)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256)
|
||||
elseif(SB_CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
set(keytype CONFIG_BOOT_SIGNATURE_TYPE_ED25519)
|
||||
endif()
|
||||
|
||||
foreach(loopkeytype ${keytypes})
|
||||
if("${loopkeytype}" STREQUAL "${keytype}")
|
||||
set_config_bool(${ZCMAKE_APPLICATION} ${loopkeytype} y)
|
||||
else()
|
||||
set_config_bool(${ZCMAKE_APPLICATION} ${loopkeytype} n)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
|
||||
if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
|
||||
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
|
||||
else()
|
||||
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
|
||||
endif()
|
||||
endif()
|
19
share/sysbuild/image_configurations/MAIN_image_default.cmake
Normal file
19
share/sysbuild/image_configurations/MAIN_image_default.cmake
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Copyright (c) 2023 Nordic Semiconductor
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# This sysbuild CMake file sets the sysbuild controlled settings as properties
|
||||
# on the main Zephyr image.
|
||||
|
||||
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_BOOTLOADER_MCUBOOT "${SB_CONFIG_BOOTLOADER_MCUBOOT}")
|
||||
set_config_string(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_SIGNATURE_KEY_FILE
|
||||
"${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}"
|
||||
)
|
||||
|
||||
if(SB_CONFIG_BOOTLOADER_MCUBOOT)
|
||||
if("${SB_CONFIG_SIGNATURE_TYPE}" STREQUAL "NONE")
|
||||
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE y)
|
||||
else()
|
||||
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
|
||||
endif()
|
||||
endif()
|
Loading…
Reference in a new issue