Skip to content

Commit 8a9b686

Browse files
committed
trusted-firmware-m: Set --confirm when signing
The current behaviour from signing an image add --pad but do not confirm the image. This seems to be a mistake because user should inspect in the Firmware Upgrade software the image status. This means that if an image is not --confirmed the FSM can not infer correct states. This set the image as confirmed to fix this issue. Signed-off-by: BUDKE Gerson Fernando <[email protected]>
1 parent a667e92 commit 8a9b686

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

modules/trusted-firmware-m/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,18 @@ 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 HEADER TRAILER MAX_SECTORS INPUT_FILE OUTPUT_FILE)
487+
function(tfm_sign OUT_ARG SUFFIX HEADER TRAILER CONFIRM MAX_SECTORS INPUT_FILE OUTPUT_FILE)
488488
if(HEADER AND TRAILER)
489489
set(pad_args --pad --pad-header)
490490
elseif(HEADER)
491491
set(pad_args --pad-header)
492492
elseif(TRAILER)
493493
set(pad_args --pad)
494494
endif()
495+
if(CONFIRM)
496+
# --confirm imply PAD
497+
set(confim --confirm)
498+
endif()
495499
# Secure + Non-secure images are signed the same way as a secure only
496500
# build, but with a different layout file.
497501
set(layout_file ${PREPROCESSED_FILE_${SUFFIX}})
@@ -511,6 +515,7 @@ if (CONFIG_BUILD_WITH_TFM)
511515
--max-sectors ${MAX_SECTORS}
512516
-v ${CONFIG_TFM_IMAGE_VERSION_${SUFFIX}}
513517
${pad_args}
518+
${confim}
514519
${HEX_ADDR_ARGS_${SUFFIX}}
515520
${ADD_${SUFFIX}_IMAGE_MIN_VER}
516521
-s ${CONFIG_TFM_IMAGE_SECURITY_COUNTER}
@@ -549,7 +554,7 @@ if (CONFIG_BUILD_WITH_TFM)
549554
)
550555

551556
elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1")
552-
tfm_sign(sign_cmd S_NS TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
557+
tfm_sign(sign_cmd S_NS TRUE TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
553558

554559
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
555560
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
@@ -574,12 +579,12 @@ if (CONFIG_BUILD_WITH_TFM)
574579

575580
else()
576581
if (CONFIG_TFM_USE_NS_APP)
577-
tfm_sign(sign_cmd_ns NS TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
582+
tfm_sign(sign_cmd_ns NS TRUE TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
578583
else()
579-
tfm_sign(sign_cmd_ns NS FALSE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
584+
tfm_sign(sign_cmd_ns NS FALSE TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
580585
endif()
581586

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

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

0 commit comments

Comments
 (0)