Build: Convert app directory to modern cmake
update app cmake files. Update header includes where include paths have
changed. Add support for secure test only enablement.
WARNING: This change will not build in isolation, it requires _all_
other cmake changes to successfully build. It is split out only for ease
of understanding.
Signed-off-by: Raef Coles <raef.coles@arm.com>
Change-Id: I3e8eb83c13b5e4dbb428615ba83567f14000285b
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index d7577cf..6da45de 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,434 +1,155 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
#-------------------------------------------------------------------------------
-cmake_minimum_required(VERSION 3.7)
-
-set(TFM_BUILD_IN_SPE OFF)
-
-if (NOT DEFINED TFM_ROOT_DIR)
- set(TFM_ROOT_DIR ${CMAKE_SOURCE_DIR})
-endif()
-
-#Tell cmake where our modules can be found
-list(APPEND CMAKE_MODULE_PATH ${TFM_ROOT_DIR}/cmake)
-
-set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface)
-
-#Include common stuff to control cmake.
-include("Common/BuildSys")
-
-#Start an embedded project.
-embedded_project_start(CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake")
+cmake_minimum_required(VERSION 3.13)
project(tfm_ns LANGUAGES ASM C)
-embedded_project_fixup()
-#Include BL2 bootloader related functions
-set(MCUBOOT_DIR "${TFM_ROOT_DIR}/bl2/ext/mcuboot")
-include("${MCUBOOT_DIR}/MCUBoot.cmake")
-
-#CMSIS
-set(CMSIS_DIR ${CMAKE_CURRENT_LIST_DIR}/../CMSIS)
-
-if (NOT DEFINED BL2)
- message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ")
-endif ()
-
-if (NOT DEFINED TFM_PARTITION_AUDIT_LOG)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.")
+# For multi-core projects, the NS app can be run on a different CPU to the
+# Secure code. To facilitate this, we once again reload the compiler to load the
+# setting for the NS CPU. Cmake settings are directory scoped so this affects
+# anything loaded from or declared in this dir.
+if (TFM_MULTI_CORE_TOPOLOGY)
+ include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
endif()
-if (NOT DEFINED TFM_PARTITION_PLATFORM)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PLATFORM is undefined.")
+############################# PSA test integration #############################
+
+if(TEST_PSA_API)
+ set(SUITE ${TEST_PSA_API})
+
+ string(REGEX REPLACE ".*/" "" PSA_API_TEST_TARGET ${TFM_PLATFORM})
+
+ if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
+ set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
+ else()
+ set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
+ endif()
+
+ set(PSA_INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/interface/include/
+ ${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/
+ ${CMAKE_BINARY_DIR}/generated/interface/include
+ )
+
+ set(SP_HEAP_MEM_SUPP=0)
+ set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
+
+ if (${CMAKE_C_COMPILER_ID} STREQUAL GNU)
+ set(TOOLCHAIN GNUARM)
+ elseif (${CMAKE_C_COMPILER_ID} STREQUAL ARMClang)
+ set(TOOLCHAIN ARMCLANG)
+ endif()
+
+ if (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.main)
+ set(CPU_ARCH armv8m_ml)
+ elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv8-m.base)
+ set(CPU_ARCH armv8m_bl)
+ elseif (${CMAKE_SYSTEM_ARCHITECTURE} STREQUAL armv7-m)
+ set(CPU_ARCH armv7m)
+ endif()
+
+ add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
endif()
-if (NOT DEFINED TFM_PARTITION_PROTECTED_STORAGE)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PROTECTED_STORAGE is undefined.")
-endif()
+############################# Test integration #################################
-if (NOT DEFINED TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INTERNAL_TRUSTED_STORAGE is undefined.")
-endif()
+add_library(tfm_ns_integration_test STATIC EXCLUDE_FROM_ALL)
-if (NOT DEFINED TFM_PARTITION_CRYPTO)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_CRYPTO is undefined.")
-endif()
+target_sources(tfm_ns_integration_test
+ PRIVATE
+ tfm_integ_test.c
+)
-if (NOT DEFINED TFM_PARTITION_INITIAL_ATTESTATION)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_INITIAL_ATTESTATION is undefined.")
-endif()
+target_include_directories(tfm_ns_integration_test
+ PUBLIC
+ .
+)
-if (NOT DEFINED TFM_PSA_API)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined.")
-endif()
+target_link_libraries(tfm_ns_integration_test
+ PUBLIC
+ $<$<BOOL:${TEST_NS}>:tfm_ns_tests>
+ tfm_test_framework
+ PRIVATE
+ psa_interface
+ $<TARGET_PROPERTY:platform_ns,PLATFORM_RTX_LIB_PATH>
+ psa_api_ns
+ CMSIS_5_tfm_ns
+)
-embedded_include_directories(PATH ${CMAKE_CURRENT_LIST_DIR} ABSOLUTE)
+target_compile_definitions(tfm_ns_integration_test
+ PUBLIC
+ $<$<BOOL:${TEST_NS}>:TEST_FRAMEWORK_NS>
+ $<$<BOOL:${TEST_S}>:TEST_FRAMEWORK_S>
+)
-set(NS_APP_SRC "${CMSIS_DIR}/RTOS2/RTX/Config/RTX_Config.c"
- "${CMSIS_DIR}/RTOS2/RTX/Source/rtx_lib.c"
- "${CMAKE_CURRENT_LIST_DIR}/main_ns.c"
- "${CMAKE_CURRENT_LIST_DIR}/tfm_integ_test.c"
- "${CMAKE_CURRENT_LIST_DIR}/os_wrapper_cmsis_rtos_v2.c"
- "${CMAKE_CURRENT_LIST_DIR}/../log/tfm_log_raw.c"
- )
+############################# TFM NS app #######################################
-if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ns_interface.c")
-endif()
+add_executable(tfm_ns)
-if (TFM_PARTITION_AUDIT_LOG)
- if (TFM_PSA_API)
- message(FATAL_ERROR "Audit log has not been supported in IPC model yet.")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_audit_func_api.c")
- endif()
-endif()
+target_sources(tfm_ns
+ PRIVATE
+ main_ns.c
+ $<$<BOOL:${TEST_PSA_API}>:psa_api_test.c>
+)
-if (TFM_PARTITION_PLATFORM)
- if (TFM_PSA_API)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_platform_ipc_api.c")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_platform_func_api.c")
- endif()
-endif()
+target_link_libraries(tfm_ns
+ PRIVATE
+ platform_ns
+ CMSIS_5_tfm_ns
+ $<$<OR:$<BOOL:${TEST_NS}>,$<BOOL:${TEST_S}>>:tfm_ns_integration_test>
+ $<$<BOOL:${TEST_PSA_API}>:val_nspe>
+ $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
+ $<$<BOOL:${TEST_PSA_API}>:test_combine>
+ $<$<NOT:$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>>:tfm_s_veneers>
+ psa_api_ns
+)
-if (TFM_PARTITION_PROTECTED_STORAGE)
- if (TFM_PSA_API)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ps_ipc_api.c")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ps_func_api.c")
- endif()
-endif()
+target_compile_definitions(tfm_ns
+ PUBLIC
+ $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
+)
-if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
- if (TFM_PSA_API)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_its_ipc_api.c")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_its_func_api.c")
- endif()
-endif()
+set_target_properties(tfm_ns PROPERTIES
+ SUFFIX ".axf"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+)
-if (TFM_PARTITION_CRYPTO)
- if (TFM_PSA_API)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_crypto_ipc_api.c")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_crypto_func_api.c")
- endif()
-endif()
+target_link_options(tfm_ns
+ PRIVATE
+ $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
+ $<$<C_COMPILER_ID:ARMClang>:--map>
+)
-if (TFM_PARTITION_INITIAL_ATTESTATION)
- if (TFM_PSA_API)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_initial_attestation_ipc_api.c")
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_initial_attestation_func_api.c")
- endif()
-endif()
+add_convert_to_bin_target(tfm_ns)
-if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
- message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.")
-elseif (TFM_NS_CLIENT_IDENTIFICATION)
- list(APPEND NS_APP_SRC
- "${INTERFACE_DIR}/src/tfm_nspm_svc_handler.c"
- "${INTERFACE_DIR}/src/tfm_nspm_api.c"
- )
-endif()
+############################# CMSIS ############################################
-if (PSA_API_TEST_NS)
- list(APPEND NS_APP_SRC "${CMAKE_CURRENT_LIST_DIR}/psa_api_test.c")
-endif()
+include(FetchContent)
-if (TFM_PSA_API)
- if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_ns_mailbox.c"
- "${INTERFACE_DIR}/src/tfm_multi_core_api.c"
- "${INTERFACE_DIR}/src/tfm_multi_core_psa_ns_api.c"
- )
+set(FETCHCONTENT_QUIET FALSE)
+cmake_policy(SET CMP0079 NEW)
- if (TFM_MULTI_CORE_TEST)
- add_definitions(-DTFM_MULTI_CORE_TEST)
- endif()
- else()
- list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_psa_ns_api.c")
- endif()
-endif()
+add_library(CMSIS_5_tfm_ns INTERFACE)
-set(BUILD_CMSIS_CORE On)
-set(BUILD_RETARGET On)
-set(BUILD_NATIVE_DRIVERS On)
-set(BUILD_TIME On)
-set(BUILD_STARTUP On)
-set(BUILD_TARGET_CFG Off)
-set(BUILD_TARGET_HARDWARE_KEYS Off)
-set(BUILD_TARGET_NV_COUNTERS Off)
-set(BUILD_CMSIS_DRIVERS On)
-set(BUILD_UART_STDOUT On)
-set(BUILD_FLASH Off)
-if(CORE_TEST_POSITIVE)
- set(BUILD_PLAT_TEST On)
- set(BUILD_TIME On)
-else()
- set(BUILD_PLAT_TEST Off)
- set(BUILD_TIME Off)
-endif()
-if(NOT DEFINED PLATFORM_CMAKE_FILE)
- message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
-elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
- message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
-else()
- include(${PLATFORM_CMAKE_FILE})
-endif()
+target_sources(CMSIS_5_tfm_ns
+ INTERFACE
+ ${CMSIS_5_PATH}/RTOS2/RTX/Config/RTX_Config.c
+ ${CMSIS_5_PATH}/RTOS2/RTX/Source/rtx_lib.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/os_wrapper_cmsis_rtos_v2.c
+)
-if(NOT DEFINED NS_SCATTER_FILE_NAME)
- message(FATAL_ERROR "ERROR: Incomplete Configuration: NS_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake")
-endif()
-embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${NS_SCATTER_FILE_NAME}")
+target_include_directories(CMSIS_5_tfm_ns
+ INTERFACE
+ ${CMSIS_5_PATH}/Core/Include
+ ${CMSIS_5_PATH}/RTOS2/Include
+ ${CMSIS_5_PATH}/RTOS2/RTX/Include
+ ${CMSIS_5_PATH}/RTOS2/RTX/Config
+)
-#Create an object library to avoid compiling all source files twice, when two executables
-#with different memory map need to be linked(BL2 non-swapping)
-set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib)
-add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM} ${ALL_SRC_ASM_NS} ${NS_APP_SRC})
-
-#Set common compiler flags
-config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB})
-
-#Set macro definitions
-set(TARGET_COMPILE_DEFINITIONS __thumb2__ __DOMAIN_NS=1 DOMAIN_NS=__DOMAIN_NS)
-target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE ${TARGET_COMPILE_DEFINITIONS})
-
-#Set include directories.
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TEST_INTERFACE_DIR}/include ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/RTX/Include ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/Include ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_DIR}/RTOS2/RTX/Config ABSOLUTE APPEND)
-embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TEST_DIR}/.. ABSOLUTE APPEND)
-
-if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
- message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.")
-elseif (TFM_NS_CLIENT_IDENTIFICATION)
- target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION)
-endif()
-
-add_subdirectory(${TEST_DIR} ${CMAKE_BINARY_DIR}/test/non_secure_test)
-
-# For the non-swapping BL2 configuration two executables need to be built.
-# One can be executed from the primary slot flash partition and other from the
-# secondary slot. Only the linking phase is different. This function captures
-# common settings and eliminates copy-paste.
-function(set_up_app_build)
- set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE)
- set( _ONE_VALUE_ARGS NS_TARGET S_TARGET FULL_BIN SIGN_BIN VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar")
- set( _MULTI_VALUE_ARGS LINK_DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX)
- cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN})
-
- if (NOT DEFINED _MY_PARAMS_NS_TARGET)
- message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'NS_TARGET' missing.")
- endif()
-
- if (NOT DEFINED _MY_PARAMS_S_TARGET)
- message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'S_TARGET' missing.")
- endif()
-
- if (NOT DEFINED _MY_PARAMS_FULL_BIN)
- message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'FULL_BIN' missing.")
- endif()
-
- if (NOT DEFINED _MY_PARAMS_SIGN_BIN)
- message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'SIGN_BIN' missing.")
- endif()
-
- if (NOT DEFINED _MY_PARAMS_VENEER_NAME)
- message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'VENEER_NAME' missing.")
- endif()
-
- set(EXE_NAME ${_MY_PARAMS_NS_TARGET}${_MY_PARAMS_POSTFIX})
- set(S_BIN ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX})
- set(FULL_NAME ${_MY_PARAMS_FULL_BIN}${_MY_PARAMS_POSTFIX})
- set(SIGN_NAME ${_MY_PARAMS_SIGN_BIN}${_MY_PARAMS_POSTFIX})
- set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o)
-
- #Create linker target: add object library to executable
- add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>)
-
- #Set common linker flags
- config_setting_shared_linker_flags(${EXE_NAME})
-
- #Set individual linker flags per linker target/executable
- foreach(flag ${_MY_PARAMS_LINK_DEFINES})
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}")
- endforeach(flag)
-
- embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${NS_SCATTER_FILE_NAME}")
-
- #Add the RTX library
- if(NOT DEFINED RTX_LIB_PATH)
- message(FATAL_ERROR "ERROR: Incomplete Configuration: RTX_LIB_PATH is not defined.")
- endif()
-
- #Add the PSA API compliance test libraries
- if(PSA_API_TEST_NS)
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a")
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a")
- endif()
- if(PSA_API_TEST_NS AND (PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OR PSA_API_TEST_PROTECTED_STORAGE OR PSA_API_TEST_STORAGE))
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/storage/test_combine.a")
- endif()
- if(PSA_API_TEST_NS AND PSA_API_TEST_CRYPTO)
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/crypto/test_combine.a")
- endif()
- if(PSA_API_TEST_NS AND PSA_API_TEST_INITIAL_ATTESTATION)
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a")
- endif()
- if(PSA_API_TEST_NS AND PSA_API_TEST_IPC)
- target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/ff/ipc/test_combine.a")
- endif()
-
- if(NOT DEFINED PLATFORM_LINK_INCLUDES)
- message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
- endif()
- embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}")
-
- #Generate binary file from axf
- compiler_generate_binary_output(${EXE_NAME})
-
- #Generate intel hex file from axf
- compiler_generate_hex_output(${EXE_NAME})
-
- #Generate elf file from axf
- compiler_generate_elf_output(${EXE_NAME})
-
- #Generate MCUBoot compatible payload
- if (BL2)
- mcuboot_create_boot_payload(S_BIN ${S_BIN}
- NS_BIN ${EXE_NAME}
- FULL_BIN ${FULL_NAME}
- SIGN_BIN ${SIGN_NAME}
- POSTFIX ${_MY_PARAMS_POSTFIX})
- endif()
-
- if (NOT DEFINED TFM_PARTITION_TEST_CORE)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ")
- elseif (TFM_PARTITION_TEST_CORE)
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE")
- endif()
-
- if (NOT DEFINED TFM_PARTITION_TEST_CORE_IPC)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE_IPC is undefined.")
- elseif (TFM_PARTITION_TEST_CORE_IPC)
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE_IPC")
- endif()
-
- if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES)
- message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ")
- elseif (TFM_PARTITION_TEST_SECURE_SERVICES)
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES")
- endif()
-
- if (NOT DEFINED TEST_FRAMEWORK_S)
- message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.")
- elseif (TEST_FRAMEWORK_S)
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S")
- endif()
-
- if (NOT DEFINED TEST_FRAMEWORK_NS)
- message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.")
- elseif (TEST_FRAMEWORK_NS)
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS")
- endif()
-
- #Set BL2 specific settings.
- if (BL2)
- #Add BL2 and MCUBOOT_IMAGE_NUMBER defines to linker to resolve symbols in region_defs.h and flash_layout.h
- embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2" "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}")
- endif()
-
- #We depend on the non secure tests. See if the library target is available.
- if(TARGET tfm_non_secure_tests)
- #If yes, then use the library.
- target_link_libraries(${EXE_NAME} tfm_non_secure_tests)
- #Ensure library is built first.
- add_dependencies(${EXE_NAME} tfm_non_secure_tests)
- endif()
-
- target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}")
-
- #Ensure secure_fw is built before our executable.
- add_dependencies(${EXE_NAME} ${S_BIN})
-
- if (NOT DEFINED TFM_MULTI_CORE_TOPOLOGY OR NOT TFM_MULTI_CORE_TOPOLOGY)
- if (NOT DEFINED S_VENEER_PATH)
- if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../secure_fw)
- set (S_VENEER_PATH "${CMAKE_CURRENT_BINARY_DIR}/../secure_fw")
- else()
- message(FATAL_ERROR "No valid path for S_VENEER_PATH, secure_fw is built?")
- endif()
- endif()
-
- #Add the veneers to the executable.
- set(S_VENEER_FILE "${S_VENEER_PATH}/${VENEER_NAME}")
- set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_LIBRARIES ${S_VENEER_FILE})
- endif()
-
- #Collect executables to common location: build/install/outputs/
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.hex
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.elf
- DESTINATION outputs/${TARGET_PLATFORM}/)
-
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.hex
- ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.elf
- DESTINATION outputs/fvp/)
-endfunction()
-
-if (LINK_TO_BOTH_MEMORY_REGION)
- #Link to primary memory region
- set_up_app_build(NS_TARGET ${PROJECT_NAME}
- S_TARGET tfm_s
- FULL_BIN tfm_full
- SIGN_BIN tfm_sign
- VENEER_NAME s_veneers)
-
- #Link to secondary memory region(add extra linker flag)
- set_up_app_build(NS_TARGET ${PROJECT_NAME}
- LINK_DEFINES "LINK_TO_SECONDARY_PARTITION"
- S_TARGET tfm_s
- FULL_BIN tfm_full
- SIGN_BIN tfm_sign
- VENEER_NAME s_veneers
- POSTFIX "_1")
-else()
- #Link to primary memory region only
- set_up_app_build(NS_TARGET ${PROJECT_NAME}
- S_TARGET tfm_s
- FULL_BIN tfm_full
- SIGN_BIN tfm_sign
- VENEER_NAME s_veneers)
-endif()
-
-#If the tfm_non_secure_tests target is not available
-if(NOT TARGET tfm_non_secure_tests)
- #Add the test source to the build.
- #As of today since secure_fw is built as a sub-project this code will never execute.
- option(ENABLE_PROTECTED_STORAGE_SERVICE_TESTS "" TRUE)
- include(${TEST_DIR}/CMakeLists.inc)
- target_sources(${PROJECT_OBJ_LIB} PUBLIC ${ALL_SRC_C} ${ALL_SRC_C_NS})
-endif()
-
-#Finally let CMake system apply changes after the whole project is defined.
-if (TARGET ${PROJECT_NAME})
- embedded_project_end(${PROJECT_NAME})
-endif()
-
-if (TARGET ${PROJECT_NAME}_1)
- embedded_project_end(${PROJECT_NAME}_1)
-endif()
-
-embedded_project_end(${PROJECT_OBJ_LIB})
+target_link_libraries(CMSIS_5_tfm_ns
+ INTERFACE
+ platform_ns
+)
diff --git a/app/main_ns.c b/app/main_ns.c
index 53a4f47..b65d5cd 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -10,15 +10,15 @@
#include "tfm_integ_test.h"
#include "tfm_ns_svc.h"
#include "tfm_ns_interface.h"
-#ifdef TEST_FRAMEWORK_NS
-#include "test/framework/test_framework_integ_test.h"
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S)
+#include "test_framework_integ_test.h"
#endif
#ifdef PSA_API_TEST_NS
#include "psa_api_test.h"
#endif
#include "target_cfg.h"
#include "tfm_plat_ns.h"
-#include "Driver_USART.h"
+#include "driver/Driver_USART.h"
#include "device_cfg.h"
#ifdef TFM_MULTI_CORE_TOPOLOGY
#include "tfm_multi_core_api.h"
@@ -63,7 +63,8 @@
/**
* \brief List of RTOS thread attributes
*/
-#if defined(TEST_FRAMEWORK_NS) || defined(PSA_API_TEST_NS)
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S) \
+ || defined(PSA_API_TEST_NS)
static uint64_t test_app_stack[(4u * 1024u) / (sizeof(uint64_t))]; /* 4KB */
static const osThreadAttr_t thread_attr = {
.name = "test_thread",
@@ -76,7 +77,8 @@
* \brief Static globals to hold RTOS related quantities,
* main thread
*/
-#if defined(TEST_FRAMEWORK_NS) || defined(PSA_API_TEST_NS)
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S) \
+ || defined(PSA_API_TEST_NS)
static osThreadFunc_t thread_func;
#endif
@@ -163,13 +165,14 @@
/* Initialize the TFM NS interface */
tfm_ns_interface_init();
-#if defined(TEST_FRAMEWORK_NS)
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S)
thread_func = test_app;
#elif defined(PSA_API_TEST_NS)
thread_func = psa_api_test;
#endif
-#if defined(TEST_FRAMEWORK_NS) || defined(PSA_API_TEST_NS)
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S) \
+ || defined(PSA_API_TEST_NS)
(void) osThreadNew(thread_func, NULL, &thread_attr);
#endif
diff --git a/app/tfm_integ_test.c b/app/tfm_integ_test.c
index 32cb674..041e733 100644
--- a/app/tfm_integ_test.c
+++ b/app/tfm_integ_test.c
@@ -8,12 +8,11 @@
#include "tfm_integ_test.h"
#ifdef TEST_FRAMEWORK_NS
-#include "test/framework/test_framework_integ_test.h"
+#include "test_framework_integ_test.h"
#endif
#ifdef TEST_FRAMEWORK_S
-#include \
- "test/test_services/tfm_secure_client_service/tfm_secure_client_service_api.h"
+#include "tfm_secure_client_service_api.h"
#endif
#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S)
diff --git a/app/tfm_integ_test.h b/app/tfm_integ_test.h
index 93c46a5..f65f4f1 100644
--- a/app/tfm_integ_test.h
+++ b/app/tfm_integ_test.h
@@ -26,14 +26,14 @@
*/
#define UNUSED_VARIABLE(X) ((void)(X))
-#ifdef TEST_FRAMEWORK_NS
+#if defined(TEST_FRAMEWORK_NS) || defined(TEST_FRAMEWORK_S)
/**
* \brief Main test application for the RTX-TFM core
* integration tests
*
*/
void test_app(void *argument);
-#endif /* TEST_FRAMEWORK_NS */
+#endif /* TEST_FRAMEWORK_NS || TEST_FRAMEWORK_S */
#ifdef __cplusplus
}