Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 2 | # Copyright (c) 2018-2019, Arm Limited. All rights reserved. |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | if(NOT DEFINED REGRESSION) |
| 9 | message(FATAL_ERROR "ERROR: Incomplete Configuration: REGRESSION not defined, Include this file from a Config*.cmake") |
| 10 | elseif(NOT DEFINED CORE_TEST) |
| 11 | message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_TEST not defined, Include this file from a Config*.cmake") |
Tamas Ban | d90c81b | 2018-08-15 15:03:42 +0100 | [diff] [blame] | 12 | elseif(NOT DEFINED TFM_LVL) |
| 13 | message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_LVL not defined, Include this file from a Config*.cmake") |
David Hu | f2cfa12 | 2019-08-27 15:32:38 +0800 | [diff] [blame] | 14 | elseif(NOT DEFINED CORE_IPC) |
| 15 | message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_IPC not deinfed. Include this file from a Config*.cmake") |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 16 | endif() |
| 17 | |
Mate Toth-Pal | ee551bc | 2018-06-12 16:40:45 +0200 | [diff] [blame] | 18 | if(NOT DEFINED COMPILER) |
| 19 | message(FATAL_ERROR "ERROR: COMPILER is not set in command line") |
| 20 | elseif((NOT ${COMPILER} STREQUAL "ARMCLANG") AND (NOT ${COMPILER} STREQUAL "GNUARM")) |
| 21 | message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.") |
| 22 | endif() |
| 23 | |
Tamas Ban | dd10fe5 | 2019-09-18 11:52:32 +0100 | [diff] [blame] | 24 | #Configure the default build type |
| 25 | set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (i.e. Debug)") |
| 26 | |
Edison Ai | cb0ecf6 | 2019-07-10 18:43:51 +0800 | [diff] [blame] | 27 | if(CORE_IPC) |
| 28 | if (TFM_LVL EQUAL 3) |
| 29 | message(FATAL_ERROR "ERROR: Invalid isolation level!") |
| 30 | endif() |
| 31 | else() |
| 32 | if(NOT TFM_LVL EQUAL 1) |
| 33 | message(FATAL_ERROR "ERROR: Invalid isolation level!") |
| 34 | endif() |
| 35 | endif() |
| 36 | |
David Vincze | 4638b2a | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 37 | #BL2 bootloader (MCUBoot) related settings |
David Vincze | 54d0555 | 2019-08-05 12:58:47 +0200 | [diff] [blame] | 38 | include(${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/MCUBootConfig.cmake) |
David Vincze | 4638b2a | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 39 | |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 40 | set(BUILD_CMSIS_CORE Off) |
| 41 | set(BUILD_RETARGET Off) |
| 42 | set(BUILD_NATIVE_DRIVERS Off) |
| 43 | set(BUILD_TIME Off) |
| 44 | set(BUILD_STARTUP Off) |
| 45 | set(BUILD_TARGET_CFG Off) |
| 46 | set(BUILD_TARGET_HARDWARE_KEYS Off) |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 47 | set(BUILD_TARGET_NV_COUNTERS Off) |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 48 | set(BUILD_CMSIS_DRIVERS Off) |
| 49 | set(BUILD_UART_STDOUT Off) |
| 50 | set(BUILD_FLASH Off) |
Tamas Ban | 3681ce0 | 2018-11-22 15:19:24 +0000 | [diff] [blame] | 51 | set(BUILD_BOOT_SEED Off) |
Tamas Ban | 38e1731 | 2018-11-22 15:26:35 +0000 | [diff] [blame] | 52 | set(BUILD_DEVICE_ID Off) |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 53 | set(BUILD_PLAT_TEST Off) |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 54 | set(BUILD_BOOT_HAL Off) |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 55 | if(NOT DEFINED PLATFORM_CMAKE_FILE) |
| 56 | message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.") |
| 57 | elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE}) |
| 58 | message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.") |
| 59 | else() |
| 60 | include(${PLATFORM_CMAKE_FILE}) |
| 61 | endif() |
| 62 | |
David Hu | 857bfa5 | 2019-05-21 13:54:50 +0800 | [diff] [blame] | 63 | # Select the corresponding CPU type and configuration according to current |
| 64 | # building status in multi-core scenario. |
| 65 | # The updated configuration will be used in following compiler setting. |
| 66 | if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY) |
| 67 | include("Common/MultiCore") |
| 68 | |
| 69 | if (NOT DEFINED TFM_BUILD_IN_SPE) |
| 70 | message(FATAL_ERROR "Flag of building in SPE is not specified. Please set TFM_BUILD_IN_SPE.") |
| 71 | else() |
| 72 | select_arm_cpu_type(${TFM_BUILD_IN_SPE}) |
| 73 | endif() |
| 74 | endif() |
| 75 | |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 76 | if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY) |
| 77 | # CMSE is unnecessary in multi-core scenarios. |
| 78 | # TODO: Need further discussion about if CMSE is required when an Armv8-M |
| 79 | # core acts as secure core in multi-core scenario. |
| 80 | set (CMSE_FLAGS "") |
| 81 | set (ARM_FEATURE_CMSE 0) |
| 82 | else() |
| 83 | set (CMSE_FLAGS "-mcmse") |
| 84 | set (ARM_FEATURE_CMSE 3) |
| 85 | endif() |
| 86 | |
Mate Toth-Pal | ee551bc | 2018-06-12 16:40:45 +0200 | [diff] [blame] | 87 | if(${COMPILER} STREQUAL "ARMCLANG") |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 88 | #Use any ARMCLANG version found on PATH. Note: Only versions supported by the |
| 89 | #build system will work. A file cmake/Common/CompilerArmClangXY.cmake |
| 90 | #must be present with a matching version. |
| 91 | include("Common/FindArmClang") |
| 92 | include("Common/${ARMCLANG_MODULE}") |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 93 | |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 94 | set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none ${CMSE_FLAGS} -ffunction-sections -fdata-sections) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 95 | ##Shared compiler settings. |
| 96 | function(config_setting_shared_compiler_flags tgt) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 97 | embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 98 | endfunction() |
| 99 | |
| 100 | ##Shared linker settings. |
| 101 | function(config_setting_shared_linker_flags tgt) |
Antonio de Angelis | 3302f45 | 2019-07-19 10:36:33 +0100 | [diff] [blame] | 102 | embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --remove --info=summarysizes,sizes,totals,unused,veneers) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 103 | endfunction() |
| 104 | elseif(${COMPILER} STREQUAL "GNUARM") |
| 105 | #Use any GNUARM version found on PATH. Note: Only versions supported by the |
| 106 | #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake |
| 107 | #must be present with a matching version. |
| 108 | include("Common/FindGNUARM") |
| 109 | include("Common/${GNUARM_MODULE}") |
Mate Toth-Pal | 48fc6a0 | 2018-01-24 09:50:14 +0100 | [diff] [blame] | 110 | |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 111 | set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float ${CMSE_FLAGS} -ffunction-sections -fdata-sections --specs=nano.specs) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 112 | ##Shared compiler and linker settings. |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 113 | function(config_setting_shared_compiler_flags tgt) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 114 | embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror -Wno-format -Wno-return-type -Wno-unused-but-set-variable) |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 115 | endfunction() |
| 116 | |
| 117 | ##Shared linker settings. |
| 118 | function(config_setting_shared_linker_flags tgt) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 119 | #--no-wchar-size-warning flag is added because TF-M sources are compiled |
| 120 | #with short wchars, however the standard library is compiled with normal |
| 121 | #wchar, and this generates linker time warnings. TF-M code does not use |
| 122 | #wchar, so the warning can be suppressed. |
Antonio de Angelis | 3302f45 | 2019-07-19 10:36:33 +0100 | [diff] [blame] | 123 | embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Wl,-check-sections,-fatal-warnings,--gc-sections,--no-wchar-size-warning,--print-memory-usage --entry=Reset_Handler --specs=nano.specs) |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 124 | endfunction() |
Mate Toth-Pal | 7686726 | 2018-03-09 13:15:36 +0100 | [diff] [blame] | 125 | endif() |
| 126 | |
| 127 | #Create a string from the compile flags list, so that it can be used later |
| 128 | #in this file to set mbedtls and BL2 flags |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 129 | list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS}) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 130 | |
| 131 | #Settings which shall be set for all projects the same way based |
| 132 | # on the variables above. |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 133 | set (TFM_PARTITION_TEST_CORE OFF) |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 134 | set (TFM_PARTITION_TEST_CORE_IPC OFF) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 135 | set (CORE_TEST_POSITIVE OFF) |
| 136 | set (CORE_TEST_INTERACTIVE OFF) |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 137 | set (REFERENCE_PLATFORM OFF) |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 138 | set (TFM_PARTITION_TEST_SECURE_SERVICES OFF) |
Tamas Ban | d90c81b | 2018-08-15 15:03:42 +0100 | [diff] [blame] | 139 | set (SERVICES_TEST_ENABLED OFF) |
Marc Moreno Berengue | cae2c53 | 2018-10-09 12:58:46 +0100 | [diff] [blame] | 140 | set (TEST_FRAMEWORK_S OFF) |
| 141 | set (TEST_FRAMEWORK_NS OFF) |
Edison Ai | ec109cd | 2018-07-17 16:04:14 +0800 | [diff] [blame] | 142 | set (TFM_PSA_API OFF) |
Miklos Balint | 87da251 | 2018-04-19 13:45:50 +0200 | [diff] [blame] | 143 | set (TFM_LEGACY_API ON) |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 144 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 145 | option(TFM_PARTITION_AUDIT_LOG "Enable the TF-M Audit Log partition" ON) |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 146 | option(TFM_PARTITION_PLATFORM "Enable the TF-M Platform partition" ON) |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 147 | |
Marton Berke | 6fd21f1 | 2019-07-02 13:43:07 +0200 | [diff] [blame] | 148 | if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519" OR ${TARGET_PLATFORM} STREQUAL "AN539") |
Miklos Balint | f13ec02 | 2018-04-06 17:21:22 +0200 | [diff] [blame] | 149 | set (REFERENCE_PLATFORM ON) |
| 150 | endif() |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 151 | |
Miklos Balint | 6cbeba6 | 2018-04-12 17:31:34 +0200 | [diff] [blame] | 152 | # Option to demonstrate usage of secure-only peripheral |
| 153 | set (SECURE_UART1 OFF) |
| 154 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 155 | if (REGRESSION) |
| 156 | set(SERVICES_TEST_ENABLED ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 157 | endif() |
| 158 | |
Edison Ai | ec109cd | 2018-07-17 16:04:14 +0800 | [diff] [blame] | 159 | if (CORE_IPC) |
| 160 | set(TFM_PSA_API ON) |
David Hu | f2cfa12 | 2019-08-27 15:32:38 +0800 | [diff] [blame] | 161 | |
| 162 | # Disable IPC Test by default if the config or platform doesn't explicitly |
| 163 | # require it |
| 164 | if (NOT DEFINED IPC_TEST) |
| 165 | set(IPC_TEST OFF) |
| 166 | endif() |
| 167 | else() |
| 168 | set(IPC_TEST OFF) |
Edison Ai | ec109cd | 2018-07-17 16:04:14 +0800 | [diff] [blame] | 169 | endif() |
| 170 | |
Miklos Balint | 87da251 | 2018-04-19 13:45:50 +0200 | [diff] [blame] | 171 | if (TFM_PSA_API) |
| 172 | add_definitions(-DTFM_PSA_API) |
| 173 | endif() |
| 174 | |
| 175 | if (TFM_LEGACY_API) |
| 176 | add_definitions(-DTFM_LEGACY_API) |
| 177 | endif() |
| 178 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 179 | if (SERVICES_TEST_ENABLED) |
| 180 | set(SERVICE_TEST_S ON) |
| 181 | set(SERVICE_TEST_NS ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 182 | endif() |
| 183 | |
| 184 | if (CORE_TEST) |
Mate Toth-Pal | 6569a59 | 2019-06-07 12:09:50 +0200 | [diff] [blame] | 185 | set(CORE_TEST_POSITIVE ON) |
| 186 | set(CORE_TEST_INTERACTIVE OFF) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 187 | endif() |
| 188 | |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 189 | if (CORE_TEST_INTERACTIVE) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 190 | add_definitions(-DCORE_TEST_INTERACTIVE) |
| 191 | set(TEST_FRAMEWORK_NS ON) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 192 | set(TFM_PARTITION_TEST_CORE ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 193 | endif() |
| 194 | |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 195 | if (CORE_TEST_POSITIVE) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 196 | add_definitions(-DCORE_TEST_POSITIVE) |
| 197 | set(TEST_FRAMEWORK_NS ON) |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 198 | set(TFM_PARTITION_TEST_CORE ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 199 | endif() |
| 200 | |
David Hu | 33f2fd2 | 2019-08-16 15:32:39 +0800 | [diff] [blame] | 201 | if (TFM_PARTITION_TEST_CORE) |
| 202 | # If the platform or the topology doesn't specify whether IRQ test is |
| 203 | # supported, enable it by default. |
| 204 | if (NOT DEFINED TFM_ENABLE_IRQ_TEST) |
| 205 | set(TFM_ENABLE_IRQ_TEST ON) |
| 206 | endif() |
| 207 | |
| 208 | if (TFM_ENABLE_IRQ_TEST) |
| 209 | add_definitions(-DTFM_ENABLE_IRQ_TEST) |
| 210 | endif() |
| 211 | else() |
| 212 | set(TFM_ENABLE_IRQ_TEST OFF) |
| 213 | endif() |
| 214 | |
David Hu | f2cfa12 | 2019-08-27 15:32:38 +0800 | [diff] [blame] | 215 | if (IPC_TEST) |
| 216 | add_definitions(-DENABLE_IPC_TEST) |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 217 | set(TEST_FRAMEWORK_NS ON) |
| 218 | set(TFM_PARTITION_TEST_CORE_IPC ON) |
Edison Ai | ec109cd | 2018-07-17 16:04:14 +0800 | [diff] [blame] | 219 | endif() |
| 220 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 221 | if (SERVICE_TEST_S) |
| 222 | add_definitions(-DSERVICES_TEST_S) |
| 223 | set(TEST_FRAMEWORK_S ON) |
| 224 | endif() |
| 225 | |
| 226 | if (SERVICE_TEST_NS) |
| 227 | add_definitions(-DSERVICES_TEST_NS) |
| 228 | set(TEST_FRAMEWORK_NS ON) |
| 229 | endif() |
| 230 | |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 231 | if (TEST_FRAMEWORK_S) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 232 | add_definitions(-DTEST_FRAMEWORK_S) |
Jamie Fox | 56da099 | 2019-05-28 14:35:06 +0100 | [diff] [blame] | 233 | # The secure client partition is required to run secure tests |
| 234 | set(TFM_PARTITION_TEST_SECURE_SERVICES ON) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 235 | endif() |
| 236 | |
Ben Davis | 6d7256b | 2018-04-18 14:16:53 +0100 | [diff] [blame] | 237 | if (TEST_FRAMEWORK_NS) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 238 | add_definitions(-DTEST_FRAMEWORK_NS) |
| 239 | endif() |
| 240 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 241 | if (CORE_IPC) |
| 242 | set(TFM_PARTITION_AUDIT_LOG OFF) |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 243 | set(TFM_PARTITION_PLATFORM OFF) |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 244 | endif() |
| 245 | |
| 246 | if (TFM_PARTITION_AUDIT_LOG) |
| 247 | add_definitions(-DTFM_PARTITION_AUDIT_LOG) |
| 248 | endif() |
| 249 | |
Mingyang Sun | 9511e5e | 2019-05-29 18:18:44 +0800 | [diff] [blame] | 250 | if (TFM_PARTITION_PLATFORM) |
| 251 | add_definitions(-DTFM_PARTITION_PLATFORM) |
| 252 | endif() |
| 253 | |
Mate Toth-Pal | 349714a | 2018-02-23 15:30:24 +0100 | [diff] [blame] | 254 | if (TFM_PARTITION_TEST_CORE) |
| 255 | add_definitions(-DTFM_PARTITION_TEST_CORE) |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 256 | endif() |
| 257 | |
Jamie Fox | adf0255 | 2019-05-16 17:44:52 +0100 | [diff] [blame] | 258 | if (TFM_PARTITION_TEST_CORE_IPC) |
| 259 | add_definitions(-DTFM_PARTITION_TEST_CORE_IPC) |
| 260 | endif() |
| 261 | |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 262 | if (TFM_PARTITION_TEST_SECURE_SERVICES) |
| 263 | add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES) |
| 264 | endif() |
| 265 | |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 266 | if (PSA_API_TEST) |
| 267 | add_definitions(-DPSA_API_TEST_NS) |
| 268 | set(PSA_API_TEST_NS ON) |
| 269 | if (NOT DEFINED PSA_API_TEST_CRYPTO) |
| 270 | set(PSA_API_TEST_CRYPTO OFF) |
| 271 | endif() |
Jamie Fox | 6b6a19b | 2019-09-30 16:54:17 +0100 | [diff] [blame] | 272 | if (NOT DEFINED PSA_API_TEST_INTERNAL_TRUSTED_STORAGE) |
| 273 | set(PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OFF) |
| 274 | endif() |
Jamie Fox | 17c30bb | 2019-01-10 13:39:33 +0000 | [diff] [blame] | 275 | if (NOT DEFINED PSA_API_TEST_SECURE_STORAGE) |
| 276 | set(PSA_API_TEST_SECURE_STORAGE OFF) |
| 277 | endif() |
| 278 | if (NOT DEFINED PSA_API_TEST_ATTESTATION) |
| 279 | set(PSA_API_TEST_ATTESTATION OFF) |
| 280 | endif() |
| 281 | endif() |
| 282 | |
Marc Moreno Berengue | c2e4db8 | 2018-09-14 16:32:24 +0100 | [diff] [blame] | 283 | # This flag indicates if the non-secure OS is capable of identify the non-secure clients |
Mingyang Sun | 9ac0237 | 2019-08-26 15:59:14 +0800 | [diff] [blame] | 284 | # which call the secure services. It is diabled in IPC model. |
Marc Moreno Berengue | c2e4db8 | 2018-09-14 16:32:24 +0100 | [diff] [blame] | 285 | if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION) |
Mingyang Sun | 9ac0237 | 2019-08-26 15:59:14 +0800 | [diff] [blame] | 286 | if (TFM_PSA_API) |
| 287 | set(TFM_NS_CLIENT_IDENTIFICATION OFF) |
| 288 | else() |
| 289 | set(TFM_NS_CLIENT_IDENTIFICATION ON) |
| 290 | endif() |
Marc Moreno Berengue | c2e4db8 | 2018-09-14 16:32:24 +0100 | [diff] [blame] | 291 | endif() |
| 292 | |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 293 | if (BL2) |
David Vincze | 63eda7a | 2019-08-09 17:42:51 +0200 | [diff] [blame] | 294 | # Add MCUBOOT_IMAGE_NUMBER definition to the compiler command line. |
| 295 | add_definitions(-DMCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER}) |
| 296 | |
David Vincze | 4638b2a | 2019-05-24 10:14:23 +0200 | [diff] [blame] | 297 | if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP") |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 298 | set(LINK_TO_BOTH_MEMORY_REGION ON) |
| 299 | endif() |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 300 | endif() |
| 301 | |
Jamie Fox | daade49 | 2019-04-26 14:35:39 +0100 | [diff] [blame] | 302 | ##Set Mbed TLS compiler flags and variables for audit log and crypto |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 303 | set(MBEDTLS_C_FLAGS_SERVICES "-D__ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common") |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 304 | |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 305 | #Default TF-M secure storage flags. |
| 306 | #These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake |
Tamas Ban | 01f64c5 | 2019-08-26 13:46:21 +0100 | [diff] [blame] | 307 | #Documentation about these flags can be found in docs/user_guides/services/tfm_sst_integration_guide.rst |
Marc Moreno Berengue | 8385e8e | 2019-01-21 11:49:50 +0000 | [diff] [blame] | 308 | if (NOT DEFINED SST_ENCRYPTION) |
| 309 | set (SST_ENCRYPTION ON) |
| 310 | endif() |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 311 | |
Marc Moreno Berengue | 8385e8e | 2019-01-21 11:49:50 +0000 | [diff] [blame] | 312 | if (NOT DEFINED SST_ROLLBACK_PROTECTION) |
| 313 | set (SST_ROLLBACK_PROTECTION OFF) |
| 314 | endif() |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 315 | |
Marc Moreno Berengue | 8385e8e | 2019-01-21 11:49:50 +0000 | [diff] [blame] | 316 | if (NOT DEFINED SST_CREATE_FLASH_LAYOUT) |
| 317 | set (SST_CREATE_FLASH_LAYOUT OFF) |
| 318 | endif() |
Marc Moreno Berengue | 184d203 | 2018-08-14 12:51:43 +0100 | [diff] [blame] | 319 | |
Marc Moreno Berengue | 8385e8e | 2019-01-21 11:49:50 +0000 | [diff] [blame] | 320 | if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH) |
| 321 | set (SST_VALIDATE_METADATA_FROM_FLASH ON) |
| 322 | endif() |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 323 | |
Marc Moreno Berengue | 8385e8e | 2019-01-21 11:49:50 +0000 | [diff] [blame] | 324 | if (NOT DEFINED SST_RAM_FS) |
| 325 | if (REGRESSION) |
| 326 | set (SST_RAM_FS ON) |
| 327 | else() |
| 328 | set (SST_RAM_FS OFF) |
Marc Moreno Berengue | 02a2344 | 2018-08-15 14:28:45 +0100 | [diff] [blame] | 329 | endif() |
Marc Moreno Berengue | 792fc68 | 2018-02-20 11:53:30 +0000 | [diff] [blame] | 330 | endif() |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 331 | |
Jamie Fox | 95bacd4 | 2019-03-21 18:14:15 +0000 | [diff] [blame] | 332 | if (NOT DEFINED SST_TEST_NV_COUNTERS) |
| 333 | if (REGRESSION AND (TFM_LVL EQUAL 1)) |
| 334 | set(SST_TEST_NV_COUNTERS ON) |
| 335 | else() |
| 336 | set(SST_TEST_NV_COUNTERS OFF) |
| 337 | endif() |
| 338 | endif() |
| 339 | |
TudorCretu | fb182bc | 2019-07-05 17:34:12 +0100 | [diff] [blame] | 340 | #Default TF-M internal trusted storage flags. |
| 341 | #These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake |
| 342 | #Documentation about these flags can be found in the TF-M ITS integration guide |
| 343 | option(ITS_CREATE_FLASH_LAYOUT "Create an empty ITS Flash Layout" OFF) |
| 344 | |
| 345 | if (NOT DEFINED ITS_VALIDATE_METADATA_FROM_FLASH) |
| 346 | set (ITS_VALIDATE_METADATA_FROM_FLASH ON) |
| 347 | endif() |
| 348 | |
| 349 | if (NOT DEFINED ITS_RAM_FS) |
| 350 | if (REGRESSION) |
| 351 | set (ITS_RAM_FS ON) |
| 352 | else() |
| 353 | set (ITS_RAM_FS OFF) |
| 354 | endif() |
| 355 | endif() |
| 356 | |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 357 | if (NOT DEFINED MBEDTLS_DEBUG) |
Jamie Fox | 287885f | 2018-10-24 14:09:34 +0100 | [diff] [blame] | 358 | set(MBEDTLS_DEBUG OFF) |
Marc Moreno Berengue | 6ffb22f | 2018-02-20 13:46:30 +0000 | [diff] [blame] | 359 | endif() |
Mate Toth-Pal | 65c935e | 2018-01-17 18:42:13 +0100 | [diff] [blame] | 360 | |
Tamas Ban | 01f64c5 | 2019-08-26 13:46:21 +0100 | [diff] [blame] | 361 | #Default TF-M initial-attestation service flags. |
| 362 | #Documentation about these flags can be found in docs/user_guides/services/tfm_attestation_integration_guide.rst |
| 363 | if (NOT DEFINED ATTEST_INCLUDE_OPTIONAL_CLAIMS) |
| 364 | set(ATTEST_INCLUDE_OPTIONAL_CLAIMS ON) |
| 365 | endif() |
| 366 | |
Tamas Ban | 303dd08 | 2019-08-27 10:43:03 +0100 | [diff] [blame] | 367 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 368 | set(ATTEST_INCLUDE_TEST_CODE_AND_KEY_ID ON) |
| 369 | else() |
| 370 | set(ATTEST_INCLUDE_TEST_CODE_AND_KEY_ID OFF) |
| 371 | endif() |
| 372 | |
David Vincze | 00dceb1 | 2019-09-17 17:34:03 +0200 | [diff] [blame] | 373 | set(ATTEST_BOOT_INTERFACE "CBOR_ENCODED_CLAIMS" CACHE STRING "Set the format in which to pass the claims to the initial-attestation service.") |
David Vincze | 219a175 | 2019-10-14 11:35:09 +0200 | [diff] [blame] | 374 | set_property(CACHE ATTEST_BOOT_INTERFACE PROPERTY STRINGS "INDIVIDUAL_CLAIMS;CBOR_ENCODED_CLAIMS") |
| 375 | validate_cache_value(ATTEST_BOOT_INTERFACE) |
| 376 | |
Tamas Ban | db69d52 | 2018-03-01 10:04:41 +0000 | [diff] [blame] | 377 | ##Set mbedTLS compiler flags for BL2 bootloader |
David Hu | feae0f9 | 2019-06-17 13:42:20 +0800 | [diff] [blame] | 378 | set(MBEDTLS_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-boot.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include") |
Tamas Ban | 7801ed4 | 2019-05-20 13:21:53 +0100 | [diff] [blame] | 379 | if (MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-3072") |
| 380 | string(APPEND MBEDTLS_C_FLAGS_BL2 " -DMCUBOOT_SIGN_RSA_LEN=3072") |
Jamie Fox | c78c62c | 2019-05-23 13:42:17 +0100 | [diff] [blame] | 381 | endif() |