blob: e8094f524e288fb1d52e8d3dd40de723f0405ab3 [file] [log] [blame]
Mate Toth-Pal65c935e2018-01-17 18:42:13 +01001#-------------------------------------------------------------------------------
Tamas Banabea89d2020-01-15 13:29:25 +00002# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Mate Toth-Pal65c935e2018-01-17 18:42:13 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8if(NOT DEFINED REGRESSION)
9 message(FATAL_ERROR "ERROR: Incomplete Configuration: REGRESSION not defined, Include this file from a Config*.cmake")
10elseif(NOT DEFINED CORE_TEST)
11 message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_TEST not defined, Include this file from a Config*.cmake")
Tamas Band90c81b2018-08-15 15:03:42 +010012elseif(NOT DEFINED TFM_LVL)
13 message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_LVL not defined, Include this file from a Config*.cmake")
David Huf2cfa122019-08-27 15:32:38 +080014elseif(NOT DEFINED CORE_IPC)
Tamas Banabea89d2020-01-15 13:29:25 +000015 message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_IPC not defined. Include this file from a Config*.cmake")
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010016endif()
17
Mate Toth-Palee551bc2018-06-12 16:40:45 +020018if(NOT DEFINED COMPILER)
19 message(FATAL_ERROR "ERROR: COMPILER is not set in command line")
TTornblom99f0be22019-12-17 16:22:38 +010020elseif((NOT ${COMPILER} STREQUAL "ARMCLANG") AND (NOT ${COMPILER} STREQUAL "GNUARM") AND (NOT ${COMPILER} STREQUAL "IARARM"))
Mate Toth-Palee551bc2018-06-12 16:40:45 +020021 message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
22endif()
23
Kevin Pengb3a70452020-07-08 17:50:09 +080024set(TEST_DIR ${CMAKE_SOURCE_DIR}/../tf-m-tests/test)
Kevin Pengc5781482020-07-08 15:30:24 +080025
Tamas Bandd10fe52019-09-18 11:52:32 +010026#Configure the default build type
27set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (i.e. Debug)")
28
Raef Colesb321c0b2019-10-15 08:49:17 +010029#Ignore case on the cmake build types
30string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
31
Edison Aicb0ecf62019-07-10 18:43:51 +080032if(CORE_IPC)
33 if (TFM_LVL EQUAL 3)
34 message(FATAL_ERROR "ERROR: Invalid isolation level!")
35 endif()
36else()
37 if(NOT TFM_LVL EQUAL 1)
38 message(FATAL_ERROR "ERROR: Invalid isolation level!")
39 endif()
40endif()
41
David Vincze4638b2a2019-05-24 10:14:23 +020042#BL2 bootloader (MCUBoot) related settings
David Vincze54d05552019-08-05 12:58:47 +020043include(${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/MCUBootConfig.cmake)
David Vincze4638b2a2019-05-24 10:14:23 +020044
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010045set(BUILD_CMSIS_CORE Off)
46set(BUILD_RETARGET Off)
47set(BUILD_NATIVE_DRIVERS Off)
48set(BUILD_TIME Off)
49set(BUILD_STARTUP Off)
50set(BUILD_TARGET_CFG Off)
51set(BUILD_TARGET_HARDWARE_KEYS Off)
Marc Moreno Berengue4cc81fc2018-08-10 14:32:01 +010052set(BUILD_TARGET_NV_COUNTERS Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010053set(BUILD_CMSIS_DRIVERS Off)
54set(BUILD_UART_STDOUT Off)
55set(BUILD_FLASH Off)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010056set(BUILD_PLAT_TEST Off)
Tamas Band4bf3472019-09-06 12:59:56 +010057set(BUILD_BOOT_HAL Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010058if(NOT DEFINED PLATFORM_CMAKE_FILE)
59 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
60elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
61 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
62else()
63 include(${PLATFORM_CMAKE_FILE})
64endif()
65
David Hu857bfa52019-05-21 13:54:50 +080066# Select the corresponding CPU type and configuration according to current
67# building status in multi-core scenario.
68# The updated configuration will be used in following compiler setting.
69if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
David Hu104388f2019-11-18 14:37:32 +080070 if (NOT CORE_IPC)
71 message(FATAL_ERROR "CORE_IPC is OFF. Multi-core topology should work in IPC model.")
72 endif()
73
David Hu857bfa52019-05-21 13:54:50 +080074 include("Common/MultiCore")
75
76 if (NOT DEFINED TFM_BUILD_IN_SPE)
77 message(FATAL_ERROR "Flag of building in SPE is not specified. Please set TFM_BUILD_IN_SPE.")
78 else()
79 select_arm_cpu_type(${TFM_BUILD_IN_SPE})
80 endif()
David Hu857bfa52019-05-21 13:54:50 +080081
David Hufeae0f92019-06-17 13:42:20 +080082 # CMSE is unnecessary in multi-core scenarios.
83 # TODO: Need further discussion about if CMSE is required when an Armv8-M
84 # core acts as secure core in multi-core scenario.
Mate Toth-Pal8f17a712020-03-02 16:22:19 +010085 # leave CMSE_FLAGS undefined
David Hufeae0f92019-06-17 13:42:20 +080086else()
TTornblom99f0be22019-12-17 16:22:38 +010087 if(${COMPILER} STREQUAL "IARARM")
88 set (CMSE_FLAGS "--cmse")
89 else()
90 set (CMSE_FLAGS "-mcmse")
91 endif()
David Huaeaf2732019-10-10 14:32:53 +080092
93 # Clear multi-core test setting
94 set (TFM_MULTI_CORE_TEST OFF)
David Hufeae0f92019-06-17 13:42:20 +080095endif()
96
Karl Zhangb10723f2020-07-23 11:47:05 +080097if(NOT ${COMPILER} STREQUAL "GNUARM")
98 if(CODE_COVERAGE_EN)
99 message(WARNING "CODE COVERAGE for '${COMPILER}' is not supported.")
100 endif()
101endif()
102
Mate Toth-Palee551bc2018-06-12 16:40:45 +0200103if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +0100104 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
105 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
106 #must be present with a matching version.
107 include("Common/FindArmClang")
108 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100109
Ken Liu8e7622b2020-04-16 17:05:56 +0800110 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -ffunction-sections -fdata-sections -fno-builtin -nostdlib)
Tamas Bandb69d522018-03-01 10:04:41 +0000111 ##Shared compiler settings.
112 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal8f17a712020-03-02 16:22:19 +0100113 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C APPEND FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror)
Tamas Bandb69d522018-03-01 10:04:41 +0000114 endfunction()
115
116 ##Shared linker settings.
117 function(config_setting_shared_linker_flags tgt)
Antonio de Angelis3302f452019-07-19 10:36:33 +0100118 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --remove --info=summarysizes,sizes,totals,unused,veneers)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100119 endfunction()
120elseif(${COMPILER} STREQUAL "GNUARM")
121 #Use any GNUARM version found on PATH. Note: Only versions supported by the
122 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
123 #must be present with a matching version.
124 include("Common/FindGNUARM")
125 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100126
Ken Liu8e7622b2020-04-16 17:05:56 +0800127 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -ffunction-sections -fdata-sections --specs=nano.specs -fno-builtin)
Karl Zhangb10723f2020-07-23 11:47:05 +0800128
129 #Code coverage required
130 if(CODE_COVERAGE_EN)
131 set (CODE_COVERAGE_FLAGS -g)
132 else()
133 unset (CODE_COVERAGE_FLAGS)
134 endif()
135
Mate Toth-Pal76867262018-03-09 13:15:36 +0100136 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +0000137 function(config_setting_shared_compiler_flags tgt)
Karl Zhangb10723f2020-07-23 11:47:05 +0800138 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C APPEND FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} ${CODE_COVERAGE_FLAGS} -Wall -Werror -Wno-format -Wno-return-type -Wno-unused-but-set-variable)
Tamas Bandb69d522018-03-01 10:04:41 +0000139 endfunction()
140
141 ##Shared linker settings.
142 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100143 #--no-wchar-size-warning flag is added because TF-M sources are compiled
144 #with short wchars, however the standard library is compiled with normal
145 #wchar, and this generates linker time warnings. TF-M code does not use
146 #wchar, so the warning can be suppressed.
Antonio de Angelis3302f452019-07-19 10:36:33 +0100147 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-Pal76867262018-03-09 13:15:36 +0100148 endfunction()
TTornblom99f0be22019-12-17 16:22:38 +0100149elseif(${COMPILER} STREQUAL "IARARM")
150 #Use any IARARM version found on PATH. Note: Only versions supported by the
151 #build system will work. A file cmake/Common/CompilerIARARMXY.cmake
152 #must be present with a matching version.
153 include("Common/FindIARARM")
154 include("Common/${IARARM_MODULE}")
155
TTornblomae979882020-04-24 13:39:23 +0200156 set (COMMON_COMPILE_FLAGS -e --dlib_config=full --vla --silent -DNO_TYPEOF --diag_suppress Pe546,Pe940,Pa082,Pa084)
TTornblom99f0be22019-12-17 16:22:38 +0100157 ##Shared compiler and linker settings.
158 function(config_setting_shared_compiler_flags tgt)
TTornblom17766722020-07-10 08:42:44 +0200159 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C APPEND FLAGS ${COMMON_COMPILE_FLAGS} )
TTornblom99f0be22019-12-17 16:22:38 +0100160 endfunction()
161
162 ##Shared linker settings.
163 function(config_setting_shared_linker_flags tgt)
164 #--no-wchar-size-warning flag is added because TF-M sources are compiled
165 #with short wchars, however the standard library is compiled with normal
166 #wchar, and this generates linker time warnings. TF-M code does not use
167 #wchar, so the warning can be suppressed.
168 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --silent --semihosting --redirect __write=__write_buffered)
169 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +0100170endif()
171
172#Create a string from the compile flags list, so that it can be used later
173#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +0000174list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100175
176#Settings which shall be set for all projects the same way based
177# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100178set (TFM_PARTITION_TEST_CORE OFF)
Jamie Foxadf02552019-05-16 17:44:52 +0100179set (TFM_PARTITION_TEST_CORE_IPC OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100180set (CORE_TEST_POSITIVE OFF)
181set (CORE_TEST_INTERACTIVE OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +0100182set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Kevin Pengc6d74502020-03-04 16:55:37 +0800183set (TFM_PARTITION_TEST_PS OFF)
Tamas Band90c81b2018-08-15 15:03:42 +0100184set (SERVICES_TEST_ENABLED OFF)
Marc Moreno Berenguecae2c532018-10-09 12:58:46 +0100185set (TEST_FRAMEWORK_S OFF)
186set (TEST_FRAMEWORK_NS OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800187set (TFM_PSA_API OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200188
David Hu60105382019-12-25 13:37:05 +0800189if (NOT DEFINED TFM_PARTITION_AUDIT_LOG)
190 # Enable the TF-M Audit Log partition
191 set(TFM_PARTITION_AUDIT_LOG ON)
192endif()
193if (NOT DEFINED TFM_PARTITION_PLATFORM)
194 # Enable the TF-M Platform partition
195 set(TFM_PARTITION_PLATFORM ON)
196endif()
Kevin Pengc6d74502020-03-04 16:55:37 +0800197if (NOT DEFINED TFM_PARTITION_PROTECTED_STORAGE)
198 # Enable the TF-M Protected storage partition
199 set(TFM_PARTITION_PROTECTED_STORAGE ON)
David Hu60105382019-12-25 13:37:05 +0800200endif()
201if (NOT DEFINED TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
202 # Enable the TF-M internal trusted storage partition
203 set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON)
204endif()
205if (NOT DEFINED TFM_PARTITION_CRYPTO)
206 # Enable the TF-M crypto partition
207 set(TFM_PARTITION_CRYPTO ON)
208endif()
209if (NOT DEFINED TFM_PARTITION_INITIAL_ATTESTATION)
210 # Enable the TF-M initial attestation partition
211 set(TFM_PARTITION_INITIAL_ATTESTATION ON)
212endif()
Kevin Pengc73130f2019-10-22 17:27:18 +0800213
Edison Ai1dfd7b12020-02-23 14:16:08 +0800214if (NOT TFM_LVL EQUAL 1 AND NOT DEFINED CONFIG_TFM_ENABLE_MEMORY_PROTECT)
215 set (CONFIG_TFM_ENABLE_MEMORY_PROTECT ON)
216endif()
217
Kevin Pengc6d74502020-03-04 16:55:37 +0800218if (TFM_PARTITION_INITIAL_ATTESTATION OR TFM_PARTITION_PROTECTED_STORAGE)
Kevin Pengc73130f2019-10-22 17:27:18 +0800219 #PSA Initial Attestation and Protected storage rely on Cryptography API
220 set(TFM_PARTITION_CRYPTO ON)
221endif()
Jamie Foxc78c62c2019-05-23 13:42:17 +0100222
Kevin Pengc6d74502020-03-04 16:55:37 +0800223if (TFM_PARTITION_PROTECTED_STORAGE)
Kevin Peng0b5acd32020-03-03 15:17:58 +0800224 set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON)
225endif()
226
Miklos Balint6cbeba62018-04-12 17:31:34 +0200227# Option to demonstrate usage of secure-only peripheral
228set (SECURE_UART1 OFF)
229
Alan DeMars61844692019-10-22 08:23:29 -0700230if (PLATFORM_SVC_HANDLERS)
231 add_definitions(-DPLATFORM_SVC_HANDLERS)
232endif()
233
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100234if (REGRESSION)
235 set(SERVICES_TEST_ENABLED ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100236endif()
237
Edison Aiec109cd2018-07-17 16:04:14 +0800238if (CORE_IPC)
239 set(TFM_PSA_API ON)
David Huf2cfa122019-08-27 15:32:38 +0800240
241 # Disable IPC Test by default if the config or platform doesn't explicitly
242 # require it
243 if (NOT DEFINED IPC_TEST)
244 set(IPC_TEST OFF)
245 endif()
246else()
247 set(IPC_TEST OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800248endif()
249
Miklos Balint87da2512018-04-19 13:45:50 +0200250if (TFM_PSA_API)
251 add_definitions(-DTFM_PSA_API)
252endif()
253
David Hu104388f2019-11-18 14:37:32 +0800254if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
255 add_definitions(-DTFM_MULTI_CORE_TOPOLOGY)
David Huaeaf2732019-10-10 14:32:53 +0800256
257 # Skip multi-core test cases if regression test is disabled
258 if (NOT REGRESSION)
259 set(TFM_MULTI_CORE_TEST OFF)
260 endif()
David Hu104388f2019-11-18 14:37:32 +0800261endif()
262
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100263if (SERVICES_TEST_ENABLED)
264 set(SERVICE_TEST_S ON)
265 set(SERVICE_TEST_NS ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100266endif()
267
268if (CORE_TEST)
Kevin Peng726ad7a2020-01-22 15:49:29 +0800269 if (NOT CORE_IPC OR TFM_LVL EQUAL 1)
270 set(CORE_TEST_POSITIVE ON)
271 endif()
Mate Toth-Pal6569a592019-06-07 12:09:50 +0200272 set(CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100273endif()
274
Ben Davis6d7256b2018-04-18 14:16:53 +0100275if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100276 add_definitions(-DCORE_TEST_INTERACTIVE)
277 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100278 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100279endif()
280
Ben Davis6d7256b2018-04-18 14:16:53 +0100281if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100282 add_definitions(-DCORE_TEST_POSITIVE)
283 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100284 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100285endif()
286
David Hu33f2fd22019-08-16 15:32:39 +0800287if (TFM_PARTITION_TEST_CORE)
288 # If the platform or the topology doesn't specify whether IRQ test is
289 # supported, enable it by default.
290 if (NOT DEFINED TFM_ENABLE_IRQ_TEST)
291 set(TFM_ENABLE_IRQ_TEST ON)
292 endif()
293
294 if (TFM_ENABLE_IRQ_TEST)
295 add_definitions(-DTFM_ENABLE_IRQ_TEST)
296 endif()
297else()
298 set(TFM_ENABLE_IRQ_TEST OFF)
299endif()
300
David Huf2cfa122019-08-27 15:32:38 +0800301if (IPC_TEST)
302 add_definitions(-DENABLE_IPC_TEST)
Jamie Foxadf02552019-05-16 17:44:52 +0100303 set(TEST_FRAMEWORK_NS ON)
304 set(TFM_PARTITION_TEST_CORE_IPC ON)
Edison Aiec109cd2018-07-17 16:04:14 +0800305endif()
306
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100307if (SERVICE_TEST_S)
308 add_definitions(-DSERVICES_TEST_S)
309 set(TEST_FRAMEWORK_S ON)
310endif()
311
312if (SERVICE_TEST_NS)
313 add_definitions(-DSERVICES_TEST_NS)
314 set(TEST_FRAMEWORK_NS ON)
315endif()
316
Ben Davis6d7256b2018-04-18 14:16:53 +0100317if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100318 add_definitions(-DTEST_FRAMEWORK_S)
Jamie Fox56da0992019-05-28 14:35:06 +0100319 # The secure client partition is required to run secure tests
320 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100321endif()
322
Ben Davis6d7256b2018-04-18 14:16:53 +0100323if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100324 add_definitions(-DTEST_FRAMEWORK_NS)
325endif()
326
Jamie Foxc78c62c2019-05-23 13:42:17 +0100327if (CORE_IPC)
328 set(TFM_PARTITION_AUDIT_LOG OFF)
329endif()
330
Kevin Pengc5781482020-07-08 15:30:24 +0800331include(${TEST_DIR}/TestConfig.cmake)
Kevin Pengedde1de2019-10-25 17:12:45 +0800332
Jamie Foxc78c62c2019-05-23 13:42:17 +0100333if (TFM_PARTITION_AUDIT_LOG)
334 add_definitions(-DTFM_PARTITION_AUDIT_LOG)
335endif()
336
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800337if (TFM_PARTITION_PLATFORM)
338 add_definitions(-DTFM_PARTITION_PLATFORM)
339endif()
340
Kevin Pengc6d74502020-03-04 16:55:37 +0800341if (TFM_PARTITION_PROTECTED_STORAGE)
342 add_definitions(-DTFM_PARTITION_PROTECTED_STORAGE)
Kevin Pengc73130f2019-10-22 17:27:18 +0800343endif()
344
345if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
346 add_definitions(-DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
347endif()
348
349if (TFM_PARTITION_CRYPTO)
350 add_definitions(-DTFM_PARTITION_CRYPTO)
351endif()
352
353if (TFM_PARTITION_INITIAL_ATTESTATION)
354 add_definitions(-DTFM_PARTITION_INITIAL_ATTESTATION)
David Hu724a12d2020-01-21 15:44:21 +0800355
356 if (NOT DEFINED SYMMETRIC_INITIAL_ATTESTATION)
357 set(SYMMETRIC_INITIAL_ATTESTATION OFF)
358 endif()
359
360 if (SYMMETRIC_INITIAL_ATTESTATION)
361 add_definitions(-DSYMMETRIC_INITIAL_ATTESTATION)
362 endif()
Kevin Pengc73130f2019-10-22 17:27:18 +0800363endif()
364
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100365if (TFM_PARTITION_TEST_CORE)
366 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100367endif()
368
Jamie Foxadf02552019-05-16 17:44:52 +0100369if (TFM_PARTITION_TEST_CORE_IPC)
370 add_definitions(-DTFM_PARTITION_TEST_CORE_IPC)
371endif()
372
Jamie Foxc78c62c2019-05-23 13:42:17 +0100373if (TFM_PARTITION_TEST_SECURE_SERVICES)
374 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
375endif()
376
Edison Ai1dfd7b12020-02-23 14:16:08 +0800377if (CONFIG_TFM_ENABLE_MEMORY_PROTECT)
378 add_definitions(-DCONFIG_TFM_ENABLE_MEMORY_PROTECT)
379endif()
380
Jamie Fox17c30bb2019-01-10 13:39:33 +0000381if (PSA_API_TEST)
382 add_definitions(-DPSA_API_TEST_NS)
383 set(PSA_API_TEST_NS ON)
384 if (NOT DEFINED PSA_API_TEST_CRYPTO)
385 set(PSA_API_TEST_CRYPTO OFF)
386 endif()
Vinay Kumar Kotegowder75641062020-04-24 16:44:12 +0530387 if (NOT DEFINED PSA_API_TEST_STORAGE)
388 set(PSA_API_TEST_STORAGE OFF)
389 endif()
Jamie Fox6b6a19b2019-09-30 16:54:17 +0100390 if (NOT DEFINED PSA_API_TEST_INTERNAL_TRUSTED_STORAGE)
391 set(PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OFF)
392 endif()
Karl Zhang1895a2c2020-03-08 18:27:32 +0800393 if (NOT DEFINED PSA_API_TEST_PROTECTED_STORAGE)
394 set(PSA_API_TEST_PROTECTED_STORAGE OFF)
Jamie Fox17c30bb2019-01-10 13:39:33 +0000395 endif()
Karl Zhang1895a2c2020-03-08 18:27:32 +0800396 if (NOT DEFINED PSA_API_TEST_INITIAL_ATTESTATION)
397 set(PSA_API_TEST_INITIAL_ATTESTATION OFF)
Jamie Fox17c30bb2019-01-10 13:39:33 +0000398 endif()
Jaykumar Pitambarbhai Patel38e6db52020-01-09 16:35:41 +0530399 if (NOT DEFINED PSA_API_TEST_IPC)
400 set(PSA_API_TEST_IPC OFF)
401 endif()
402
403 #Set PSA API compliance test build path
404 if(NOT DEFINED PSA_API_TEST_BUILD_PATH)
405 #If not specified, assume it's the default build folder checked out at the same level of TFM root dir
406 set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD")
407 endif()
Jamie Fox17c30bb2019-01-10 13:39:33 +0000408endif()
409
Kevin Penge9b61a72020-01-06 17:01:44 +0800410# The config for enable secure context management in TF-M
411if (NOT DEFINED CONFIG_TFM_ENABLE_CTX_MGMT)
412 set(CONFIG_TFM_ENABLE_CTX_MGMT ON)
413endif()
414
415if (CONFIG_TFM_ENABLE_CTX_MGMT)
416 add_definitions(-DCONFIG_TFM_ENABLE_CTX_MGMT)
417endif()
418
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100419# This flag indicates if the non-secure OS is capable of identify the non-secure clients
Mingyang Sun9ac02372019-08-26 15:59:14 +0800420# which call the secure services. It is diabled in IPC model.
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100421if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
Mingyang Sun9ac02372019-08-26 15:59:14 +0800422 if (TFM_PSA_API)
423 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
424 else()
Kevin Penge9b61a72020-01-06 17:01:44 +0800425 if (CONFIG_TFM_ENABLE_CTX_MGMT)
426 set(TFM_NS_CLIENT_IDENTIFICATION ON)
427 else()
428 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
429 endif()
Mingyang Sun9ac02372019-08-26 15:59:14 +0800430 endif()
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100431endif()
432
Kevin Penge9b61a72020-01-06 17:01:44 +0800433if (NOT CONFIG_TFM_ENABLE_CTX_MGMT AND TFM_NS_CLIENT_IDENTIFICATION)
434 # NS client ID is part of context management.
435 message(FATAL_ERROR "TFM_NS_CLIENT_IDENTIFICATION cannot be ON when CONFIG_TFM_ENABLE_CTX_MGMT is OFF")
436endif()
437
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100438if (BL2)
David Vincze63eda7a2019-08-09 17:42:51 +0200439 # Add MCUBOOT_IMAGE_NUMBER definition to the compiler command line.
440 add_definitions(-DMCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER})
441
David Vincze4638b2a2019-05-24 10:14:23 +0200442 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
Tamas Bandb69d522018-03-01 10:04:41 +0000443 set(LINK_TO_BOTH_MEMORY_REGION ON)
444 endif()
David Vincze53998032020-06-10 15:54:31 +0200445
446 if (MCUBOOT_REPO STREQUAL "TF-M")
447 # FixMe: LEGACY_TFM_TLV_HEADER could be removed when MCUBoot fork is deleted.
448 set(LEGACY_TFM_TLV_HEADER ON)
449 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100450endif()
451
Raef Coles1bb168e2019-10-17 09:04:55 +0100452##Set Mbed Crypto compiler flags and variables for crypto service
Mate Toth-Pal8f17a712020-03-02 16:22:19 +0100453set(MBEDCRYPTO_C_FLAGS_SERVICES "${CMSE_FLAGS} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common")
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100454
Kevin Pengc6d74502020-03-04 16:55:37 +0800455#Default TF-M protected storage flags.
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000456#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
Kevin Pengc6d74502020-03-04 16:55:37 +0800457#Documentation about these flags can be found in docs/user_guides/services/tfm_ps_integration_guide.rst
458if (NOT DEFINED PS_ENCRYPTION)
459 set (PS_ENCRYPTION ON)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000460endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000461
Kevin Pengc6d74502020-03-04 16:55:37 +0800462if (NOT DEFINED PS_ROLLBACK_PROTECTION)
463 set (PS_ROLLBACK_PROTECTION OFF)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000464endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000465
Kevin Pengc6d74502020-03-04 16:55:37 +0800466if (NOT DEFINED PS_CREATE_FLASH_LAYOUT)
467 set (PS_CREATE_FLASH_LAYOUT OFF)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000468endif()
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100469
Kevin Pengc6d74502020-03-04 16:55:37 +0800470if (NOT DEFINED PS_VALIDATE_METADATA_FROM_FLASH)
471 set (PS_VALIDATE_METADATA_FROM_FLASH ON)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000472endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000473
Kevin Pengc6d74502020-03-04 16:55:37 +0800474if (NOT DEFINED PS_RAM_FS)
Jamie Foxf58bd222020-06-12 18:21:25 +0100475 set (PS_RAM_FS OFF)
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000476endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000477
Kevin Pengc6d74502020-03-04 16:55:37 +0800478if (NOT DEFINED PS_TEST_NV_COUNTERS)
479 if (REGRESSION AND ENABLE_PROTECTED_STORAGE_SERVICE_TESTS)
480 set(PS_TEST_NV_COUNTERS ON)
Jamie Fox95bacd42019-03-21 18:14:15 +0000481 else()
Kevin Pengc6d74502020-03-04 16:55:37 +0800482 set(PS_TEST_NV_COUNTERS OFF)
Jamie Fox95bacd42019-03-21 18:14:15 +0000483 endif()
484endif()
485
Kevin Pengc6d74502020-03-04 16:55:37 +0800486# The PS NV counter tests depend on the PS test partition to call
487# ps_system_prepare().
488if (PS_TEST_NV_COUNTERS)
489 set(TFM_PARTITION_TEST_PS ON)
490 add_definitions(-DTFM_PARTITION_TEST_PS)
Jamie Fox0e823a02019-10-28 17:28:19 +0000491endif()
492
TudorCretufb182bc2019-07-05 17:34:12 +0100493#Default TF-M internal trusted storage flags.
494#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
495#Documentation about these flags can be found in the TF-M ITS integration guide
496option(ITS_CREATE_FLASH_LAYOUT "Create an empty ITS Flash Layout" OFF)
497
498if (NOT DEFINED ITS_VALIDATE_METADATA_FROM_FLASH)
499 set (ITS_VALIDATE_METADATA_FROM_FLASH ON)
500endif()
501
502if (NOT DEFINED ITS_RAM_FS)
Jamie Foxf58bd222020-06-12 18:21:25 +0100503 set (ITS_RAM_FS OFF)
TudorCretufb182bc2019-07-05 17:34:12 +0100504endif()
505
Raef Coles1bb168e2019-10-17 09:04:55 +0100506if (NOT DEFINED MBEDCRYPTO_DEBUG)
507 set(MBEDCRYPTO_DEBUG OFF)
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000508endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100509
Tamas Ban01f64c52019-08-26 13:46:21 +0100510#Default TF-M initial-attestation service flags.
511#Documentation about these flags can be found in docs/user_guides/services/tfm_attestation_integration_guide.rst
512if (NOT DEFINED ATTEST_INCLUDE_OPTIONAL_CLAIMS)
513 set(ATTEST_INCLUDE_OPTIONAL_CLAIMS ON)
514endif()
515
Tamas Banabea89d2020-01-15 13:29:25 +0000516if (NOT DEFINED ATTEST_INCLUDE_COSE_KEY_ID)
517 set(ATTEST_INCLUDE_COSE_KEY_ID OFF)
518endif()
519
520if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
521 if (CMAKE_BUILD_TYPE STREQUAL "debug")
522 set(ATTEST_INCLUDE_TEST_CODE ON)
523 else()
524 set(ATTEST_INCLUDE_TEST_CODE OFF)
525 endif()
Tamas Ban303dd082019-08-27 10:43:03 +0100526endif()
527
David Vinczee13a48b2020-01-08 17:42:30 +0100528if (NOT DEFINED BOOT_DATA_AVAILABLE)
David Vincze141f2152020-02-19 09:42:07 +0100529 if (BL2)
David Vinczee13a48b2020-01-08 17:42:30 +0100530 set(BOOT_DATA_AVAILABLE ON)
531 else()
532 set(BOOT_DATA_AVAILABLE OFF)
533 endif()
534endif()
535
Balint Matyi95f58eb2020-05-22 08:52:32 +0100536if (NOT DEFINED ATTEST_CLAIM_VALUE_CHECK)
537 set(ATTEST_CLAIM_VALUE_CHECK OFF)
538endif()
539
Balint Matyi5c476312020-03-31 13:15:39 +0100540##Set common mbedTLS compiler flags for BL2 bootloader
541set(MBEDCRYPTO_C_FLAGS_BL2 "${CMSE_FLAGS} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-rsa.h\\\\\\\"")