Skip to content

Commit 3bc5390

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 e3b352f commit 3bc5390

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
@@ -472,14 +472,18 @@ 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 HEADER TRAILER MAX_SECTORS INPUT_FILE OUTPUT_FILE)
475+
function(tfm_sign OUT_ARG SUFFIX HEADER TRAILER CONFIRM MAX_SECTORS INPUT_FILE OUTPUT_FILE)
476476
if(HEADER AND TRAILER)
477477
set(pad_args --pad --pad-header)
478478
elseif(HEADER)
479479
set(pad_args --pad-header)
480480
elseif(TRAILER)
481481
set(pad_args --pad)
482482
endif()
483+
if(CONFIRM)
484+
# --confirm imply PAD
485+
set(confim --confirm)
486+
endif()
483487
# Secure + Non-secure images are signed the same way as a secure only
484488
# build, but with a different layout file.
485489
set(layout_file ${PREPROCESSED_FILE_${SUFFIX}})
@@ -499,6 +503,7 @@ if (CONFIG_BUILD_WITH_TFM)
499503
--max-sectors ${MAX_SECTORS}
500504
-v ${CONFIG_TFM_IMAGE_VERSION_${SUFFIX}}
501505
${pad_args}
506+
${confim}
502507
${HEX_ADDR_ARGS_${SUFFIX}}
503508
${ADD_${SUFFIX}_IMAGE_MIN_VER}
504509
-s ${CONFIG_TFM_IMAGE_SECURITY_COUNTER}
@@ -537,7 +542,7 @@ if (CONFIG_BUILD_WITH_TFM)
537542
)
538543

539544
elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1")
540-
tfm_sign(sign_cmd S_NS TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
545+
tfm_sign(sign_cmd S_NS TRUE TRUE TRUE ${S_MAX_SECTORS} ${S_NS_FILE} ${S_NS_SIGNED_FILE})
541546

542547
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
543548
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/mergehex.py
@@ -562,12 +567,12 @@ if (CONFIG_BUILD_WITH_TFM)
562567

563568
else()
564569
if (CONFIG_TFM_USE_NS_APP)
565-
tfm_sign(sign_cmd_ns NS TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
570+
tfm_sign(sign_cmd_ns NS TRUE TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
566571
else()
567-
tfm_sign(sign_cmd_ns NS FALSE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
572+
tfm_sign(sign_cmd_ns NS FALSE TRUE TRUE ${NS_MAX_SECTORS} ${NS_APP_FILE} ${NS_SIGNED_FILE})
568573
endif()
569574

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

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

0 commit comments

Comments
 (0)