Skip to content

Commit a667e92

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 3ac8c36 commit a667e92

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
@@ -484,9 +484,13 @@ if (CONFIG_BUILD_WITH_TFM)
484484
math(EXPR S_MAX_SECTORS "${s_partition_size} / ${flash_erase_block_size}")
485485
math(EXPR NS_MAX_SECTORS "${ns_partition_size} / ${flash_erase_block_size}")
486486

487-
function(tfm_sign OUT_ARG SUFFIX PAD MAX_SECTORS INPUT_FILE OUTPUT_FILE)
488-
if(PAD)
487+
function(tfm_sign OUT_ARG SUFFIX HEADER TRAILER MAX_SECTORS INPUT_FILE OUTPUT_FILE)
488+
if(HEADER AND TRAILER)
489489
set(pad_args --pad --pad-header)
490+
elseif(HEADER)
491+
set(pad_args --pad-header)
492+
elseif(TRAILER)
493+
set(pad_args --pad)
490494
endif()
491495
# Secure + Non-secure images are signed the same way as a secure only
492496
# build, but with a different layout file.
@@ -545,7 +549,7 @@ if (CONFIG_BUILD_WITH_TFM)
545549
)
546550

547551
elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1")
548-
tfm_sign(sign_cmd S_NS TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
552+
tfm_sign(sign_cmd S_NS TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
549553

550554
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
551555
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
@@ -570,12 +574,12 @@ if (CONFIG_BUILD_WITH_TFM)
570574

571575
else()
572576
if (CONFIG_TFM_USE_NS_APP)
573-
tfm_sign(sign_cmd_ns NS TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
577+
tfm_sign(sign_cmd_ns NS TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
574578
else()
575-
tfm_sign(sign_cmd_ns NS FALSE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
579+
tfm_sign(sign_cmd_ns NS FALSE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
576580
endif()
577581

578-
tfm_sign(sign_cmd_s S TRUE ${S_MAX_SECTORS} $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_FILE})
582+
tfm_sign(sign_cmd_s S TRUE TRUE ${S_MAX_SECTORS} $<TARGET_PROPERTY:tfm,TFM_S_HEX_FILE> ${S_SIGNED_FILE})
579583

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

0 commit comments

Comments
 (0)