Awadhy Mohammed | 71bd937 | 2023-08-07 14:46:15 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.15) |
| 8 | |
| 9 | if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH}) |
| 10 | message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=") |
| 11 | endif() |
| 12 | |
| 13 | list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake) |
| 14 | |
| 15 | # A platform specific MCPU and architecture flags for NS side |
| 16 | include(${CONFIG_SPE_PATH}/platform/cpuarch.cmake) |
| 17 | # Include common configs exported from TF-M |
| 18 | include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake) |
| 19 | |
| 20 | # Select toolchain file if it is not specified via command line or the absolutate path |
| 21 | # is unavailable. |
| 22 | if (NOT DEFINED TFM_TOOLCHAIN_FILE) |
| 23 | set(TFM_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake) |
| 24 | endif() |
| 25 | |
| 26 | if(NOT EXISTS ${TFM_TOOLCHAIN_FILE}) |
| 27 | message(FATAL_ERROR "TFM_TOOLCHAIN_FILE ${TFM_TOOLCHAIN_FILE} doesn't exist." |
| 28 | "If it's relative path then please change to absolute path.") |
| 29 | endif() |
| 30 | |
| 31 | include(${TFM_TOOLCHAIN_FILE}) |
| 32 | |
| 33 | project("TF-M Example" LANGUAGES C) |
| 34 | tfm_toolchain_reload_compiler() |
| 35 | |
| 36 | # The exported TF-M interfaces |
| 37 | add_subdirectory(${CONFIG_SPE_PATH} ${CMAKE_BINARY_DIR}/spe) |
| 38 | |
| 39 | add_executable(tfm_ns |
| 40 | main.c |
| 41 | ${CONFIG_SPE_PATH}/interface/src/os_wrapper/tfm_ns_interface_bare_metal.c |
| 42 | # GNU Arm compiler version greater equal than *11.3.Rel1* |
| 43 | # has a linker issue that required system calls are missing, |
| 44 | # such as _read and _write. Add stub functions of required |
| 45 | # system calls to solve this issue. |
| 46 | $<$<BOOL:${CONFIG_GNU_SYSCALL_STUB_ENABLED}>:syscalls_stub.c> |
| 47 | ) |
| 48 | |
| 49 | target_link_libraries(tfm_ns |
| 50 | PRIVATE |
| 51 | tfm_api_ns |
| 52 | ) |
| 53 | |
Anton Komlev | 95add8a | 2024-05-09 14:33:11 +0100 | [diff] [blame^] | 54 | if (CONFIG_TFM_USE_TRUSTZONE) |
| 55 | target_link_libraries(tfm_ns |
| 56 | PRIVATE |
| 57 | tfm_api_ns_tz |
| 58 | ) |
| 59 | endif() |
| 60 | |
Awadhy Mohammed | 71bd937 | 2023-08-07 14:46:15 +0100 | [diff] [blame] | 61 | set_target_properties(tfm_ns PROPERTIES |
| 62 | SUFFIX ".axf" |
| 63 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" |
| 64 | ) |
| 65 | |
| 66 | target_add_scatter_file(tfm_ns ${CONFIG_SPE_PATH}/platform/linker_scripts) |
| 67 | |
| 68 | target_link_options(tfm_ns |
| 69 | PRIVATE |
| 70 | $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
| 71 | $<$<C_COMPILER_ID:ARMClang>:--map> |
| 72 | $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map> |
| 73 | ) |
| 74 | |
| 75 | add_convert_to_bin_target(tfm_ns) |