Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 2 | # Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | cmake_minimum_required(VERSION 3.7) |
| 9 | |
David Hu | 857bfa5 | 2019-05-21 13:54:50 +0800 | [diff] [blame^] | 10 | set(TFM_BUILD_IN_SPE OFF) |
| 11 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 12 | #Tell cmake where our modules can be found |
| 13 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake) |
| 14 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 15 | set(APP_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 16 | get_filename_component(TFM_ROOT_DIR ${APP_DIR}/.. ABSOLUTE) |
| 17 | set(INTERFACE_DIR ${TFM_ROOT_DIR}/interface) |
Mate Toth-Pal | 813e9d1 | 2019-01-17 15:51:29 +0100 | [diff] [blame] | 18 | set(TEST_DIR ${TFM_ROOT_DIR}/test) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 19 | |
Ken Liu | e40f9a2 | 2019-06-03 16:42:47 +0800 | [diff] [blame] | 20 | #Include common stuff to control cmake. |
| 21 | include("Common/BuildSys") |
| 22 | |
| 23 | #Start an embedded project. |
| 24 | embedded_project_start(CONFIG "${TFM_ROOT_DIR}/configs/ConfigDefault.cmake") |
| 25 | project(tfm_ns LANGUAGES ASM C) |
| 26 | embedded_project_fixup() |
| 27 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 28 | #Include BL2 bootloader related functions |
| 29 | set(MCUBOOT_DIR "${TFM_ROOT_DIR}/bl2/ext/mcuboot") |
| 30 | include("${MCUBOOT_DIR}/MCUBoot.cmake") |
| 31 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 32 | #Set variables |
| 33 | get_filename_component(CMSIS_5_DIR ${TFM_ROOT_DIR}/../CMSIS_5 ABSOLUTE) |
| 34 | |
| 35 | if(NOT EXISTS ${CMSIS_5_DIR}) |
| 36 | message(FATAL_ERROR "Missing CMSIS_5. Please clone the CMSIS_5 repo to directory \"${CMSIS_5_DIR}\".") |
| 37 | endif() |
| 38 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 39 | if (NOT DEFINED BL2) |
| 40 | message(FATAL_ERROR "Incomplete build configuration: BL2 is undefined. ") |
| 41 | endif () |
| 42 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 43 | if (NOT DEFINED TFM_PARTITION_AUDIT_LOG) |
| 44 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_AUDIT_LOG is undefined.") |
| 45 | endif() |
| 46 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 47 | if (NOT DEFINED TFM_PARTITION_PLATFORM) |
| 48 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_PLATFORM is undefined.") |
| 49 | endif() |
| 50 | |
Kevin Peng | 9449a36 | 2019-07-29 16:05:42 +0800 | [diff] [blame] | 51 | if (NOT DEFINED TFM_PSA_API) |
| 52 | message(FATAL_ERROR "Incomplete build configuration: TFM_PSA_API is undefined.") |
| 53 | endif() |
| 54 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 55 | set(NS_APP_SRC "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config/RTX_Config.c" |
| 56 | "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Source/rtx_lib.c" |
| 57 | "${APP_DIR}/main_ns.c" |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 58 | "${APP_DIR}/tfm_integ_test.c" |
Kevin Peng | d36a7fc | 2019-07-22 16:01:10 +0800 | [diff] [blame] | 59 | "${APP_DIR}/os_wrapper_cmsis_rtos_v2.c" |
Kevin Peng | c86dec0 | 2019-07-23 16:15:57 +0800 | [diff] [blame] | 60 | "${INTERFACE_DIR}/src/tfm_ns_interface.c" |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 61 | ) |
| 62 | |
Kevin Peng | 9449a36 | 2019-07-29 16:05:42 +0800 | [diff] [blame] | 63 | if (TFM_PSA_API) |
| 64 | list(APPEND NS_APP_SRC |
| 65 | "${INTERFACE_DIR}/src/tfm_sst_ipc_api.c" |
| 66 | "${INTERFACE_DIR}/src/tfm_crypto_ipc_api.c" |
| 67 | "${INTERFACE_DIR}/src/tfm_initial_attestation_ipc_api.c" |
| 68 | ) |
| 69 | else() |
| 70 | list(APPEND NS_APP_SRC |
| 71 | "${INTERFACE_DIR}/src/tfm_sst_func_api.c" |
| 72 | "${INTERFACE_DIR}/src/tfm_crypto_func_api.c" |
| 73 | "${INTERFACE_DIR}/src/tfm_initial_attestation_func_api.c" |
| 74 | ) |
| 75 | endif() |
| 76 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 77 | if (TFM_PARTITION_AUDIT_LOG) |
Kevin Peng | 9449a36 | 2019-07-29 16:05:42 +0800 | [diff] [blame] | 78 | if (TFM_PSA_API) |
| 79 | message(FATAL_ERROR "Audit log has not been supported in IPC model yet.") |
| 80 | else() |
| 81 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_audit_func_api.c") |
| 82 | endif() |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 83 | endif() |
| 84 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 85 | if (TFM_PARTITION_PLATFORM) |
Kevin Peng | 9449a36 | 2019-07-29 16:05:42 +0800 | [diff] [blame] | 86 | if (TFM_PSA_API) |
| 87 | message(FATAL_ERROR "Platform service has not been supported in IPC model yet.") |
| 88 | else() |
| 89 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_platform_func_api.c") |
| 90 | endif() |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 91 | endif() |
| 92 | |
Miklos Balint | 16a9ffb | 2018-11-19 11:35:49 +0100 | [diff] [blame] | 93 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 94 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 95 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 96 | list(APPEND NS_APP_SRC |
| 97 | "${INTERFACE_DIR}/src/tfm_nspm_svc_handler.c" |
| 98 | "${INTERFACE_DIR}/src/tfm_nspm_api.c" |
| 99 | ) |
| 100 | endif() |
| 101 | |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 102 | if (PSA_API_TEST_NS) |
| 103 | list(APPEND NS_APP_SRC "${APP_DIR}/psa_api_test.c") |
| 104 | endif() |
| 105 | |
Kevin Peng | 9449a36 | 2019-07-29 16:05:42 +0800 | [diff] [blame] | 106 | if (TFM_PSA_API) |
Miklos Balint | 87da251 | 2018-04-19 13:45:50 +0200 | [diff] [blame] | 107 | list(APPEND NS_APP_SRC "${INTERFACE_DIR}/src/tfm_psa_ns_api.c") |
| 108 | endif() |
| 109 | |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 110 | set(BUILD_CMSIS_CORE On) |
| 111 | set(BUILD_RETARGET On) |
| 112 | set(BUILD_NATIVE_DRIVERS On) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 113 | set(BUILD_TIME On) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 114 | set(BUILD_STARTUP On) |
| 115 | set(BUILD_TARGET_CFG Off) |
| 116 | set(BUILD_TARGET_HARDWARE_KEYS Off) |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 117 | set(BUILD_TARGET_NV_COUNTERS Off) |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 118 | set(BUILD_CMSIS_DRIVERS On) |
| 119 | set(BUILD_UART_STDOUT Off) |
| 120 | set(BUILD_FLASH Off) |
Tamas Ban | 3681ce0 | 2018-11-22 15:19:24 +0000 | [diff] [blame] | 121 | set(BUILD_BOOT_SEED Off) |
Tamas Ban | 2318feb | 2019-01-02 16:50:51 +0000 | [diff] [blame] | 122 | set(BUILD_DEVICE_ID Off) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 123 | if(CORE_TEST_POSITIVE) |
| 124 | set(BUILD_PLAT_TEST On) |
| 125 | set(BUILD_TIME On) |
| 126 | else() |
| 127 | set(BUILD_PLAT_TEST Off) |
| 128 | set(BUILD_TIME Off) |
| 129 | endif() |
Marc Moreno Berengue | a1f296f | 2018-01-25 15:21:22 +0000 | [diff] [blame] | 130 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 131 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 132 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 133 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 134 | else() |
| 135 | include(${PLATFORM_CMAKE_FILE}) |
| 136 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 137 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 138 | if(NOT DEFINED NS_SCATTER_FILE_NAME) |
| 139 | message(FATAL_ERROR "ERROR: Incomplete Configuration: NS_SCATTER_FILE_NAME not defined, Include this file from a Config*.cmake") |
| 140 | endif() |
Gabor Kertesz | d7d7d74 | 2018-07-04 11:50:05 +0200 | [diff] [blame] | 141 | embedded_set_target_linker_file(TARGET ${PROJECT_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 142 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 143 | #Create an object library to avoid compiling all source files twice, when two executables |
| 144 | #with different memory map need to be linked(BL2 non-swapping) |
| 145 | set(PROJECT_OBJ_LIB ${PROJECT_NAME}_obj_lib) |
| 146 | add_library(${PROJECT_OBJ_LIB} OBJECT ${ALL_SRC_C} ${ALL_SRC_C_NS} ${ALL_SRC_ASM_NS} ${NS_APP_SRC}) |
| 147 | |
| 148 | #Set common compiler flags |
| 149 | config_setting_shared_compiler_flags(${PROJECT_OBJ_LIB}) |
| 150 | |
| 151 | #Set macro definitions |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 152 | set(TARGET_COMPILE_DEFINITIONS __thumb2__ __DOMAIN_NS=1 DOMAIN_NS=__DOMAIN_NS __ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE}) |
Antonio de Angelis | df5817d | 2019-06-20 16:07:26 +0100 | [diff] [blame] | 153 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE ${TARGET_COMPILE_DEFINITIONS}) |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 154 | |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 155 | #Set include directories. |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 156 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TEST_INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 157 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${INTERFACE_DIR}/include ABSOLUTE APPEND) |
| 158 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR} ABSOLUTE APPEND) |
| 159 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/spm ABSOLUTE APPEND) |
Ken Liu | b8ed8ba | 2019-07-09 12:52:08 +0800 | [diff] [blame] | 160 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${TFM_ROOT_DIR}/secure_fw/core/include ABSOLUTE APPEND) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 161 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Include ABSOLUTE APPEND) |
| 162 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/Include ABSOLUTE APPEND) |
| 163 | embedded_target_include_directories(TARGET ${PROJECT_OBJ_LIB} PATH ${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Config ABSOLUTE APPEND) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 164 | |
Mate Toth-Pal | 5313609 | 2018-09-19 09:34:01 +0200 | [diff] [blame] | 165 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
| 166 | message(FATAL_ERROR "Incomplete build configuration: TFM_NS_CLIENT_IDENTIFICATION is undefined.") |
| 167 | elseif (TFM_NS_CLIENT_IDENTIFICATION) |
| 168 | target_compile_definitions(${PROJECT_OBJ_LIB} PRIVATE TFM_NS_CLIENT_IDENTIFICATION) |
| 169 | endif() |
| 170 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 171 | # For the non-swapping BL2 configuration two executables need to be built. |
David Vincze | 8bdfc2d | 2019-03-18 15:49:23 +0100 | [diff] [blame] | 172 | # One can be executed from the primary slot flash partition and other from the |
| 173 | # secondary slot. Only the linking phase is different. This function captures |
| 174 | # common settings and eliminates copy-paste. |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 175 | function(set_up_app_build) |
| 176 | set( _OPTIONS_ARGS) #Option (on/off) arguments (e.g. IGNORE_CASE) |
| 177 | set( _ONE_VALUE_ARGS NS_TARGET S_TARGET FULL_BIN SIGN_BIN VENEER_NAME POSTFIX) #Single option arguments (e.g. PATH "./foo/bar") |
| 178 | set( _MULTI_VALUE_ARGS LINK_DEFINES) #List arguments (e.g. LANGUAGES C ASM CXX) |
| 179 | cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 180 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 181 | if (NOT DEFINED _MY_PARAMS_NS_TARGET) |
| 182 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'NS_TARGET' missing.") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 183 | endif() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 184 | |
| 185 | if (NOT DEFINED _MY_PARAMS_S_TARGET) |
| 186 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'S_TARGET' missing.") |
| 187 | endif() |
| 188 | |
| 189 | if (NOT DEFINED _MY_PARAMS_FULL_BIN) |
| 190 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'FULL_BIN' missing.") |
| 191 | endif() |
| 192 | |
| 193 | if (NOT DEFINED _MY_PARAMS_SIGN_BIN) |
| 194 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'SIGN_BIN' missing.") |
| 195 | endif() |
| 196 | |
| 197 | if (NOT DEFINED _MY_PARAMS_VENEER_NAME) |
| 198 | message(FATAL_ERROR "set_up_app_build(): mandatory parameter 'VENEER_NAME' missing.") |
| 199 | endif() |
| 200 | |
| 201 | set(EXE_NAME ${_MY_PARAMS_NS_TARGET}${_MY_PARAMS_POSTFIX}) |
| 202 | set(S_BIN ${_MY_PARAMS_S_TARGET}${_MY_PARAMS_POSTFIX}) |
| 203 | set(FULL_NAME ${_MY_PARAMS_FULL_BIN}${_MY_PARAMS_POSTFIX}) |
| 204 | set(SIGN_NAME ${_MY_PARAMS_SIGN_BIN}${_MY_PARAMS_POSTFIX}) |
| 205 | set(VENEER_NAME ${_MY_PARAMS_VENEER_NAME}${_MY_PARAMS_POSTFIX}.o) |
| 206 | |
| 207 | #Create linker target: add object library to executable |
Tamas Ban | a4574d9 | 2019-03-06 14:21:33 +0000 | [diff] [blame] | 208 | add_executable(${EXE_NAME} $<TARGET_OBJECTS:${PROJECT_OBJ_LIB}>) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 209 | |
| 210 | #Set common linker flags |
| 211 | config_setting_shared_linker_flags(${EXE_NAME}) |
| 212 | |
| 213 | #Set individual linker flags per linker target/executable |
| 214 | foreach(flag ${_MY_PARAMS_LINK_DEFINES}) |
| 215 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "${flag}") |
| 216 | endforeach(flag) |
| 217 | |
| 218 | embedded_set_target_linker_file(TARGET ${EXE_NAME} PATH "${NS_SCATTER_FILE_NAME}") |
| 219 | |
| 220 | #Add the RTX library |
| 221 | if(NOT DEFINED RTX_LIB_PATH) |
| 222 | message(FATAL_ERROR "ERROR: Incomplete Configuration: RTX_LIB_PATH is not defined.") |
| 223 | endif() |
| 224 | target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}") |
| 225 | |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 226 | #Add the PSA API compliance test libraries |
| 227 | if(NOT DEFINED PSA_API_TEST_BUILD_PATH) |
| 228 | #If not specified, assume it's the default build folder checked out at the same level of TFM root dir |
| 229 | set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD") |
| 230 | endif() |
| 231 | if(PSA_API_TEST_NS) |
| 232 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a") |
| 233 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a") |
| 234 | endif() |
| 235 | if(PSA_API_TEST_NS AND PSA_API_TEST_SECURE_STORAGE) |
| 236 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/protected_storage/test_combine.a") |
| 237 | endif() |
| 238 | if(PSA_API_TEST_NS AND PSA_API_TEST_CRYPTO) |
| 239 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/crypto/test_combine.a") |
| 240 | endif() |
| 241 | if(PSA_API_TEST_NS AND PSA_API_TEST_ATTESTATION) |
| 242 | target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a") |
| 243 | endif() |
| 244 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 245 | if(NOT DEFINED PLATFORM_LINK_INCLUDES) |
| 246 | message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.") |
| 247 | endif() |
| 248 | embedded_set_target_link_includes(TARGET ${EXE_NAME} INCLUDES "${PLATFORM_LINK_INCLUDES}") |
| 249 | |
| 250 | #Generate binary file from axf |
| 251 | compiler_generate_binary_output(${EXE_NAME}) |
| 252 | |
| 253 | #Generate MCUBoot compatible payload |
| 254 | if (BL2) |
| 255 | mcuboot_create_boot_payload(S_BIN ${S_BIN} |
| 256 | NS_BIN ${EXE_NAME} |
| 257 | FULL_BIN ${FULL_NAME} |
| 258 | SIGN_BIN ${SIGN_NAME} |
| 259 | POSTFIX ${_MY_PARAMS_POSTFIX}) |
| 260 | endif() |
| 261 | |
| 262 | if (NOT DEFINED TFM_PARTITION_TEST_CORE) |
| 263 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE is undefined. ") |
| 264 | elseif (TFM_PARTITION_TEST_CORE) |
| 265 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE") |
| 266 | endif() |
| 267 | |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 268 | if (NOT DEFINED TFM_PARTITION_TEST_CORE_IPC) |
| 269 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_CORE_IPC is undefined.") |
| 270 | elseif (TFM_PARTITION_TEST_CORE_IPC) |
| 271 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_CORE_IPC") |
| 272 | endif() |
| 273 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 274 | if (NOT DEFINED TFM_PARTITION_TEST_SECURE_SERVICES) |
| 275 | message(FATAL_ERROR "Incomplete build configuration: TFM_PARTITION_TEST_SECURE_SERVICES is undefined. ") |
| 276 | elseif (TFM_PARTITION_TEST_SECURE_SERVICES) |
| 277 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TFM_PARTITION_TEST_SECURE_SERVICES") |
| 278 | endif() |
| 279 | |
Marc Moreno Berengue | cae2c53 | 2018-10-09 12:58:46 +0100 | [diff] [blame] | 280 | if (NOT DEFINED TEST_FRAMEWORK_S) |
| 281 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_S is undefined.") |
| 282 | elseif (TEST_FRAMEWORK_S) |
| 283 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_S") |
| 284 | endif() |
| 285 | |
| 286 | if (NOT DEFINED TEST_FRAMEWORK_NS) |
| 287 | message(FATAL_ERROR "Incomplete build configuration: TEST_FRAMEWORK_NS is undefined.") |
| 288 | elseif (TEST_FRAMEWORK_NS) |
| 289 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "TEST_FRAMEWORK_NS") |
| 290 | endif() |
| 291 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 292 | #Set BL2 specific settings. |
| 293 | if (BL2) |
David Vincze | 63eda7a | 2019-08-09 17:42:51 +0200 | [diff] [blame] | 294 | #Add BL2 and MCUBOOT_IMAGE_NUMBER defines to linker to resolve symbols in region_defs.h and flash_layout.h |
| 295 | embedded_set_target_link_defines(TARGET ${EXE_NAME} DEFINES "BL2" "MCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}") |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 296 | endif() |
| 297 | |
| 298 | #We depend on the non secure tests. See if the library target is available. |
| 299 | if(TARGET tfm_non_secure_tests) |
| 300 | #If yes, then use the library. |
| 301 | target_link_libraries(${EXE_NAME} tfm_non_secure_tests) |
| 302 | #Ensure library is built first. |
| 303 | add_dependencies(${EXE_NAME} tfm_non_secure_tests) |
| 304 | endif() |
| 305 | |
| 306 | #Ensure secure_fw is built before our executable. |
| 307 | add_dependencies(${EXE_NAME} ${S_BIN}) |
| 308 | |
Ken Liu | d8e0b8c | 2019-08-01 13:43:16 +0800 | [diff] [blame] | 309 | if (NOT DEFINED S_VENEER_PATH) |
| 310 | if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/../secure_fw) |
| 311 | set (S_VENEER_PATH "${CMAKE_CURRENT_BINARY_DIR}/../secure_fw") |
| 312 | else() |
| 313 | message(FATAL_ERROR "No valid path for S_VENEER_PATH, secure_fw is built?") |
| 314 | endif() |
| 315 | endif() |
| 316 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 317 | #Add the veneers to the executable. |
Ken Liu | d8e0b8c | 2019-08-01 13:43:16 +0800 | [diff] [blame] | 318 | set(S_VENEER_FILE "${S_VENEER_PATH}/${VENEER_NAME}") |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 319 | set_property(TARGET ${EXE_NAME} APPEND PROPERTY LINK_LIBRARIES ${S_VENEER_FILE}) |
| 320 | |
| 321 | #Collect executables to common location: build/install/outputs/ |
| 322 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 323 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 324 | DESTINATION outputs/${TARGET_PLATFORM}/) |
| 325 | |
| 326 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.axf |
| 327 | ${CMAKE_CURRENT_BINARY_DIR}/${EXE_NAME}.bin |
| 328 | DESTINATION outputs/fvp/) |
| 329 | endfunction() |
| 330 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 331 | if (LINK_TO_BOTH_MEMORY_REGION) |
| 332 | #Link to primary memory region |
| 333 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
| 334 | S_TARGET tfm_s |
| 335 | FULL_BIN tfm_full |
| 336 | SIGN_BIN tfm_sign |
Tamas Ban | bba8564 | 2019-06-06 09:31:59 +0100 | [diff] [blame] | 337 | VENEER_NAME s_veneers) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 338 | |
| 339 | #Link to secondary memory region(add extra linker flag) |
Oliver Swede | 2144044 | 2018-07-10 09:31:32 +0100 | [diff] [blame] | 340 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 341 | LINK_DEFINES "LINK_TO_SECONDARY_PARTITION" |
| 342 | S_TARGET tfm_s |
| 343 | FULL_BIN tfm_full |
| 344 | SIGN_BIN tfm_sign |
| 345 | VENEER_NAME s_veneers |
Tamas Ban | 57bfa43 | 2018-04-13 16:05:49 +0100 | [diff] [blame] | 346 | POSTFIX "_1") |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 347 | else() |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 348 | #Link to primary memory region only |
Oliver Swede | 2144044 | 2018-07-10 09:31:32 +0100 | [diff] [blame] | 349 | set_up_app_build(NS_TARGET ${PROJECT_NAME} |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 350 | S_TARGET tfm_s |
| 351 | FULL_BIN tfm_full |
| 352 | SIGN_BIN tfm_sign |
| 353 | VENEER_NAME s_veneers) |
| 354 | endif() |
| 355 | |
| 356 | #If the tfm_non_secure_tests target is not available |
| 357 | if(NOT TARGET tfm_non_secure_tests) |
| 358 | #Add the test source to the build. |
| 359 | #As of today since secure_fw is built as a sub-project this code will never execute. |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 360 | option(ENABLE_INVERT_SERVICE_TESTS "" TRUE) |
| 361 | option(ENABLE_SECURE_STORAGE_SERVICE_TESTS "" TRUE) |
| 362 | include(../test/CMakeLists.inc) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 363 | target_sources(${PROJECT_OBJ_LIB} PUBLIC ${ALL_SRC_C} ${ALL_SRC_C_NS}) |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 364 | endif() |
| 365 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 366 | #Finally let CMake system apply changes after the whole project is defined. |
| 367 | if (TARGET ${PROJECT_NAME}) |
| 368 | embedded_project_end(${PROJECT_NAME}) |
| 369 | endif() |
Gyorgy Szing | 30fa987 | 2017-12-05 01:08:47 +0000 | [diff] [blame] | 370 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 371 | if (TARGET ${PROJECT_NAME}_1) |
| 372 | embedded_project_end(${PROJECT_NAME}_1) |
| 373 | endif() |
| 374 | |
| 375 | embedded_project_end(${PROJECT_OBJ_LIB}) |