Skip to content

Commit

Permalink
Add TF-M regression tests on AN524
Browse files Browse the repository at this point in the history
TF-M regression tests config option `TFM_REGRESSION` is documented in
`Arm/MPS3_AN524/app/config.cmake` and is disabled by default. To run
TF-M NS regression tests set the config option to `ON` and rebuild
the application. Then run it either on QEMU or hardware.

Signed-off-by: Devaraj Ranganna <[email protected]>
  • Loading branch information
urutva committed Jul 5, 2021
1 parent 576a71f commit 0b07d33
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Arm/MPS3_AN524/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ set(SOURCES

add_executable(${PROJECT_NAME} ${SOURCES})

target_compile_definitions(${PROJECT_NAME}
PRIVATE
$<$<BOOL:${TFM_REGRESSION}>:TFM_REGRESSION>
)

target_link_libraries(${PROJECT_NAME}
PUBLIC
azrtos::threadx
Expand Down
2 changes: 1 addition & 1 deletion Arm/MPS3_AN524/app/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cmake_dependent_option(TFM_IPC
cmake_dependent_option(TFM_REGRESSION
"When enabled, this option signifies that the TF-M build includes
the Secure and the Non-Secure regression tests."
ON
OFF
BUILD_WITH_TFM OFF
)

Expand Down
15 changes: 15 additions & 0 deletions Arm/MPS3_AN524/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@
#include "psa_manifest/sid.h"
#endif

#ifdef TFM_REGRESSION
#include "test_framework_integ_test.h"
#endif

#define AZURE_THREAD_STACK_SIZE 4096
#define AZURE_THREAD_PRIORITY 4

int tfm_log_printf(const char *fmt, ...)
{
printf(fmt);
}

static __inline void systick_interval_set(uint32_t ticks)
{
// 1. Disable the counter
Expand Down Expand Up @@ -62,6 +71,8 @@ void azure_thread_entry(ULONG parameter)
printf("The version of the PSA Framework API is not valid!\n");
return;
}

#ifdef TFM_REGRESSION
psa_handle_t handle;

handle = psa_connect(IPC_SERVICE_TEST_BASIC_SID,
Expand All @@ -73,6 +84,10 @@ void azure_thread_entry(ULONG parameter)
return;
}
psa_close(handle);

/* Start TF-M NS regression tests */
tfm_non_secure_client_run_tests();
#endif
}

void tx_application_define(void* first_unused_memory)
Expand Down
68 changes: 59 additions & 9 deletions Arm/MPS3_AN524/lib/tf-m/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ function(trusted_firmware_build)
set(MCUBOOT_IMAGE_NUM_ARG -DMCUBOOT_IMAGE_NUMBER=${TFM_MCUBOOT_IMAGE_NUMBER})
endif()

set(VENEERS_FILE ${TFM_BINARY_DIR}/install/interface/lib/s_veneers.o)
set(PSA_API_NS_PATH ${TFM_BINARY_DIR}/app/libtfm_api_ns.a)
set(TFM_GENERATED_INCLUDES ${TFM_BINARY_DIR}/generated/interface/include)

if(TFM_BL2)
Expand All @@ -102,9 +100,45 @@ function(trusted_firmware_build)
set(TFM_NS_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_ns_signed.bin)
set(TFM_S_NS_SIGNED_BIN_FILE ${TFM_BINARY_DIR}/bin/tfm_s_ns_signed.bin)

set(VENEERS_FILE ${TFM_BINARY_DIR}/install/interface/lib/s_veneers.o)

set(PSA_API_NS_PATH ${TFM_BINARY_DIR}/app/libtfm_api_ns.a)
if (TFM_REGRESSION)
set(PSA_QCBOR_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/qcbor/libtfm_test_suite_qcbor_ns.a)
set(PSA_NS_CORE_TEST_PATH ${TFM_BINARY_DIR}/test/suites/core/libtfm_test_suite_core_ns.a)
set(PSA_NS_IPC_TEST_PATH ${TFM_BINARY_DIR}/test/suites/ipc/libtfm_test_suite_ipc_ns.a)
set(PSA_ATTESTATION_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/attestation/libtfm_test_suite_attestation_ns.a)
set(PSA_CRYPTO_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/crypto/libtfm_test_suite_crypto_ns.a)
set(PSA_PLATFORM_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/platform/libtfm_test_suite_platform_ns.a)
set(PSA_PS_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/ps/libtfm_test_suite_ps_ns.a)
set(PSA_ITS_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/its/libtfm_test_suite_its_ns.a)
set(PSA_T_COSE_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/test/suites/t_cose/libtfm_test_suite_t_cose_ns.a)
set(PSA_NS_REGRESSION_TEST_PATH ${TFM_BINARY_DIR}/app/libtfm_ns_integration_test.a)
set(PSA_QCBOR_TEST_PATH ${TFM_BINARY_DIR}/lib/ext/qcbor/libtfm_qcbor_test.a)
set(PSA_T_COSE_TEST_PATH ${TFM_BINARY_DIR}/lib/ext/t_cose/libtfm_t_cose_test.a)
set(PSA_PLATFORM_NS_PATH ${TFM_BINARY_DIR}/platform/libplatform_ns.a)
set(PSA_QCBOR_PATH ${TFM_BINARY_DIR}/lib/ext/qcbor/libtfm_qcbor.a)
set(PSA_T_COSE_PATH ${TFM_BINARY_DIR}/lib/ext/t_cose/libtfm_t_cose.a)
endif()

set(BUILD_BYPRODUCTS
${VENEERS_FILE}
${PSA_API_NS_PATH}
${PSA_QCBOR_NS_REGRESSION_TEST_PATH}
${PSA_NS_CORE_TEST_PATH}
${PSA_NS_IPC_TEST_PATH}
${PSA_ATTESTATION_NS_REGRESSION_TEST_PATH}
${PSA_CRYPTO_NS_REGRESSION_TEST_PATH}
${PSA_PLATFORM_NS_REGRESSION_TEST_PATH}
${PSA_PS_NS_REGRESSION_TEST_PATH}
${PSA_ITS_NS_REGRESSION_TEST_PATH}
${PSA_T_COSE_NS_REGRESSION_TEST_PATH}
${PSA_NS_REGRESSION_TEST_PATH}
${PSA_QCBOR_TEST_PATH}
${PSA_T_COSE_TEST_PATH}
${PSA_PLATFORM_NS_PATH}
${PSA_QCBOR_PATH}
${PSA_T_COSE_PATH}
${TFM_GENERATED_INCLUDES}/psa_manifest/sid.h
${BL2_BIN_FILE}
${BL2_HEX_FILE}
Expand Down Expand Up @@ -170,24 +204,40 @@ function(trusted_firmware_build)
TFM_S_NS_SIGNED_BIN_FILE ${TFM_S_NS_SIGNED_BIN_FILE} # Merged TFM Secure/Nonsecure FW (signed)
)

add_library(tfm_api
${TX_TFM_TESTS_DIR}/app/os_wrapper_cmsis_rtos_v2.c
add_library(tfm_api INTERFACE
# ${TX_TFM_TESTS_DIR}/app/os_wrapper_cmsis_rtos_v2.c
)

target_include_directories(tfm_api
PRIVATE
${TX_TFM_TESTS_DIR}/CMSIS/RTOS2/Include
PUBLIC
${TX_TFM_BASE_DIR}/interface/include
# PRIVATE
# ${TX_TFM_TESTS_DIR}/CMSIS/RTOS2/Include
INTERFACE
${TX_TFM_BASE_DIR}/interface/include
${TX_TFM_BASE_DIR}/../tf-m-tests/test/framework
# INTERFACE
${TFM_GENERATED_INCLUDES}
)

target_link_libraries(tfm_api
INTERFACE
${PSA_NS_CORE_TEST_PATH}
${PSA_ATTESTATION_NS_REGRESSION_TEST_PATH}
${PSA_CRYPTO_NS_REGRESSION_TEST_PATH}
${PSA_NS_IPC_TEST_PATH}
${PSA_ITS_NS_REGRESSION_TEST_PATH}
${PSA_PLATFORM_NS_REGRESSION_TEST_PATH}
${PSA_PS_NS_REGRESSION_TEST_PATH}
${PSA_QCBOR_NS_REGRESSION_TEST_PATH}
${PSA_T_COSE_NS_REGRESSION_TEST_PATH}
${PSA_QCBOR_TEST_PATH}
${PSA_T_COSE_TEST_PATH}
${PSA_PLATFORM_NS_PATH}
${PSA_API_NS_PATH}
${PSA_NS_REGRESSION_TEST_PATH}
${PSA_QCBOR_PATH}
${PSA_T_COSE_PATH}
${VENEERS_FILE}
$<TARGET_FILE:tfm_api>
# $<TARGET_FILE:tfm_api>
)

add_dependencies(tfm_api tfm)
Expand Down
6 changes: 6 additions & 0 deletions Arm/MPS3_AN524/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ and semaphores. The size of these allocations may also be configured.
Configuration options for these are defined and documented in
`Arm/MPS3_AN524/lib/threadx/CMmakeLists.txt`.

### Running TF-M NS regression tests
TF-M NS regression tests config option `TFM_REGRESSION` is documented in
`Arm/MPS3_AN524/app/config.cmake` and is disabled by default. To run TF-M NS
regression tests set the config option to `ON` and rebuild the application.
Then run it either on [QEMU](#using-qemu) or [hardware](#updating-application-image)

## Updating application image
> This has only been tested on OS X, some modifications might be needed to make
`Arm/MPS3_AN524/tools/flash.py` to work in Windows/Linux environments.
Expand Down

0 comments on commit 0b07d33

Please sign in to comment.