44
55cmake_minimum_required (VERSION 3.21.0 FATAL_ERROR)
66
7+ set (NS_TARGET_NAME freertos-iot-libraries-tests)
8+ set (APPLICATION_PATH "${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} /applications/freertos_iot_libraries_tests" CACHE STRING "Path to the application folder" )
79set (AWS_OTA_SIGNATURE_TYPE "RSA-3072" CACHE STRING "Supported algorithms for signature validation [RSA-2048, RSA-3072, EC-P256, EC-P384]" )
810
9- set (MCUBOOT_IMAGE_VERSION_NS "0.0.1+10" )
10- set (MCUBOOT_IMAGE_NUMBER 2 CACHE STRING "Total number of firmware images" )
11- set (DEFAULT_MCUBOOT_FLASH_MAP ON )
12-
13- set (APPLICATION_PATH "${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} /applications/freertos_iot_libraries_tests" CACHE STRING "Path to the application folder" )
11+ # Toolchain file has to be included before the very first project() call
12+ include (${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} /components/security/trusted_firmware-m/integration/cmake/TfmNsToolchain.cmake)
1413
15- # Trusted Firmware-M setup
16- set (TFM_CMAKE_APP_ARGS
17- -DPROJECT_CONFIG_HEADER_FILE=${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} /applications/freertos_iot_libraries_tests/configs/tfm_config/project_config.h
18- -DMCUBOOT_DATA_SHARING=ON
19- -DMCUBOOT_CONFIRM_IMAGE=ON
20- -DMCUBOOT_UPGRADE_STRATEGY=SWAP_USING_SCRATCH
21- -DMCUBOOT_IMAGE_VERSION_NS=${MCUBOOT_IMAGE_VERSION_NS}
22- -DPLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT=ON
23- -DTFM_PARTITION_FIRMWARE_UPDATE=ON
24- )
2514
2615project (freertos-iot-libraries-tests LANGUAGES C)
2716
28- # Set global optimization level to reduce code size while keeping the debug experience.
29- if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" )
30- add_compile_options (-Og)
31- elseif (${CMAKE_C_COMPILER_ID} STREQUAL "ARMClang" )
32- add_compile_options (-O1)
33- endif ()
17+ set_compiler_and_linker_flags()
18+ include (${CONFIG_SPE_PATH} /config/cp_check.cmake)
3419
3520# This variable is checked to apply configurations specific to FreeRTOS Libraries Integrations Tests
3621set (FREERTOS_LIBRARIES_INTEGRATION_TESTS 1)
@@ -74,15 +59,13 @@ target_link_libraries(freertos-libraries-integration-tests-config
7459add_executable (${CMAKE_PROJECT_NAME}
7560 main.c
7661 integration_tests_platform_function.c
62+ ${CONFIG_SPE_PATH} /interface /src/os_wrapper/tfm_ns_interface_rtos.c
7763)
7864
79- # Trusted Firmware-M must be built before the application, because
80- # the application depends on the NS interface and the BL2 signing scripts,
81- # both of which are generated as parts of the Trusted Firmware-M build process.
82- add_dependencies (${CMAKE_PROJECT_NAME} trusted_firmware-m-build )
8365# The provision data must be built before the application because
8466# it provides credentials to connect to AWS
8567add_dependencies (${CMAKE_PROJECT_NAME} provisioning_data_bin)
68+
8669target_link_libraries (${CMAKE_PROJECT_NAME}
8770 PRIVATE
8871 backoff-algorithm
@@ -97,30 +80,35 @@ target_link_libraries(${CMAKE_PROJECT_NAME}
9780 helpers-events
9881 provisioning-lib
9982 mbedtls
100- tfm-ns-interface
83+ toolchain-override
84+ tfm_api_ns
85+ # FRI always uses TrustZone
86+ tfm_api_ns_tz
10187)
10288
10389set_linker_script(${CMAKE_PROJECT_NAME} )
10490
10591list (APPEND CMAKE_MODULE_PATH ${IOT_REFERENCE_ARM_CORSTONE3XX_SOURCE_DIR} /tools/cmake)
10692include (ConvertElfToBin)
107- include (ExternalProject)
108- ExternalProject_Get_Property(trusted_firmware-m-build BINARY_DIR)
10993
11094extract_sections_from_axf(
11195 ${CMAKE_PROJECT_NAME}
11296 SECTIONS_NAMES "ddr.bin"
11397 OUTPUT_BIN_NAME "ns_image"
11498)
11599
116- # The non-secure application image should be padded while being signed
117- iot_reference_arm_corstone3xx_tf_m_sign_image(
118- ${CMAKE_PROJECT_NAME}
119- "ns_image"
120- ${CMAKE_PROJECT_NAME} _signed
121- ${MCUBOOT_IMAGE_VERSION_NS}
122- "${BINARY_DIR} /api_ns/image_signing/layout_files/signing_layout_ns.o"
123- TRUE
100+ # Copy the binary flash content to the location expected by default signing
101+ # Signing is implemented in the exported TF-M NS CMakeLists.txt (in the
102+ # ${CONFIG_SPE_PATH} directory)
103+ add_custom_target (freertos-iot-libraries-tests_bin
104+ SOURCES ${CMAKE_BINARY_DIR} /freertos-iot-libraries-tests.bin
105+ DEPENDS freertos-iot-libraries-tests
106+ )
107+ add_custom_command (OUTPUT ${CMAKE_BINARY_DIR} /freertos-iot-libraries-tests.bin
108+ DEPENDS freertos-iot-libraries-tests
109+ COMMAND ${CMAKE_COMMAND}
110+ -E copy ${SECTORS_BIN_DIR} /ns_image.bin
111+ ${CMAKE_BINARY_DIR} /freertos-iot-libraries-tests.bin
124112)
125113
126114# A user project that consumes the ARM FRI needs to explicitly provide
0 commit comments