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 | |
Nicola Mazzucato | 6414e29 | 2025-05-09 22:05:05 +0100 | [diff] [blame] | 68 | if (TFM_HYBRID_PLATFORM_API_BROKER) |
| 69 | add_library(tfm_api_broker STATIC) |
| 70 | target_sources(tfm_api_broker |
| 71 | PUBLIC |
| 72 | ${INTERFACE_SRC_DIR}/hybrid_platform/api_broker.c |
| 73 | ) |
| 74 | |
| 75 | target_compile_definitions(tfm_api_broker |
| 76 | PUBLIC |
| 77 | TFM_HYBRID_PLATFORM_API_BROKER |
| 78 | ) |
| 79 | |
| 80 | target_include_directories(tfm_api_broker |
| 81 | PUBLIC |
| 82 | ${INTERFACE_INC_DIR} |
| 83 | ) |
| 84 | |
| 85 | target_link_libraries(tfm_api_ns_tz PUBLIC tfm_api_broker) |
| 86 | |
| 87 | endif() |
| 88 | |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 89 | if (TFM_PARTITION_NS_AGENT_MAILBOX) |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame] | 90 | add_library(tfm_api_ns_mailbox STATIC) |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 91 | |
| 92 | target_sources(tfm_api_ns_mailbox |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame] | 93 | PUBLIC |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 94 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c |
| 95 | ${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c |
Nicola Mazzucato | 6414e29 | 2025-05-09 22:05:05 +0100 | [diff] [blame] | 96 | ${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox.c |
| 97 | ${INTERFACE_SRC_DIR}/multi_core/platform_ns_mailbox.c |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 98 | ) |
| 99 | |
| 100 | target_include_directories(tfm_api_ns_mailbox |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame] | 101 | PUBLIC |
| 102 | ${INTERFACE_INC_DIR} |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 103 | ${INTERFACE_INC_DIR}/multi_core |
Nicola Mazzucato | 1d39bd0 | 2025-06-06 20:41:10 +0100 | [diff] [blame] | 104 | ${PLATFORM_DIR}/ext/cmsis/Include |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 105 | ) |
Nicola Mazzucato | 6414e29 | 2025-05-09 22:05:05 +0100 | [diff] [blame] | 106 | |
| 107 | target_compile_definitions(tfm_api_ns_mailbox |
| 108 | PUBLIC |
| 109 | $<$<BOOL:${TFM_HYBRID_PLATFORM_API_BROKER}>:TFM_HYBRID_PLATFORM_API_BROKER> |
| 110 | ) |
Jamie Fox | c0489cc | 2023-11-28 17:55:36 +0000 | [diff] [blame] | 111 | endif() |
| 112 | |
Antonio de Angelis | 8bb9851 | 2024-01-16 14:13:36 +0000 | [diff] [blame] | 113 | if (TFM_PARTITION_CRYPTO) |
| 114 | target_link_libraries(tfm_api_ns |
| 115 | PUBLIC |
| 116 | psa_crypto_config |
| 117 | ) |
| 118 | endif() |
| 119 | |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 120 | add_library(platform_region_defs INTERFACE) |
| 121 | |
| 122 | target_compile_definitions(platform_region_defs |
| 123 | INTERFACE |
| 124 | $<$<BOOL:${BL1}>:BL1> |
| 125 | $<$<BOOL:${BL2}>:BL2> |
| 126 | BL2_HEADER_SIZE=${BL2_HEADER_SIZE} |
| 127 | BL2_TRAILER_SIZE=${BL2_TRAILER_SIZE} |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 128 | $<$<BOOL:${MCUBOOT_IMAGE_NUMBER}>:MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}> |
Dávid Házi | 7815773 | 2024-07-11 22:18:42 +0200 | [diff] [blame] | 129 | $<$<STREQUAL:${MCUBOOT_EXECUTION_SLOT},2>:LINK_TO_SECONDARY_PARTITION> |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 130 | $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_${TEST_PSA_API}> |
| 131 | $<$<OR:$<CONFIG:Debug>,$<CONFIG:relwithdebinfo>>:ENABLE_HEAP> |
| 132 | ) |
| 133 | |
| 134 | target_link_libraries(platform_region_defs |
| 135 | INTERFACE |
| 136 | tfm_config |
| 137 | ) |
| 138 | |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 139 | add_subdirectory(platform) |
| 140 | |
David Hu | b27a663 | 2023-10-23 22:38:39 +0800 | [diff] [blame] | 141 | target_sources(platform_ns |
| 142 | PRIVATE |
| 143 | $<$<BOOL:${PLATFORM_DEFAULT_UART_STDOUT}>:${CMAKE_CURRENT_SOURCE_DIR}/platform/ext/common/uart_stdout.c> |
| 144 | ) |
| 145 | |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 146 | add_library(platform_ns_definitions INTERFACE) |
| 147 | |
| 148 | # these compile definitions must match on the secure and nonsecure side for security |
| 149 | target_compile_definitions(platform_ns_definitions |
| 150 | INTERFACE |
Kevin Peng | 7dc0ebf | 2023-11-14 14:31:31 +0800 | [diff] [blame] | 151 | DOMAIN_NS=1 |
Anton Komlev | 8dc9eb2 | 2023-09-15 15:53:03 +0100 | [diff] [blame] | 152 | $<$<BOOL:${PLATFORM_DEFAULT_CRYPTO_KEYS}>:PLATFORM_DEFAULT_CRYPTO_KEYS> |
| 153 | $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},hard>:CONFIG_TFM_FLOAT_ABI=2> |
| 154 | $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},soft>:CONFIG_TFM_FLOAT_ABI=0> |
Roman Mazurak | 0a79e67 | 2024-08-14 16:48:13 +0300 | [diff] [blame] | 155 | $<$<BOOL:${CONFIG_TFM_DISABLE_CP10CP11}>:CONFIG_TFM_DISABLE_CP10CP11> |
Anton Komlev | 8dc9eb2 | 2023-09-15 15:53:03 +0100 | [diff] [blame] | 156 | $<$<BOOL:${CONFIG_TFM_ENABLE_CP10CP11}>:CONFIG_TFM_ENABLE_CP10CP11> |
| 157 | ) |
| 158 | |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 159 | target_link_libraries(platform_ns |
| 160 | PUBLIC |
| 161 | platform_ns_definitions |
| 162 | ) |
| 163 | |
| 164 | if (DEFINED PLATFORM_CUSTOM_NS_FILES) |
| 165 | message(STATUS "Using PLATFORM_CUSTOM_NS_FILES: ${PLATFORM_CUSTOM_NS_FILES}") |
| 166 | else() |
| 167 | set(PLATFORM_CUSTOM_NS_FILES FALSE) |
| 168 | endif() |
| 169 | |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 170 | target_link_libraries(tfm_api_ns |
| 171 | PUBLIC |
David Hu | 35aa1a5 | 2023-10-24 23:04:04 +0800 | [diff] [blame] | 172 | platform_region_defs |
Gergely Kovacs | 5206a41 | 2024-10-14 09:49:57 +0000 | [diff] [blame] | 173 | platform_ns_definitions |
| 174 | $<$<NOT:$<BOOL:${PLATFORM_CUSTOM_NS_FILES}>>:platform_ns> |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 175 | ) |
| 176 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 177 | if(BL2 AND PLATFORM_DEFAULT_IMAGE_SIGNING) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 178 | |
David Hu | a5fefdc | 2023-11-03 13:24:41 +0800 | [diff] [blame] | 179 | find_package(Python3) |
| 180 | |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 181 | add_custom_target(tfm_s_ns_signed_bin |
| 182 | ALL |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 183 | SOURCES ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 184 | ) |
| 185 | |
Gergely Kovacs | aae6d78 | 2024-10-11 07:21:30 +0000 | [diff] [blame] | 186 | if (DEFINED S_NS_SIGNED_TARGET_NAME) |
| 187 | message(STATUS "Using S_NS_SIGNED_TARGET_NAME: ${S_NS_SIGNED_TARGET_NAME}") |
| 188 | else() |
| 189 | set(S_NS_SIGNED_TARGET_NAME tfm_s_ns_signed) |
| 190 | endif() |
| 191 | |
| 192 | add_custom_command( |
| 193 | TARGET tfm_s_ns_signed_bin |
| 194 | POST_BUILD |
| 195 | COMMAND ${CMAKE_COMMAND} -E copy |
| 196 | ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 197 | $<TARGET_FILE_DIR:${NS_TARGET_NAME}>/${S_NS_SIGNED_TARGET_NAME}.bin |
Gergely Kovacs | aae6d78 | 2024-10-11 07:21:30 +0000 | [diff] [blame] | 198 | ) |
| 199 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 200 | if (MCUBOOT_IMAGE_NUMBER GREATER 1) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 201 | |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 202 | set(wrapper_args |
| 203 | --version ${MCUBOOT_IMAGE_VERSION_NS} |
| 204 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_ns.o |
| 205 | --key ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_ns_signing_private_key.pem |
| 206 | --public-key-format $<IF:$<BOOL:${MCUBOOT_HW_KEY}>,full,hash> |
| 207 | --align ${MCUBOOT_ALIGN_VAL} |
| 208 | --pad |
| 209 | --pad-header |
| 210 | -H ${BL2_HEADER_SIZE} |
| 211 | -s ${MCUBOOT_SECURITY_COUNTER_NS} |
| 212 | -L ${MCUBOOT_ENC_KEY_LEN} |
| 213 | -d \"\(0, ${MCUBOOT_S_IMAGE_MIN_VER}\)\" |
| 214 | $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},OVERWRITE_ONLY>:--overwrite-only> |
| 215 | $<$<BOOL:${MCUBOOT_CONFIRM_IMAGE}>:--confirm> |
| 216 | $<$<BOOL:${MCUBOOT_ENC_IMAGES}>:-E${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_enc_key.pem> |
| 217 | $<$<BOOL:${MCUBOOT_MEASURED_BOOT}>:--measured-boot-record> |
| 218 | $<TARGET_FILE_DIR:${NS_TARGET_NAME}>/${NS_TARGET_NAME}.bin |
| 219 | ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
| 220 | ) |
| 221 | |
| 222 | if(MCUBOOT_BUILTIN_KEY) |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 223 | set(wrapper_args ${wrapper_args} --psa-key-ids ${TFM_NS_KEY_ID}) |
| 224 | endif() |
| 225 | |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 226 | add_custom_target(${NS_TARGET_NAME}_signed_bin |
| 227 | SOURCES ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 228 | ) |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 229 | 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] | 230 | DEPENDS ${NS_TARGET_NAME}_bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 231 | 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] | 232 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 233 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 234 | #Sign non-secure binary image with provided secret key |
Maulik Patel | d1afad0 | 2025-04-14 13:04:35 +0100 | [diff] [blame] | 235 | 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] | 236 | ) |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 237 | |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 238 | # Create concatenated binary image from the two independently signed |
| 239 | # binary file. This only uses the local assemble.py script (not from |
| 240 | # upstream mcuboot) because that script is geared towards zephyr |
| 241 | # support |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 242 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 243 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s_signed.bin |
Anton Komlev | c88e2ac | 2024-09-12 16:46:39 +0100 | [diff] [blame] | 244 | DEPENDS ${CMAKE_BINARY_DIR}/bin/${NS_TARGET_NAME}_signed.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 245 | 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] | 246 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 247 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 248 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/assemble.py |
| 249 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s.o |
| 250 | --secure ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s_signed.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 251 | --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] | 252 | --output ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 253 | ) |
| 254 | else() |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 255 | add_custom_target(tfm_s_ns_bin |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 256 | SOURCES ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 257 | ) |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 258 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 259 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s.bin |
Anton Komlev | 8ab4f04 | 2025-06-03 21:13:07 +0100 | [diff] [blame] | 260 | DEPENDS ${NS_TARGET_NAME}_bin |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 261 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
| 262 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 263 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 264 | # concatenate S + NS binaries into tfm_s_ns.bin |
| 265 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/assemble.py |
David Hu | b5f10a5 | 2023-10-26 22:24:10 +0800 | [diff] [blame] | 266 | --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] | 267 | --secure ${CMAKE_CURRENT_SOURCE_DIR}/bin/tfm_s.bin |
Gergely Kovacs | 4d50f25 | 2024-10-07 10:23:36 +0000 | [diff] [blame] | 268 | --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] | 269 | --output ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
David Hu | a01be0a | 2023-10-25 23:08:10 +0800 | [diff] [blame] | 270 | ) |
| 271 | |
Maulik Patel | 439be35 | 2025-04-15 14:34:28 +0100 | [diff] [blame] | 272 | set(wrapper_args |
| 273 | --version ${MCUBOOT_IMAGE_VERSION_S} |
| 274 | --layout ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/layout_files/signing_layout_s_ns.o |
| 275 | --key ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_s_signing_private_key.pem |
| 276 | --public-key-format $<IF:$<BOOL:${MCUBOOT_HW_KEY}>,full,hash> |
| 277 | --align ${MCUBOOT_ALIGN_VAL} |
| 278 | --pad |
| 279 | --pad-header |
| 280 | -H ${BL2_HEADER_SIZE} |
| 281 | -s ${MCUBOOT_SECURITY_COUNTER_S} |
| 282 | -L ${MCUBOOT_ENC_KEY_LEN} |
| 283 | $<$<STREQUAL:${MCUBOOT_UPGRADE_STRATEGY},OVERWRITE_ONLY>:--overwrite-only> |
| 284 | $<$<BOOL:${MCUBOOT_CONFIRM_IMAGE}>:--confirm> |
| 285 | $<$<BOOL:${MCUBOOT_ENC_IMAGES}>:-E${CMAKE_CURRENT_SOURCE_DIR}/image_signing/keys/image_enc_key.pem> |
| 286 | $<$<BOOL:${MCUBOOT_MEASURED_BOOT}>:--measured-boot-record> |
| 287 | ${CMAKE_BINARY_DIR}/bin/tfm_s_ns.bin |
| 288 | ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
| 289 | ) |
| 290 | |
| 291 | if(MCUBOOT_BUILTIN_KEY) |
| 292 | set(wrapper_args ${wrapper_args} --psa-key-ids ${TFM_S_KEY_ID}) |
| 293 | endif() |
| 294 | |
Dávid Házi | 1a72fd4 | 2024-03-06 18:33:45 +0100 | [diff] [blame] | 295 | add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/tfm_s_ns_signed.bin |
| 296 | 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] | 297 | 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] | 298 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 299 | |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 300 | # sign the combined tfm_s_ns.bin file |
| 301 | COMMAND ${Python3_EXECUTABLE} |
| 302 | ${CMAKE_CURRENT_SOURCE_DIR}/image_signing/scripts/wrapper/wrapper.py |
Maulik Patel | 439be35 | 2025-04-15 14:34:28 +0100 | [diff] [blame] | 303 | ${wrapper_args} |
Dávid Házi | 34cf9b9 | 2023-10-11 11:10:41 +0200 | [diff] [blame] | 304 | ) |
| 305 | endif() |
Anton Komlev | aee4b61 | 2023-05-14 17:38:36 +0100 | [diff] [blame] | 306 | endif() |