CMakeLists.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. # Copyright (c) 2019, 2020 Linaro
  2. # Copyright (c) 2020, 2021 Nordic Semiconductor ASA
  3. #
  4. # SPDX-License-Identifier: Apache-2.0
  5. # List of all partitions supported by TF-M
  6. # Name must match name in 'trusted-firmware-m/config/config_default.cmake'
  7. set(TFM_VALID_PARTITIONS
  8. TFM_PARTITION_PROTECTED_STORAGE
  9. TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
  10. TFM_PARTITION_CRYPTO
  11. TFM_PARTITION_INITIAL_ATTESTATION
  12. TFM_PARTITION_PLATFORM
  13. TFM_PARTITION_AUDIT_LOG
  14. )
  15. # List of all crypto modules that can be enabled/disabled
  16. # Corresponds to the *_MODULE_DISABLED configs in 'trusted-firmware-m/config/config_default.cmake'
  17. set(TFM_CRYPTO_MODULES
  18. CRYPTO_RNG_MODULE
  19. CRYPTO_KEY_MODULE
  20. CRYPTO_AEAD_MODULE
  21. CRYPTO_MAC_MODULE
  22. CRYPTO_HASH_MODULE
  23. CRYPTO_CIPHER_MODULE
  24. CRYPTO_GENERATOR_MODULE
  25. CRYPTO_ASYMMETRIC_MODULE
  26. CRYPTO_KEY_DERIVATION_MODULE
  27. )
  28. if (CONFIG_BUILD_WITH_TFM)
  29. if (CONFIG_TFM_IPC)
  30. list(APPEND TFM_CMAKE_ARGS -DTFM_PSA_API=ON)
  31. # PSA API awareness for the Non-Secure application
  32. target_compile_definitions(app PRIVATE "TFM_PSA_API")
  33. endif()
  34. if (CONFIG_TFM_REGRESSION_S)
  35. list(APPEND TFM_CMAKE_ARGS -DTEST_S=ON)
  36. endif()
  37. if (CONFIG_TFM_REGRESSION_NS)
  38. list(APPEND TFM_CMAKE_ARGS -DTEST_NS=ON)
  39. endif()
  40. if (CONFIG_TFM_BL2)
  41. list(APPEND TFM_CMAKE_ARGS -DBL2=TRUE)
  42. else()
  43. list(APPEND TFM_CMAKE_ARGS -DBL2=FALSE)
  44. endif()
  45. if (CONFIG_TFM_ISOLATION_LEVEL)
  46. list(APPEND TFM_CMAKE_ARGS -DTFM_ISOLATION_LEVEL=${CONFIG_TFM_ISOLATION_LEVEL})
  47. endif()
  48. if (CONFIG_TFM_PROFILE)
  49. list(APPEND TFM_CMAKE_ARGS -DTFM_PROFILE=${CONFIG_TFM_PROFILE})
  50. endif()
  51. if (CONFIG_TFM_PSA_TEST_CRYPTO)
  52. set(TFM_PSA_TEST_SUITE CRYPTO)
  53. elseif (CONFIG_TFM_PSA_TEST_PROTECTED_STORAGE)
  54. set(TFM_PSA_TEST_SUITE PROTECTED_STORAGE)
  55. elseif (CONFIG_TFM_PSA_TEST_INTERNAL_TRUSTED_STORAGE)
  56. set(TFM_PSA_TEST_SUITE INTERNAL_TRUSTED_STORAGE)
  57. elseif (CONFIG_TFM_PSA_TEST_STORAGE)
  58. set(TFM_PSA_TEST_SUITE STORAGE)
  59. elseif (CONFIG_TFM_PSA_TEST_INITIAL_ATTESTATION)
  60. set(TFM_PSA_TEST_SUITE INITIAL_ATTESTATION)
  61. endif()
  62. if (DEFINED TFM_PSA_TEST_SUITE)
  63. list(APPEND TFM_CMAKE_ARGS -DTEST_PSA_API=${TFM_PSA_TEST_SUITE})
  64. endif()
  65. if (CONFIG_TFM_CMAKE_BUILD_TYPE_RELEASE)
  66. set(TFM_CMAKE_BUILD_TYPE "Release")
  67. elseif (CONFIG_TFM_CMAKE_BUILD_TYPE_MINSIZEREL)
  68. set(TFM_CMAKE_BUILD_TYPE "MinSizeRel")
  69. elseif (CONFIG_TFM_CMAKE_BUILD_TYPE_DEBUG)
  70. set(TFM_CMAKE_BUILD_TYPE "Debug")
  71. else ()
  72. set(TFM_CMAKE_BUILD_TYPE "RelWithDebInfo")
  73. endif()
  74. if (DEFINED CONFIG_TFM_MCUBOOT_IMAGE_NUMBER)
  75. list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_IMAGE_NUMBER=${CONFIG_TFM_MCUBOOT_IMAGE_NUMBER})
  76. endif()
  77. # Enable TFM partitions as specified in Kconfig
  78. foreach(partition ${TFM_VALID_PARTITIONS})
  79. if (CONFIG_${partition})
  80. # list(APPEND TFM_ENABLED_PARTITIONS_ARG ${partition})
  81. set(val "ON")
  82. else()
  83. set(val "OFF")
  84. endif()
  85. list(APPEND TFM_CMAKE_ARGS -D${partition}=${val})
  86. endforeach()
  87. # Enable TFM crypto modules as specified in Kconfig
  88. foreach(module ${TFM_CRYPTO_MODULES})
  89. if (CONFIG_TFM_${module}_ENABLED)
  90. # list(APPEND TFM_ENABLED_CRYPTO_MODULES_ARG ${module})
  91. set(val "FALSE")
  92. else()
  93. set(val "TRUE")
  94. endif()
  95. list(APPEND TFM_CMAKE_ARGS -D${module}_DISABLED=${val})
  96. endforeach()
  97. set(TFM_BINARY_DIR ${CMAKE_BINARY_DIR}/tfm)
  98. set(VENEERS_FILE ${TFM_BINARY_DIR}/secure_fw/s_veneers.o)
  99. set(TFM_API_NS_PATH ${TFM_BINARY_DIR}/app/libtfm_api_ns.a)
  100. set(TFM_GENERATED_INCLUDES ${TFM_BINARY_DIR}/generated/interface/include)
  101. set(PLATFORM_NS_FILE ${TFM_BINARY_DIR}/platform/libplatform_ns.a)
  102. if (TFM_PSA_TEST_SUITE)
  103. set(PSA_TEST_VAL_FILE ${TFM_BINARY_DIR}/app/psa_api_tests/val/val_nspe.a)
  104. set(PSA_TEST_PAL_FILE ${TFM_BINARY_DIR}/app/psa_api_tests/platform/pal_nspe.a)
  105. set(COMBINE_DIR_STORAGE storage)
  106. set(COMBINE_DIR_PROTECTED_STORAGE storage)
  107. set(COMBINE_DIR_INTERNAL_TRUSTED_STORAGE storage)
  108. set(COMBINE_DIR_CRYPTO crypto)
  109. set(COMBINE_DIR_INITIAL_ATTESTATION initial_attestation)
  110. set(PSA_TEST_COMBINE_FILE ${TFM_BINARY_DIR}/app/psa_api_tests/dev_apis/${COMBINE_DIR_${TFM_PSA_TEST_SUITE}}/test_combine.a)
  111. endif()
  112. if(CONFIG_TFM_BL2)
  113. set(BL2_BIN_FILE ${TFM_BINARY_DIR}/bin/bl2.bin)
  114. set(BL2_HEX_FILE ${TFM_BINARY_DIR}/bin/bl2.hex)
  115. endif()
  116. set(TFM_S_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s.bin)
  117. set(TFM_S_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_s.hex)
  118. set(TFM_NS_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns.bin)
  119. set(TFM_NS_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_ns.hex)
  120. set(TFM_S_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s_signed.bin)
  121. set(TFM_NS_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns_signed.bin)
  122. set(TFM_S_NS_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s_ns_signed.bin)
  123. set(BUILD_BYPRODUCTS
  124. ${VENEERS_FILE}
  125. ${TFM_API_NS_PATH}
  126. ${TFM_GENERATED_INCLUDES}/psa_manifest/sid.h
  127. ${PSA_TEST_VAL_FILE}
  128. ${PSA_TEST_PAL_FILE}
  129. ${PSA_TEST_COMBINE_FILE}
  130. ${PLATFORM_NS_FILE}
  131. ${BL2_BIN_FILE}
  132. ${BL2_HEX_FILE}
  133. ${TFM_S_BIN_FILE}
  134. ${TFM_S_HEX_FILE}
  135. ${TFM_NS_BIN_FILE}
  136. ${TFM_NS_HEX_FILE}
  137. ${TFM_S_SIGNED_BIN_FILE}
  138. ${TFM_NS_SIGNED_BIN_FILE}
  139. ${TFM_S_NS_SIGNED_BIN_FILE}
  140. )
  141. # Get the toolchain variant
  142. # TODO: Add support for cross-compile toolchain variant
  143. # TODO: Enforce GCC version check against TF-M compiler requirements
  144. if(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "zephyr")
  145. set(TFM_TOOLCHAIN_FILE "trusted-firmware-m/toolchain_GNUARM.cmake")
  146. set(TFM_TOOLCHAIN_PREFIX "arm-zephyr-eabi")
  147. set(TFM_TOOLCHAIN_PATH ${ZEPHYR_SDK_INSTALL_DIR}/arm-zephyr-eabi/bin)
  148. elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "gnuarmemb")
  149. set(TFM_TOOLCHAIN_FILE "trusted-firmware-m/toolchain_GNUARM.cmake")
  150. set(TFM_TOOLCHAIN_PREFIX "arm-none-eabi")
  151. set(TFM_TOOLCHAIN_PATH ${GNUARMEMB_TOOLCHAIN_PATH}/bin)
  152. elseif(${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "xtools")
  153. set(TFM_TOOLCHAIN_FILE "trusted-firmware-m/toolchain_GNUARM.cmake")
  154. set(TFM_TOOLCHAIN_PREFIX "arm-zephyr-eabi")
  155. set(TFM_TOOLCHAIN_PATH ${XTOOLS_TOOLCHAIN_PATH}/arm-zephyr-eabi/bin)
  156. else()
  157. message(FATAL_ERROR "Unsupported ZEPHYR_TOOLCHAIN_VARIANT: ${ZEPHYR_TOOLCHAIN_VARIANT}")
  158. endif()
  159. if(CONFIG_BOARD_LPCXPRESSO55S69_CPU0)
  160. # Supply path to NXP HAL sources used for TF-M build
  161. set(TFM_PLATFORM_NXP_HAL_FILE_PATH ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m/platform/ext/target/nxp/)
  162. list(APPEND TFM_CMAKE_ARGS -DTFM_PLATFORM_NXP_HAL_FILE_PATH=${TFM_PLATFORM_NXP_HAL_FILE_PATH})
  163. endif()
  164. if(CONFIG_TFM_BL2 AND CONFIG_TFM_MCUBOOT_PATH_LOCAL)
  165. # Supply path to MCUboot for TF-M build
  166. list(APPEND TFM_CMAKE_ARGS -DMCUBOOT_PATH=${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/../../../bootloader/mcuboot)
  167. endif()
  168. file(MAKE_DIRECTORY ${TFM_BINARY_DIR})
  169. add_custom_target(tfm_cmake
  170. DEPENDS ${TFM_BINARY_DIR}/CMakeCache.txt
  171. )
  172. add_custom_command(
  173. OUTPUT ${TFM_BINARY_DIR}/CMakeCache.txt
  174. COMMAND ${CMAKE_COMMAND}
  175. -G${CMAKE_GENERATOR}
  176. -DTFM_TOOLCHAIN_FILE=${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/${TFM_TOOLCHAIN_FILE}
  177. -DTFM_PLATFORM=${TFM_BOARD}
  178. -DCROSS_COMPILE=${TFM_TOOLCHAIN_PATH}/${TFM_TOOLCHAIN_PREFIX}
  179. -DCMAKE_BUILD_TYPE=${TFM_CMAKE_BUILD_TYPE}
  180. -DTFM_PLATFORM=${CONFIG_TFM_BOARD}
  181. ${TFM_CMAKE_ARGS}
  182. $<GENEX_EVAL:$<TARGET_PROPERTY:zephyr_property_target,TFM_CMAKE_OPTIONS>>
  183. -DTFM_TEST_REPO_PATH=${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/tf-m-tests
  184. -DMBEDCRYPTO_PATH=$<IF:$<BOOL:$<TARGET_PROPERTY:zephyr_property_target,TFM_MBEDCRYPTO_PATH>>,$<TARGET_PROPERTY:zephyr_property_target,TFM_MBEDCRYPTO_PATH>,${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/../../crypto/mbedtls/mbedtls>
  185. -DPSA_ARCH_TESTS_PATH=${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/psa-arch-tests
  186. ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m
  187. WORKING_DIRECTORY ${TFM_BINARY_DIR}
  188. COMMAND_EXPAND_LISTS
  189. )
  190. include(ExternalProject)
  191. ExternalProject_Add(
  192. tfm
  193. SOURCE_DIR ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m
  194. BINARY_DIR ${TFM_BINARY_DIR}
  195. CONFIGURE_COMMAND ""
  196. BUILD_COMMAND ${CMAKE_COMMAND} --build .
  197. INSTALL_COMMAND ${CMAKE_COMMAND} --install .
  198. BUILD_ALWAYS True
  199. USES_TERMINAL_BUILD True
  200. DEPENDS tfm_cmake
  201. BUILD_BYPRODUCTS ${BUILD_BYPRODUCTS}
  202. )
  203. # Set BL2 (MCUboot) executable file paths as target properties on 'tfm'
  204. # These files are produced by the TFM build system.
  205. if(CONFIG_TFM_BL2)
  206. set_target_properties(tfm PROPERTIES
  207. BL2_BIN_FILE ${BL2_BIN_FILE}
  208. BL2_HEX_FILE ${BL2_HEX_FILE}
  209. )
  210. endif()
  211. # Set TFM S/NS executable file paths as target properties on 'tfm'
  212. # These files are produced by the TFM build system.
  213. # Note that the Nonsecure FW is replaced by the Zephyr app in regular Zephyr
  214. # builds.
  215. set_target_properties(tfm PROPERTIES
  216. TFM_S_BIN_FILE ${TFM_S_BIN_FILE} # TFM Secure FW (unsigned)
  217. TFM_S_HEX_FILE ${TFM_S_HEX_FILE} # TFM Secure FW (unsigned)
  218. TFM_NS_BIN_FILE ${TFM_NS_BIN_FILE} # TFM Nonsecure FW (unsigned)
  219. TFM_NS_HEX_FILE ${TFM_NS_HEX_FILE} # TFM Nonsecure FW (unsigned)
  220. TFM_S_SIGNED_BIN_FILE ${TFM_S_SIGNED_BIN_FILE} # TFM Secure FW (signed)
  221. TFM_NS_SIGNED_BIN_FILE ${TFM_NS_SIGNED_BIN_FILE} # TFM Nonsecure FW (signed)
  222. TFM_S_NS_SIGNED_BIN_FILE ${TFM_S_NS_SIGNED_BIN_FILE} # Merged TFM Secure/Nonsecure FW (signed)
  223. )
  224. zephyr_library_named(tfm_api)
  225. zephyr_library_sources(
  226. src/zephyr_tfm_log.c
  227. interface/interface.c
  228. )
  229. # Non-Secure interface to request system reboot
  230. zephyr_library_sources_ifdef(CONFIG_TFM_PARTITION_PLATFORM src/reboot.c)
  231. zephyr_library_sources_ifndef(CONFIG_TFM_PSA_TEST_NONE src/zephyr_tfm_psa_test.c)
  232. zephyr_include_directories(
  233. ${TFM_GENERATED_INCLUDES}
  234. )
  235. target_include_directories(tfm_api PRIVATE
  236. ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m/interface/include
  237. )
  238. zephyr_library_link_libraries(
  239. ${PSA_TEST_VAL_FILE}
  240. ${PSA_TEST_PAL_FILE}
  241. ${PSA_TEST_COMBINE_FILE}
  242. ${PLATFORM_NS_FILE}
  243. ${TFM_API_NS_PATH}
  244. ${VENEERS_FILE}
  245. )
  246. # To ensure that generated include files are created before they are used.
  247. add_dependencies(zephyr_interface tfm)
  248. # Set default image versions if not defined elsewhere
  249. if (NOT DEFINED TFM_IMAGE_VERSION_S)
  250. set(TFM_IMAGE_VERSION_S 0.0.0+0)
  251. endif()
  252. if (NOT DEFINED TFM_IMAGE_VERSION_NS)
  253. set(TFM_IMAGE_VERSION_NS 0.0.0+0)
  254. endif()
  255. if (CONFIG_TFM_BL2)
  256. set(PREPROCESSED_FILE_S "${CMAKE_BINARY_DIR}/tfm/bl2/ext/mcuboot/CMakeFiles/signing_layout_s.dir/signing_layout_s.o")
  257. set(PREPROCESSED_FILE_NS "${CMAKE_BINARY_DIR}/tfm/bl2/ext/mcuboot/CMakeFiles/signing_layout_ns.dir/signing_layout_ns.o")
  258. set(TFM_MCUBOOT_DIR "${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/trusted-firmware-m/bl2/ext/mcuboot")
  259. endif()
  260. # Configure which format (full or hash) to include the public key in
  261. # the image manifest
  262. if(NOT DEFINED TFM_PUBLIC_KEY_FORMAT)
  263. set(TFM_PUBLIC_KEY_FORMAT "full")
  264. endif()
  265. if(DEFINED TFM_HEX_BASE_ADDRESS_S)
  266. set(HEX_ADDR_ARGS_S "--hex-addr=${TFM_HEX_BASE_ADDRESS_S}")
  267. endif()
  268. if(DEFINED TFM_HEX_BASE_ADDRESS_NS)
  269. set(HEX_ADDR_ARGS_NS "--hex-addr=${TFM_HEX_BASE_ADDRESS_NS}")
  270. endif()
  271. function(tfm_sign OUT_ARG SUFFIX PAD INPUT_FILE OUTPUT_FILE)
  272. if(PAD)
  273. set(pad_args --pad --pad-header)
  274. endif()
  275. set (${OUT_ARG}
  276. ${PYTHON_EXECUTABLE} ${TFM_MCUBOOT_DIR}/scripts/wrapper/wrapper.py
  277. --layout ${PREPROCESSED_FILE_${SUFFIX}}
  278. -k ${CONFIG_TFM_KEY_FILE_${SUFFIX}}
  279. --public-key-format ${TFM_PUBLIC_KEY_FORMAT}
  280. --align 1
  281. -v ${TFM_IMAGE_VERSION_${SUFFIX}}
  282. ${pad_args}
  283. ${HEX_ADDR_ARGS_${SUFFIX}}
  284. ${ADD_${SUFFIX}_IMAGE_MIN_VER}
  285. -s auto
  286. -H ${CONFIG_ROM_START_OFFSET}
  287. ${INPUT_FILE}
  288. ${OUTPUT_FILE}
  289. PARENT_SCOPE)
  290. endfunction()
  291. set(MERGED_FILE ${CMAKE_BINARY_DIR}/tfm_merged.hex)
  292. set(S_NS_FILE ${CMAKE_BINARY_DIR}/tfm_s_zephyr_ns.hex)
  293. set(S_NS_SIGNED_FILE ${CMAKE_BINARY_DIR}/tfm_s_zephyr_ns_signed.hex)
  294. set(NS_SIGNED_FILE ${CMAKE_BINARY_DIR}/zephyr_ns_signed.hex)
  295. set(S_SIGNED_FILE ${CMAKE_BINARY_DIR}/tfm_s_signed.hex)
  296. if (CONFIG_TFM_REGRESSION_NS)
  297. # Use the TF-M NS binary as the Non-Secure application firmware image
  298. set(NS_APP_FILE $<TARGET_PROPERTY:tfm,TFM_NS_HEX_FILE>)
  299. else()
  300. # Use the Zephyr binary as the Non-Secure application firmware image
  301. set(NS_APP_FILE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME})
  302. endif()
  303. if (NOT CONFIG_TFM_BL2)
  304. # Merge tfm_s and zephyr (NS) image to a single binary.
  305. set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
  306. COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py
  307. -o ${MERGED_FILE}
  308. $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE>
  309. ${NS_APP_FILE}
  310. )
  311. set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
  312. ${MERGED_FILE}
  313. )
  314. elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1")
  315. tfm_sign(sign_cmd NS TRUE ${S_NS_FILE} ${S_NS_SIGNED_FILE})
  316. set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
  317. COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py
  318. -o ${S_NS_FILE}
  319. $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE>
  320. ${NS_APP_FILE}
  321. COMMAND ${sign_cmd}
  322. COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py
  323. -o ${MERGED_FILE}
  324. $<TARGET_PROPERTY:tfm,BL2_HEX_FILE>
  325. ${S_NS_SIGNED_FILE}
  326. )
  327. set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
  328. ${S_NS_FILE}
  329. ${S_NS_SIGNED_FILE}
  330. ${MERGED_FILE}
  331. )
  332. else()
  333. if (CONFIG_TFM_REGRESSION_NS)
  334. tfm_sign(sign_cmd_ns NS TRUE ${NS_APP_FILE} ${NS_SIGNED_FILE})
  335. else()
  336. tfm_sign(sign_cmd_ns NS FALSE ${NS_APP_FILE} ${NS_SIGNED_FILE})
  337. endif()
  338. tfm_sign(sign_cmd_s S TRUE $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_FILE})
  339. #Create and sign for concatenated binary image, should align with the TF-M BL2
  340. set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
  341. COMMAND ${sign_cmd_ns}
  342. COMMAND ${sign_cmd_s}
  343. COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py
  344. -o ${MERGED_FILE}
  345. $<TARGET_PROPERTY:tfm,BL2_HEX_FILE>
  346. ${S_SIGNED_FILE}
  347. ${NS_SIGNED_FILE}
  348. )
  349. set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
  350. ${S_SIGNED_FILE}
  351. ${NS_SIGNED_FILE}
  352. ${MERGED_FILE}
  353. )
  354. endif()
  355. endif()