Skip to content

Commit 45be71d

Browse files
committed
cmake: Support for split slot Direct XIP in ZIP
Add code necessary to include both slots, generated by the Direct XIP inside the DFU ZIP distribution file. Ref: NCSDK-35733 Signed-off-by: Tomasz Chyrowicz <[email protected]>
1 parent 8047650 commit 45be71d

File tree

1 file changed

+66
-31
lines changed

1 file changed

+66
-31
lines changed

cmake/sysbuild/zip.cmake

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ function(dfu_app_zip_package)
193193
# Network core
194194
get_property(image_name GLOBAL PROPERTY DOMAIN_APP_CPUNET)
195195
set(net_update_name "${image_name}.bin")
196+
set(secondary_net_update_name "${image_name}_secondary_app.bin")
196197
sysbuild_get(net_core_board IMAGE ${image_name} VAR BOARD CACHE)
197198

198199
if(SB_CONFIG_SECURE_BOOT_NETCORE)
@@ -204,42 +205,76 @@ function(dfu_app_zip_package)
204205
mcuboot_image_number_to_slot(net_update_slot_primary ${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER} n)
205206
mcuboot_image_number_to_slot(net_update_slot_secondary ${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER} y)
206207

207-
if(SB_CONFIG_PARTITION_MANAGER)
208-
set(net_load_address "$<TARGET_PROPERTY:partition_manager,CPUNET_PM_APP_ADDRESS>")
209-
else()
210-
get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition"
211-
net_load_address
212-
)
213-
endif()
208+
if(NOT SB_CONFIG_MCUBOOT_BUILD_DIRECT_XIP_VARIANT)
209+
if(SB_CONFIG_PARTITION_MANAGER)
210+
set(net_load_address "$<TARGET_PROPERTY:partition_manager,CPUNET_PM_APP_ADDRESS>")
211+
else()
212+
get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition"
213+
net_load_address
214+
)
215+
endif()
214216

215-
math(EXPR net_update_slot_primary "${net_update_slot_primary} + 1")
216-
math(EXPR net_update_slot_secondary "${net_update_slot_secondary} + 1")
217+
math(EXPR net_update_slot_primary "${net_update_slot_primary} + 1")
218+
math(EXPR net_update_slot_secondary "${net_update_slot_secondary} + 1")
219+
220+
set(generate_script_app_params
221+
${generate_script_app_params}
222+
"${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}"
223+
"${net_update_name}slot_index_primary=${net_update_slot_primary}"
224+
"${net_update_name}slot_index_secondary=${net_update_slot_secondary}"
225+
"${net_update_name}load_address=${net_load_address}"
226+
"${net_update_name}version=${net_update_version}"
227+
"${net_update_name}board=${net_core_board}"
228+
"${net_update_name}soc=${SB_CONFIG_SOC}"
229+
)
230+
231+
if(SB_CONFIG_SECURE_BOOT_NETCORE)
232+
list(APPEND bin_files "${CMAKE_BINARY_DIR}/signed_by_mcuboot_and_b0_${image_name}.bin")
233+
list(APPEND signed_targets ${image_name}_signed_packaged_target)
234+
else()
235+
sysbuild_get(net_CONFIG_KERNEL_BIN_NAME IMAGE ${image_name} VAR CONFIG_KERNEL_BIN_NAME KCONFIG)
236+
if(SB_CONFIG_BOOT_ENCRYPTION)
237+
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin")
238+
else()
239+
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.bin")
240+
endif()
241+
endif()
242+
243+
list(APPEND zip_names "${net_update_name}")
244+
list(APPEND signed_targets ${image_name}_extra_byproducts)
245+
elseif(NOT SB_CONFIG_PARTITION_MANAGER)
246+
get_address_from_dt_partition_nodelabel("slot${net_update_slot_primary}_partition" primary_net_load_address)
247+
get_address_from_dt_partition_nodelabel("slot${net_update_slot_secondary}_partition" secondary_net_load_address)
217248

218-
set(generate_script_app_params
249+
# Radio in DirectXIP mode
250+
set(generate_script_app_params
219251
${generate_script_app_params}
220-
"${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}"
221-
"${net_update_name}slot_index_primary=${net_update_slot_primary}"
222-
"${net_update_name}slot_index_secondary=${net_update_slot_secondary}"
223-
"${net_update_name}load_address=${net_load_address}"
224-
"${net_update_name}version=${net_update_version}"
225-
"${net_update_name}board=${net_core_board}"
226-
"${net_update_name}soc=${SB_CONFIG_SOC}"
227-
)
252+
"${net_update_name}load_address=${primary_net_load_address}"
253+
"${net_update_name}version_MCUBOOT+XIP=${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION}"
254+
"${net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}"
255+
"${net_update_name}slot=${net_update_slot_primary}"
256+
"${secondary_net_update_name}load_address=${secondary_net_load_address}"
257+
"${secondary_net_update_name}image_index=${SB_CONFIG_MCUBOOT_NETWORK_CORE_IMAGE_NUMBER}"
258+
"${secondary_net_update_name}slot=${net_update_slot_secondary}"
259+
"${secondary_net_update_name}version_MCUBOOT+XIP=${CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION}"
260+
)
261+
list(APPEND bin_files
262+
"${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin"
263+
"${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin"
264+
)
265+
set(exclude_files EXCLUDE
266+
${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin
267+
${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.signed.bin
268+
)
269+
set(include_files INCLUDE
270+
${CMAKE_BINARY_DIR}/${image_name}/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
271+
${CMAKE_BINARY_DIR}/${image_name}_secondary_app/zephyr/${CONFIG_KERNEL_BIN_NAME}.bin
272+
)
228273

229-
if(SB_CONFIG_SECURE_BOOT_NETCORE)
230-
list(APPEND bin_files "${CMAKE_BINARY_DIR}/signed_by_mcuboot_and_b0_${image_name}.bin")
231-
list(APPEND signed_targets ${image_name}_signed_packaged_target)
232-
else()
233-
sysbuild_get(net_CONFIG_KERNEL_BIN_NAME IMAGE ${image_name} VAR CONFIG_KERNEL_BIN_NAME KCONFIG)
234-
if(SB_CONFIG_BOOT_ENCRYPTION)
235-
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.encrypted.bin")
236-
else()
237-
list(APPEND bin_files "${CMAKE_BINARY_DIR}/${image_name}/zephyr/${net_CONFIG_KERNEL_BIN_NAME}.signed.bin")
238-
endif()
274+
list(APPEND zip_names "${net_update_name};${secondary_net_update_name}")
275+
list(APPEND signed_targets ${image_name}_extra_byproducts)
276+
list(APPEND signed_targets ${image_name}_secondary_app_extra_byproducts)
239277
endif()
240-
241-
list(APPEND zip_names "${net_update_name}")
242-
list(APPEND signed_targets ${image_name}_extra_byproducts)
243278
endif()
244279

245280
if(SB_CONFIG_DFU_ZIP_WIFI_FW_PATCH)

0 commit comments

Comments
 (0)