Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Raef Coles | 09dcd16 | 2024-12-09 15:40:53 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
David Hu | 1249f0d | 2023-12-04 22:57:56 +0800 | [diff] [blame] | 7 | cmake_minimum_required(VERSION 3.21) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 8 | |
| 9 | # This CMake script is prepard by TF-M for building the non-secure side |
| 10 | # application and not used in secure build a tree being for export only. |
| 11 | # This file is renamed to spe/CMakeList.txt during installation phase |
| 12 | |
| 13 | include(spe_config) |
| 14 | include(spe_export) |
| 15 | |
Antonio de Angelis | 8bb9851 | 2024-01-16 14:13:36 +0000 | [diff] [blame] | 16 | set_target_properties(tfm_config psa_interface psa_crypto_config PROPERTIES IMPORTED_GLOBAL True) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 17 | target_link_libraries(tfm_config INTERFACE psa_interface) |
| 18 | |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 19 | # In actual NS integration, NS side build should include the source files |
| 20 | # exported by TF-M build. |
| 21 | set(INTERFACE_SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/interface/src) |
| 22 | set(INTERFACE_INC_DIR ${CMAKE_CURRENT_LIST_DIR}/interface/include) |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 23 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}/platform) |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 24 | if (DEFINED NS_TARGET_NAME) |
| 25 | message(STATUS "Using NS_TARGET_NAME: ${NS_TARGET_NAME}") |
| 26 | else() |
| 27 | set(NS_TARGET_NAME "tfm_ns") |
| 28 | endif() |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 29 | |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 30 | add_library(tfm_api_ns STATIC) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 31 | |
| 32 | target_sources(tfm_api_ns |
David Hu | 0a07b63 | 2023-10-16 15:25:20 +0800 | [diff] [blame] | 33 | PUBLIC |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 34 | $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_api.c> |
| 35 | $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_api.c> |
| 36 | $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_api.c> |
| 37 | $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_api.c> |
| 38 | $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_attest_api.c> |
| 39 | $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_fwu_api.c> |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 40 | ) |
| 41 | |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 42 | # Include interface headers exported by TF-M |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 43 | target_include_directories(tfm_api_ns |
| 44 | PUBLIC |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 45 | ${INTERFACE_INC_DIR} |
| 46 | ${INTERFACE_INC_DIR}/crypto_keys |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 47 | ) |
| 48 | |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 49 | if (CONFIG_TFM_USE_TRUSTZONE) |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 50 | add_library(tfm_api_ns_tz STATIC) |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 51 | |
| 52 | target_sources(tfm_api_ns_tz |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 53 | PUBLIC |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 54 | ${INTERFACE_SRC_DIR}/tfm_tz_psa_ns_api.c |
| 55 | ) |
| 56 | |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 57 | target_include_directories(tfm_api_ns_tz |
| 58 | PUBLIC |
| 59 | ${INTERFACE_INC_DIR} |
| 60 | ) |
| 61 | |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 62 | target_link_libraries(tfm_api_ns_tz |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 63 | PRIVATE |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 64 | ${CMAKE_CURRENT_SOURCE_DIR}/interface/lib/s_veneers.o |
| 65 | ) |
| 66 | endif() |
| 67 | |
| 68 | if (TFM_PARTITION_NS_AGENT_MAILBOX) |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 69 | add_library(tfm_api_ns_mailbox STATIC) |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 70 | |
| 71 | target_sources(tfm_api_ns_mailbox |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 72 | PUBLIC |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 73 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c |
| 74 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c |
| 75 | ) |
| 76 | |
| 77 | target_include_directories(tfm_api_ns_mailbox |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 78 | PUBLIC |
| 79 | ${INTERFACE_INC_DIR} |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 80 | ${INTERFACE_INC_DIR}/multi_core |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame^] | 81 | ${PLATFORM_DIR}/ext/cmsis/Include |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 82 | ) |
| 83 | endif() |
| 84 | |
Antonio de Angelis | 8bb9851 | 2024-01-16 14:13:36 +0000 | [diff] [blame] | 85 | if (TFM_PARTITION_CRYPTO) |
| 86 | target_link_libraries(tfm_api_ns |
| 87 | PUBLIC |
| 88 | psa_crypto_config |
| 89 | ) |
| 90 | endif() |
| 91 | |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 92 | add_library(platform_region_defs INTERFACE) |
| 93 | |
| 94 | target_compile_definitions(platform_region_defs |
| 95 | INTERFACE |
| 96 | $<$<BOOL:${BL1}>:BL1> |
| 97 | $<$<BOOL:${BL2}>:BL2> |
| 98 | BL2_HEADER_SIZE=${BL2_HEADER_SIZE} |
| 99 | BL2_TRAILER_SIZE=${BL2_TRAILER_SIZE} |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 100 | $<$<BOOL:${MCUBOOT_IMAGE_NUMBER}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}> |
Dávid Házi | 7815773 | 2024-07-11 22:18:42 +0200 | [diff] [blame] | 101 | $<$<STREQUAL:${MCUBOOT_EXECUTION_SLOT},2>:LINK_TO_SECONDARY_PARTITION> |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 102 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_${TEST_PSA_API}> |
| 103 | $<$<OR:$<CONFIG:Debug>,$<CONFIG:relwithdebinfo>>:ENABLE_HEAP> |
| 104 | ) |
| 105 | |
| 106 | target_link_libraries(platform_region_defs |
| 107 | INTERFACE |
| 108 | tfm_config |
| 109 | ) |
| 110 | |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 111 | add_subdirectory(platform) |
| 112 | |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 113 | target_sources(platform_ns |
| 114 | PRIVATE |
| 115 | $<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/common/uart_stdout.c> |
| 116 | ) |
| 117 | |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 118 | add_library(platform_ns_definitions INTERFACE) |
| 119 | |
| 120 | # these compile definitions must match on the secure and nonsecure side for security |
| 121 | target_compile_definitions(platform_ns_definitions |
| 122 | INTERFACE |
Kevin Peng | 7dc0ebf | 2023-11-14 14:31:31 +0800 | [diff] [blame] | 123 | DOMAIN_NS=1 |
Anton Komlev | 8dc9eb2 | 2023-09-15 15:53:03 +0100 | [diff] [blame] | 124 | $<$<BOOL:${PLATFORM_DEFAULT_CRYPTO_KEYS}>:PLATFORM_DEFAULT_CRYPTO_KEYS> |
| 125 | $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},hard>:CONFIG_TFM_FLOAT_ABI=2> |
| 126 | $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},soft>:CONFIG_TFM_FLOAT_ABI=0> |
Roman Mazurak | 0a79e67 | 2024-08-14 16:48:13 +0300 | [diff] [blame] | 127 | $<$<BOOL:${CONFIG_TFM_DISABLE_CP10CP11}>:CONFIG_TFM_DISABLE_CP10CP11> |
Anton Komlev | 8dc9eb2 | 2023-09-15 15:53:03 +0100 | [diff] [blame] | 128 | $<$<BOOL:${CONFIG_TFM_ENABLE_CP10CP11}>:CONFIG_TFM_ENABLE_CP10CP11> |
| 129 | ) |
| 130 | |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 131 | target_link_libraries(platform_ns |
| 132 | PUBLIC |
| 133 | platform_ns_definitions |
| 134 | ) |
| 135 | |
| 136 | if (DEFINED PLATFORM_CUSTOM_NS_FILES) |
| 137 | message(STATUS "Using PLATFORM_CUSTOM_NS_FILES: ${PLATFORM_CUSTOM_NS_FILES}") |
| 138 | else() |
| 139 | set(PLATFORM_CUSTOM_NS_FILES FALSE) |
| 140 | endif() |
| 141 | |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 142 | target_link_libraries(tfm_api_ns |
| 143 | PUBLIC |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 144 | platform_region_defs |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 145 | platform_ns_definitions |
| 146 | $<$<NOT:$<BOOL:${PLATFORM_CUSTOM_NS_FILES}>>:platform_ns> |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 147 | ) |
| 148 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 149 | if(BL2 AND PLATFORM_DEFAULT_IMAGE_SIGNING) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 150 | |
David Hu | a5fefdc | 2023-11-03 13:24:41 +0800 | [diff] [blame] | 151 | find_package(Python3) |
| 152 | |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 153 | add_custom_target(tfm_s_ns_signed_bin |
| 154 | ALL |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 155 | SOURCES ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 156 | ) |
| 157 | |
Gergely Kovacs | aae6d78 | 2024-10-11 07:21:30 +0000 | [diff] [blame] | 158 | if (DEFINED S_NS_SIGNED_TARGET_NAME) |
| 159 | message(STATUS "Using S_NS_SIGNED_TARGET_NAME: ${S_NS_SIGNED_TARGET_NAME}") |
| 160 | else() |
| 161 | set(S_NS_SIGNED_TARGET_NAME tfm_s_ns_signed) |
| 162 | endif() |
| 163 | |
| 164 | add_custom_command( |
| 165 | TARGET tfm_s_ns_signed_bin |
| 166 | POST_BUILD |
| 167 | COMMAND ${CMAKE_COMMAND} -E copy |
| 168 | ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 169 | $<TARGET_FILE_DIR:${NS_TARGET_NAME}>/${S_NS_SIGNED_TARGET_NAME}.bin |
Gergely Kovacs | aae6d78 | 2024-10-11 07:21:30 +0000 | [diff] [blame] | 170 | ) |
| 171 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 172 | if (MCUBOOT_IMAGE_NUMBER GREATER 1) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 173 | |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 174 | set(wrapper_args |
| 175 | --version ${MCUBOOT_IMAGE_VERSION_NS} |
| 176 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_ns.o |
| 177 | --key ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_ns_signing_private_key.pem |
| 178 | --public-key-format $<IF:$<BOOL:${MCUBOOT_HW_KEY}>,full,hash> |
| 179 | --align ${MCUBOOT_ALIGN_VAL} |
| 180 | --pad |
| 181 | --pad-header |
| 182 | -H ${BL2_HEADER_SIZE} |
| 183 | -s ${MCUBOOT_SECURITY_COUNTER_NS} |
| 184 | -L ${MCUBOOT_ENC_KEY_LEN} |
| 185 | -d \"\(0, ${MCUBOOT_S_IMAGE_MIN_VER}\)\" |
| 186 | $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},OVERWRITE_ONLY>:--overwrite-only> |
| 187 | $<$<BOOL:${MCUBOOT_CONFIRM_IMAGE}>:--confirm> |
| 188 | $<$<BOOL:${MCUBOOT_ENC_IMAGES}>:-E${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_enc_key.pem> |
| 189 | $<$<BOOL:${MCUBOOT_MEASURED_BOOT}>:--measured-boot-record> |
| 190 | $<TARGET_FILE_DIR:${NS_TARGET_NAME}>/${NS_TARGET_NAME}.bin |
| 191 | ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
| 192 | ) |
| 193 | |
| 194 | if(MCUBOOT_BUILTIN_KEY) |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 195 | set(wrapper_args ${wrapper_args} --psa-key-ids ${TFM_NS_KEY_ID}) |
| 196 | endif() |
| 197 | |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 198 | add_custom_target(${NS_TARGET_NAME}_signed_bin |
| 199 | SOURCES ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 200 | ) |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 201 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
Anton Komlev | c88e2ac | 2024-09-12 16:46:39 +0100 | [diff] [blame] | 202 | DEPENDS ${NS_TARGET_NAME}_bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 203 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_ns.o |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 204 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 205 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 206 | #Sign non-secure binary image with provided secret key |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 207 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/wrapper/wrapper.py ${wrapper_args} |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 208 | ) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 209 | |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 210 | # Create concatenated binary image from the two independently signed |
| 211 | # binary file. This only uses the local assemble.py script (not from |
| 212 | # upstream mcuboot) because that script is geared towards zephyr |
| 213 | # support |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 214 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 215 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s_signed.bin |
Anton Komlev | c88e2ac | 2024-09-12 16:46:39 +0100 | [diff] [blame] | 216 | DEPENDS ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 217 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s.o |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 218 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 219 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 220 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/assemble.py |
| 221 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s.o |
| 222 | --secure ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s_signed.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 223 | --non_secure ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 224 | --output ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 225 | ) |
| 226 | else() |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 227 | add_custom_target(tfm_s_ns_bin |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 228 | SOURCES ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 229 | ) |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 230 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 231 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s.bin |
Anton Komlev | 8ab4f04 | 2025-06-03 21:13:07 +0100 | [diff] [blame] | 232 | DEPENDS ${NS_TARGET_NAME}_bin |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 233 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
| 234 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 235 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 236 | # concatenate S + NS binaries into tfm_s_ns.bin |
| 237 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/assemble.py |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 238 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 239 | --secure ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 240 | --non_secure $<TARGET_FILE_DIR:${NS_TARGET_NAME}>/${NS_TARGET_NAME}.bin |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 241 | --output ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 242 | ) |
| 243 | |
Maulik Patel | 439be35 | 2025-04-15 14:34:28 +0100 | [diff] [blame] | 244 | set(wrapper_args |
| 245 | --version ${MCUBOOT_IMAGE_VERSION_S} |
| 246 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
| 247 | --key ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_s_signing_private_key.pem |
| 248 | --public-key-format $<IF:$<BOOL:${MCUBOOT_HW_KEY}>,full,hash> |
| 249 | --align ${MCUBOOT_ALIGN_VAL} |
| 250 | --pad |
| 251 | --pad-header |
| 252 | -H ${BL2_HEADER_SIZE} |
| 253 | -s ${MCUBOOT_SECURITY_COUNTER_S} |
| 254 | -L ${MCUBOOT_ENC_KEY_LEN} |
| 255 | $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},OVERWRITE_ONLY>:--overwrite-only> |
| 256 | $<$<BOOL:${MCUBOOT_CONFIRM_IMAGE}>:--confirm> |
| 257 | $<$<BOOL:${MCUBOOT_ENC_IMAGES}>:-E${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_enc_key.pem> |
| 258 | $<$<BOOL:${MCUBOOT_MEASURED_BOOT}>:--measured-boot-record> |
| 259 | ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
| 260 | ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
| 261 | ) |
| 262 | |
| 263 | if(MCUBOOT_BUILTIN_KEY) |
| 264 | set(wrapper_args ${wrapper_args} --psa-key-ids ${TFM_S_KEY_ID}) |
| 265 | endif() |
| 266 | |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 267 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
| 268 | DEPENDS tfm_s_ns_bin ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 269 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 270 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 271 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 272 | # sign the combined tfm_s_ns.bin file |
| 273 | COMMAND ${Python3_EXECUTABLE} |
| 274 | ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/wrapper/wrapper.py |
Maulik Patel | 439be35 | 2025-04-15 14:34:28 +0100 | [diff] [blame] | 275 | ${wrapper_args} |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 276 | ) |
| 277 | endif() |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 278 | endif() |