Skip to content

Commit 2ae4f99

Browse files
committed
cmake: sysbuild: zip: Use encrypted firmware
Uses the encrypted update file instead of the unencrypted one with update zip files if the project is configured with encrypted MCUboot images Signed-off-by: Jamie McCrae <[email protected]>
1 parent e533a5f commit 2ae4f99

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

cmake/sysbuild/zip.cmake

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,13 @@ function(dfu_app_zip_package)
9797
)
9898
endif()
9999
else()
100-
set(app_update_name "${DEFAULT_IMAGE}.bin")
101-
set(secondary_app_update_name mcuboot_secondary_app.bin)
100+
if(SB_CONFIG_BOOT_ENCRYPTION)
101+
set(app_update_name "${DEFAULT_IMAGE}.signed.encrypted.bin")
102+
else()
103+
set(app_update_name "${DEFAULT_IMAGE}.signed.bin")
104+
set(secondary_app_update_name mcuboot_secondary_app.signed.bin)
105+
endif()
106+
102107
mcuboot_image_number_to_slot(slot_primary ${SB_CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER} n)
103108
mcuboot_image_number_to_slot(slot_secondary ${SB_CONFIG_MCUBOOT_APPLICATION_IMAGE_NUMBER} y)
104109

@@ -111,10 +116,15 @@ function(dfu_app_zip_package)
111116
"${app_update_name}slot_index_secondary=${slot_secondary}"
112117
"${app_update_name}version_MCUBOOT=${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION}"
113118
)
114-
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin")
119+
if(SB_CONFIG_BOOT_ENCRYPTION)
120+
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin")
121+
set(exclude_files EXCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin)
122+
else()
123+
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin")
124+
set(exclude_files EXCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin)
125+
endif()
115126
list(APPEND zip_names ${app_update_name})
116127
list(APPEND signed_targets ${DEFAULT_IMAGE}_extra_byproducts)
117-
set(exclude_files EXCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin)
118128
set(include_files INCLUDE ${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin)
119129
else()
120130
# Application in DirectXIP mode
@@ -133,12 +143,12 @@ function(dfu_app_zip_package)
133143
"${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin"
134144
"${CMAKE_BINARY_DIR}/mcuboot_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin"
135145
)
136-
list(APPEND zip_names "${app_update_name};${secondary_app_update_name}")
137-
list(APPEND signed_targets ${DEFAULT_IMAGE}_extra_byproducts mcuboot_secondary_app_extra_byproducts)
138146
set(exclude_files EXCLUDE
139147
${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin
140148
${CMAKE_BINARY_DIR}/mcuboot_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin
141149
)
150+
list(APPEND zip_names "${app_update_name};${secondary_app_update_name}")
151+
list(APPEND signed_targets ${DEFAULT_IMAGE}_extra_byproducts mcuboot_secondary_app_extra_byproducts)
142152
set(include_files INCLUDE
143153
${CMAKE_BINARY_DIR}/${DEFAULT_IMAGE}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
144154
${CMAKE_BINARY_DIR}/mcuboot_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin

0 commit comments

Comments
 (0)