From bf87f98fa4fff2dd83b5cebad2bd3e3e9bf85067 Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 3 Jun 2021 16:53:36 +0200 Subject: [PATCH] modules: tf-m: fix NS image selection for regression tests When running with TFM Regression option set, but without BL2 (MCUboot) we need to use the TF-M's NS binary, and not the Zephyr application. This was selected properly for the case with MCUboot boot already, but not when running the regression tests without MCUboot. Signed-off-by: Ioannis Glaropoulos --- modules/trusted-firmware-m/CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/trusted-firmware-m/CMakeLists.txt b/modules/trusted-firmware-m/CMakeLists.txt index 8cff2f61739..449ebf37a2b 100644 --- a/modules/trusted-firmware-m/CMakeLists.txt +++ b/modules/trusted-firmware-m/CMakeLists.txt @@ -425,13 +425,21 @@ if (CONFIG_BUILD_WITH_TFM) set(NS_SIGNED_FILE ${CMAKE_BINARY_DIR}/zephyr_ns_signed.hex) set(S_SIGNED_FILE ${CMAKE_BINARY_DIR}/tfm_s_signed.hex) + if (CONFIG_TFM_REGRESSION_NS) + # Use the TF-M NS binary as the Non-Secure application firmware image + set(NS_APP_FILE $) + else() + # Use the Zephyr binary as the Non-Secure application firmware image + set(NS_APP_FILE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME}) + endif() + if (NOT CONFIG_TFM_BL2) # Merge tfm_s and zephyr (NS) image to a single binary. set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py -o ${MERGED_FILE} $ - ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME} + ${NS_APP_FILE} ) set_property(GLOBAL APPEND PROPERTY extra_post_build_byproducts @@ -441,12 +449,6 @@ if (CONFIG_BUILD_WITH_TFM) elseif(CONFIG_TFM_MCUBOOT_IMAGE_NUMBER STREQUAL "1") tfm_sign(sign_cmd NS TRUE ${S_NS_FILE} ${S_NS_SIGNED_FILE}) - if (CONFIG_TFM_REGRESSION_NS) - set(NS_APP_FILE $) - else() - set(NS_APP_FILE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME}) - endif() - set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/mergehex.py -o ${S_NS_FILE} @@ -469,9 +471,9 @@ if (CONFIG_BUILD_WITH_TFM) else() if (CONFIG_TFM_REGRESSION_NS) - tfm_sign(sign_cmd_ns NS TRUE $ ${NS_SIGNED_FILE}) + tfm_sign(sign_cmd_ns NS TRUE ${NS_APP_FILE} ${NS_SIGNED_FILE}) else() - tfm_sign(sign_cmd_ns NS FALSE ${CMAKE_BINARY_DIR}/zephyr/${KERNEL_HEX_NAME} ${NS_SIGNED_FILE}) + tfm_sign(sign_cmd_ns NS FALSE ${NS_APP_FILE} ${NS_SIGNED_FILE}) endif() tfm_sign(sign_cmd_s S TRUE $ ${S_SIGNED_FILE})