|
10 | 10 | # Since this file is brought in via include(), we do the work in a
|
11 | 11 | # function to avoid polluting the top-level scope.
|
12 | 12 |
|
13 |
| -function(ncs_secure_boot_mcuboot_sign application application_name bin_files signed_targets) |
| 13 | +function(ncs_secure_boot_mcuboot_sign application output_name bin_files signed_targets prefix) |
14 | 14 | set(keyfile "${SB_CONFIG_BOOT_SIGNATURE_KEY_FILE}")
|
15 | 15 |
|
16 | 16 | # Find imgtool. Even though west is installed, imgtool might not be.
|
@@ -38,15 +38,15 @@ function(ncs_secure_boot_mcuboot_sign application application_name bin_files sig
|
38 | 38 | sysbuild_get(CONFIG_BUILD_OUTPUT_BIN IMAGE ${application} VAR CONFIG_BUILD_OUTPUT_BIN KCONFIG)
|
39 | 39 | sysbuild_get(CONFIG_BUILD_OUTPUT_HEX IMAGE ${application} VAR CONFIG_BUILD_OUTPUT_HEX KCONFIG)
|
40 | 40 |
|
41 |
| - string(TOUPPER "${application_name}" application_name_uppercase) |
42 |
| - set(imgtool_sign ${imgtool_path} sign --version ${SB_CONFIG_SECURE_BOOT_MCUBOOT_VERSION} --align 4 --slot-size $<TARGET_PROPERTY:partition_manager,PM_${application_name_uppercase}_SIZE> --pad-header --header-size ${SB_CONFIG_PM_MCUBOOT_PAD}) |
| 41 | + string(TOUPPER "${application}" application_uppercase) |
| 42 | + set(imgtool_sign ${imgtool_path} sign --version ${SB_CONFIG_SECURE_BOOT_MCUBOOT_VERSION} --align 4 --slot-size $<TARGET_PROPERTY:partition_manager,${prefix}PM_${application_uppercase}_SIZE> --pad-header --header-size ${SB_CONFIG_PM_MCUBOOT_PAD}) |
43 | 43 |
|
44 | 44 | if(NOT "${keyfile}" STREQUAL "")
|
45 | 45 | set(imgtool_extra -k "${keyfile}" ${imgtool_extra})
|
46 | 46 | endif()
|
47 | 47 |
|
48 | 48 | # Extensionless prefix of any output file.
|
49 |
| - set(output ${PROJECT_BINARY_DIR}/signed_by_mcuboot_and_b0_${application}) |
| 49 | + set(output ${PROJECT_BINARY_DIR}/signed_by_mcuboot_and_b0_${output_name}) |
50 | 50 |
|
51 | 51 | # List of additional build byproducts.
|
52 | 52 | set(byproducts)
|
@@ -121,45 +121,44 @@ function(ncs_secure_boot_mcuboot_sign application application_name bin_files sig
|
121 | 121 | endif()
|
122 | 122 | endfunction()
|
123 | 123 |
|
124 |
| -if(SB_CONFIG_BOOTLOADER_MCUBOOT AND SB_CONFIG_SECURE_BOOT) |
125 |
| - set(bin_files) |
126 |
| - set(signed_targets) |
127 |
| - |
| 124 | +if(SB_CONFIG_BOOTLOADER_MCUBOOT) |
128 | 125 | if(SB_CONFIG_SECURE_BOOT_APPCORE)
|
129 |
| - set(s0_image_name "mcuboot") |
130 |
| - set(s0_application_name "${s0_image_name}") |
131 |
| - else() |
132 |
| - get_property(image_name GLOBAL PROPERTY DOMAIN_APP_CPUNET) |
133 |
| - set(s0_image_name "${image_name}") |
134 |
| - set(s0_application_name "mcuboot_primary_1") |
135 |
| - endif() |
| 126 | + set(bin_files) |
| 127 | + set(signed_targets) |
136 | 128 |
|
137 |
| - ncs_secure_boot_mcuboot_sign("${s0_image_name}" "${s0_application_name}" "${bin_files}" "${signed_targets}") |
| 129 | + ncs_secure_boot_mcuboot_sign(mcuboot s0_image "${bin_files}" "${signed_targets}" "") |
138 | 130 |
|
139 |
| - if(SB_CONFIG_SECURE_BOOT_BUILD_S1_VARIANT_IMAGE) |
140 |
| - ncs_secure_boot_mcuboot_sign("s1_image" "s1_image" "${bin_files}" "${signed_targets}") |
| 131 | + if(SB_CONFIG_SECURE_BOOT_BUILD_S1_VARIANT_IMAGE) |
| 132 | + ncs_secure_boot_mcuboot_sign(s1_image s1_image "${bin_files}" "${signed_targets}" "") |
| 133 | + endif() |
| 134 | + |
| 135 | + if(bin_files) |
| 136 | + sysbuild_get(mcuboot_fw_info_firmware_version IMAGE mcuboot VAR CONFIG_FW_INFO_FIRMWARE_VERSION KCONFIG) |
| 137 | + |
| 138 | + include(${ZEPHYR_NRF_MODULE_DIR}/cmake/fw_zip.cmake) |
| 139 | + |
| 140 | + generate_dfu_zip( |
| 141 | + OUTPUT ${PROJECT_BINARY_DIR}/dfu_mcuboot.zip |
| 142 | + BIN_FILES ${bin_files} |
| 143 | + TYPE mcuboot |
| 144 | + IMAGE mcuboot |
| 145 | + SCRIPT_PARAMS |
| 146 | + "signed_by_mcuboot_and_b0_s0_image.binload_address=$<TARGET_PROPERTY:partition_manager,PM_S0_ADDRESS>" |
| 147 | + "signed_by_mcuboot_and_b0_s1_image.binload_address=$<TARGET_PROPERTY:partition_manager,PM_S1_ADDRESS>" |
| 148 | + "version_MCUBOOT=${SB_CONFIG_SECURE_BOOT_MCUBOOT_VERSION}" |
| 149 | + "version_B0=${mcuboot_fw_info_firmware_version}" |
| 150 | + DEPENDS ${signed_targets} |
| 151 | + ) |
| 152 | + endif() |
141 | 153 | endif()
|
142 | 154 |
|
143 |
| - if(bin_files) |
144 |
| - sysbuild_get(mcuboot_fw_info_firmware_version IMAGE mcuboot VAR CONFIG_FW_INFO_FIRMWARE_VERSION KCONFIG) |
145 |
| - |
146 |
| - include(${ZEPHYR_NRF_MODULE_DIR}/cmake/fw_zip.cmake) |
147 |
| - |
148 |
| - generate_dfu_zip( |
149 |
| - OUTPUT ${PROJECT_BINARY_DIR}/dfu_mcuboot.zip |
150 |
| - BIN_FILES ${bin_files} |
151 |
| - TYPE mcuboot |
152 |
| - IMAGE mcuboot |
153 |
| - SCRIPT_PARAMS |
154 |
| - "signed_by_mcuboot_and_b0_${s0_image_name}.binload_address=$<TARGET_PROPERTY:partition_manager,PM_S0_ADDRESS>" |
155 |
| - "signed_by_mcuboot_and_b0_s1_image.binload_address=$<TARGET_PROPERTY:partition_manager,PM_S1_ADDRESS>" |
156 |
| - "version_MCUBOOT=${SB_CONFIG_SECURE_BOOT_MCUBOOT_VERSION}" |
157 |
| - "version_B0=${mcuboot_fw_info_firmware_version}" |
158 |
| - DEPENDS ${signed_targets} |
159 |
| - ) |
| 155 | + if(SB_CONFIG_SECURE_BOOT_NETCORE) |
| 156 | + get_property(image_name GLOBAL PROPERTY DOMAIN_APP_CPUNET) |
| 157 | + ncs_secure_boot_mcuboot_sign(${image_name} ${image_name} "${bin_files}" "${signed_targets}" CPUNET_) |
160 | 158 | endif()
|
161 | 159 |
|
162 | 160 | # Clear temp variables
|
| 161 | + set(image_name) |
163 | 162 | set(bin_files)
|
164 | 163 | set(signed_targets)
|
165 | 164 | endif()
|
0 commit comments