Skip to content

Commit e3b352f

Browse files
committed
trusted-firmware-m: Define header and trailer options
The current behaviour when signing an image is to set always --pad and --pad-header for all images unless TFM_USE_NS_APP is set. This does not allow easy creation of a signed image for FOTA applications. Rewrite the PAD parameter into HEADER and TRAILER to easy setup more signing options. Signed-off-by: BUDKE Gerson Fernando <[email protected]>
1 parent c58012a commit e3b352f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,13 @@ if (CONFIG_BUILD_WITH_TFM)
472472
math(EXPR S_MAX_SECTORS "${s_partition_size} / ${flash_erase_block_size}")
473473
math(EXPR NS_MAX_SECTORS "${ns_partition_size} / ${flash_erase_block_size}")
474474

475-
function(tfm_sign OUT_ARG SUFFIX PAD MAX_SECTORS INPUT_FILE OUTPUT_FILE)
476-
if(PAD)
475+
function(tfm_sign OUT_ARG SUFFIX HEADER TRAILER MAX_SECTORS INPUT_FILE OUTPUT_FILE)
476+
if(HEADER AND TRAILER)
477477
set(pad_args --pad --pad-header)
478+
elseif(HEADER)
479+
set(pad_args --pad-header)
480+
elseif(TRAILER)
481+
set(pad_args --pad)
478482
endif()
479483
# Secure + Non-secure images are signed the same way as a secure only
480484
# build, but with a different layout file.
@@ -533,7 +537,7 @@ if (CONFIG_BUILD_WITH_TFM)
533537
)
534538

535539
elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1")
536-
tfm_sign(sign_cmd S_NS TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
540+
tfm_sign(sign_cmd S_NS TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
537541

538542
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
539543
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
@@ -558,12 +562,12 @@ if (CONFIG_BUILD_WITH_TFM)
558562

559563
else()
560564
if (CONFIG_TFM_USE_NS_APP)
561-
tfm_sign(sign_cmd_ns NS TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
565+
tfm_sign(sign_cmd_ns NS TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
562566
else()
563-
tfm_sign(sign_cmd_ns NS FALSE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
567+
tfm_sign(sign_cmd_ns NS FALSE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
564568
endif()
565569

566-
tfm_sign(sign_cmd_s S TRUE ${S_MAX_SECTORS} $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_FILE})
570+
tfm_sign(sign_cmd_s S TRUE TRUE ${S_MAX_SECTORS} $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_FILE})
567571

568572
#Create and sign for concatenated binary image, should align with the TF-M BL2
569573
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands

0 commit comments

Comments
 (0)