Skip to content

Commit 5b4cd27

Browse files
nandojvecfriedt
authored andcommitted
trusted-firmware-m: Create multi image bin files
A fundamental use of Trusted Firmware-M is to provide security for IoT applications, where firmware upgrades (FOTA) are almost always mandatory. The current file signing process does not produce the necessary binaries for multi-image S/NS FWU, since hex images are not suitable for this use case. This introduces the missing signed binary files for use by the FWU partition. The changes were tested in multi-image FWU scenarios, and support for single-image scenarios can be easily added in the future. Signed-off-by: BUDKE Gerson Fernando <gerson.budke@leica-geosystems.com>
1 parent 69f277c commit 5b4cd27

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ if (CONFIG_BUILD_WITH_TFM)
185185
set(TFM_S_ELF_FILE ${TFM_BINARY_DIR}/bin/tfm_s.elf)
186186
set(TFM_S_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s.bin)
187187
set(TFM_S_HEX_FILE ${TFM_BINARY_DIR}/bin/tfm_s.hex)
188-
set(TFM_NS_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns.bin)
188+
set(TFM_NS_BIN_FILE ${CMAKE_BINARY_DIR}/tfm_ns/bin/tfm_ns.bin)
189189
set(TFM_NS_HEX_FILE ${CMAKE_BINARY_DIR}/tfm_ns/bin/tfm_ns.hex)
190190
set(TFM_S_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s_signed.bin)
191191
set(TFM_NS_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns_signed.bin)
@@ -546,13 +546,17 @@ if (CONFIG_BUILD_WITH_TFM)
546546
set(S_NS_SIGNED_HEX_FILE ${CMAKE_BINARY_DIR}/zephyr/tfm_s_zephyr_ns_signed.hex)
547547
set(NS_SIGNED_HEX_FILE ${CMAKE_BINARY_DIR}/zephyr/zephyr_ns_signed.hex)
548548
set(S_SIGNED_HEX_FILE ${CMAKE_BINARY_DIR}/zephyr/tfm_s_signed.hex)
549+
set(NS_SIGNED_BIN_FILE ${CMAKE_BINARY_DIR}/zephyr/zephyr_ns_signed.bin)
550+
set(S_SIGNED_BIN_FILE ${CMAKE_BINARY_DIR}/zephyr/tfm_s_signed.bin)
549551

550552
if (CONFIG_TFM_USE_NS_APP)
551553
# Use the TF-M NS binary as the Non-Secure application firmware image
552554
set(NS_HEX_APP_FILE $<TARGET_PROPERTY:tfm,TFM_NS_HEX_FILE>)
555+
set(NS_BIN_APP_FILE $<TARGET_PROPERTY:tfm,TFM_NS_BIN_FILE>)
553556
else()
554557
# Use the Zephyr binary as the Non-Secure application firmware image
555558
set(NS_HEX_APP_FILE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME})
559+
set(NS_BIN_APP_FILE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_BIN_NAME})
556560
endif()
557561

558562
if (NOT CONFIG_TFM_BL2)
@@ -597,18 +601,26 @@ if (CONFIG_BUILD_WITH_TFM)
597601
if (CONFIG_TFM_USE_NS_APP)
598602
tfm_sign(sign_cmd_ns_hex NS TRUE TRUE TRUE ${S_NS_MAX_SECTORS} ${NS_HEX_APP_FILE}
599603
${NS_SIGNED_HEX_FILE})
604+
tfm_sign(sign_cmd_ns_bin NS TRUE TRUE FALSE ${S_NS_MAX_SECTORS} ${NS_BIN_APP_FILE}
605+
${NS_SIGNED_BIN_FILE})
600606
else()
601607
tfm_sign(sign_cmd_ns NS FALSE TRUE TRUE ${S_NS_MAX_SECTORS} ${NS_HEX_APP_FILE}
602608
${NS_SIGNED_HEX_FILE})
609+
tfm_sign(sign_cmd_ns_bin NS FALSE FALSE FALSE ${S_NS_MAX_SECTORS} ${NS_BIN_APP_FILE}
610+
${NS_SIGNED_BIN_FILE})
603611
endif()
604612

605613
tfm_sign(sign_cmd_s_hex S TRUE TRUE TRUE ${S_NS_MAX_SECTORS}
606614
$<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_HEX_FILE})
615+
tfm_sign(sign_cmd_s_bin S TRUE TRUE FALSE ${S_NS_MAX_SECTORS}
616+
$<TARGET_PROPERTY:tfm,TFM_S_BIN_FILE> ${S_SIGNED_BIN_FILE})
607617

608618
#Create and sign for concatenated binary image, should align with the TF-M BL2
609619
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
610620
COMMAND ${sign_cmd_ns_hex}
621+
COMMAND ${sign_cmd_ns_bin}
611622
COMMAND ${sign_cmd_s_hex}
623+
COMMAND ${sign_cmd_s_bin}
612624

613625
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
614626
-o ${MERGED_HEX_FILE}
@@ -620,7 +632,9 @@ if (CONFIG_BUILD_WITH_TFM)
620632

621633
set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts
622634
${S_SIGNED_HEX_FILE}
635+
${S_SIGNED_BIN_FILE}
623636
${NS_SIGNED_HEX_FILE}
637+
${NS_SIGNED_BIN_FILE}
624638
${MERGED_HEX_FILE}
625639
)
626640
endif()

0 commit comments

Comments
 (0)