blob: 830c63324c772a9f794f3a93a58750e10364127b [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
Mingyang Sun2b905a52020-09-08 16:09:00 +080032if(NOT CORE_IPC)
Edison Aicb0ecf62019-07-10 18:43:51 +080033 if(NOT TFM_LVL EQUAL 1)
34 message(FATAL_ERROR "ERROR: Invalid isolation level!")
35 endif()
36endif()
37
David Vincze4638b2a2019-05-24 10:14:23 +020038#BL2 bootloader (MCUBoot) related settings
David Vincze54d05552019-08-05 12:58:47 +020039include(${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/MCUBootConfig.cmake)
David Vincze4638b2a2019-05-24 10:14:23 +020040
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010041set(BUILD_CMSIS_CORE Off)
42set(BUILD_RETARGET Off)
43set(BUILD_NATIVE_DRIVERS Off)
44set(BUILD_TIME Off)
45set(BUILD_STARTUP Off)
46set(BUILD_TARGET_CFG Off)
47set(BUILD_TARGET_HARDWARE_KEYS Off)
Marc Moreno Berengue4cc81fc2018-08-10 14:32:01 +010048set(BUILD_TARGET_NV_COUNTERS Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010049set(BUILD_CMSIS_DRIVERS Off)
50set(BUILD_UART_STDOUT Off)
51set(BUILD_FLASH Off)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010052set(BUILD_PLAT_TEST Off)
Tamas Band4bf3472019-09-06 12:59:56 +010053set(BUILD_BOOT_HAL Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010054if(NOT DEFINED PLATFORM_CMAKE_FILE)
55 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
56elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
57 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
58else()
59 include(${PLATFORM_CMAKE_FILE})
60endif()
61
David Hu857bfa52019-05-21 13:54:50 +080062# Select the corresponding CPU type and configuration according to current
63# building status in multi-core scenario.
64# The updated configuration will be used in following compiler setting.
65if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
David Hu104388f2019-11-18 14:37:32 +080066 if (NOT CORE_IPC)
67 message(FATAL_ERROR "CORE_IPC is OFF. Multi-core topology should work in IPC model.")
68 endif()
69
David Hu857bfa52019-05-21 13:54:50 +080070 include("Common/MultiCore")
71
72 if (NOT DEFINED TFM_BUILD_IN_SPE)
73 message(FATAL_ERROR "Flag of building in SPE is not specified. Please set TFM_BUILD_IN_SPE.")
74 else()
75 select_arm_cpu_type(${TFM_BUILD_IN_SPE})
76 endif()
David Hu857bfa52019-05-21 13:54:50 +080077
David Hufeae0f92019-06-17 13:42:20 +080078 # CMSE is unnecessary in multi-core scenarios.
79 # TODO: Need further discussion about if CMSE is required when an Armv8-M
80 # core acts as secure core in multi-core scenario.
Mate Toth-Pal8f17a712020-03-02 16:22:19 +010081 # leave CMSE_FLAGS undefined
David Hufeae0f92019-06-17 13:42:20 +080082else()
TTornblom99f0be22019-12-17 16:22:38 +010083 if(${COMPILER} STREQUAL "IARARM")
84 set (CMSE_FLAGS "--cmse")
85 else()
86 set (CMSE_FLAGS "-mcmse")
87 endif()
David Huaeaf2732019-10-10 14:32:53 +080088
89 # Clear multi-core test setting
90 set (TFM_MULTI_CORE_TEST OFF)
David Hufeae0f92019-06-17 13:42:20 +080091endif()
92
Karl Zhangb10723f2020-07-23 11:47:05 +080093if(NOT ${COMPILER} STREQUAL "GNUARM")
94 if(CODE_COVERAGE_EN)
95 message(WARNING "CODE COVERAGE for '${COMPILER}' is not supported.")
96 endif()
97endif()
98
Mate Toth-Palee551bc2018-06-12 16:40:45 +020099if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +0100100 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
101 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
102 #must be present with a matching version.
103 include("Common/FindArmClang")
104 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100105
Ken Liu8e7622b2020-04-16 17:05:56 +0800106 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 +0000107 ##Shared compiler settings.
108 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal8f17a712020-03-02 16:22:19 +0100109 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 +0000110 endfunction()
111
112 ##Shared linker settings.
113 function(config_setting_shared_linker_flags tgt)
Antonio de Angelis3302f452019-07-19 10:36:33 +0100114 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 +0100115 endfunction()
116elseif(${COMPILER} STREQUAL "GNUARM")
117 #Use any GNUARM version found on PATH. Note: Only versions supported by the
118 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
119 #must be present with a matching version.
120 include("Common/FindGNUARM")
121 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100122
Ken Liu8e7622b2020-04-16 17:05:56 +0800123 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 +0800124
125 #Code coverage required
126 if(CODE_COVERAGE_EN)
127 set (CODE_COVERAGE_FLAGS -g)
128 else()
129 unset (CODE_COVERAGE_FLAGS)
130 endif()
131
Mate Toth-Pal76867262018-03-09 13:15:36 +0100132 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +0000133 function(config_setting_shared_compiler_flags tgt)
Karl Zhangb10723f2020-07-23 11:47:05 +0800134 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 +0000135 endfunction()
136
137 ##Shared linker settings.
138 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100139 #--no-wchar-size-warning flag is added because TF-M sources are compiled
140 #with short wchars, however the standard library is compiled with normal
141 #wchar, and this generates linker time warnings. TF-M code does not use
142 #wchar, so the warning can be suppressed.
Antonio de Angelis3302f452019-07-19 10:36:33 +0100143 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 +0100144 endfunction()
TTornblom99f0be22019-12-17 16:22:38 +0100145elseif(${COMPILER} STREQUAL "IARARM")
146 #Use any IARARM version found on PATH. Note: Only versions supported by the
147 #build system will work. A file cmake/Common/CompilerIARARMXY.cmake
148 #must be present with a matching version.
149 include("Common/FindIARARM")
150 include("Common/${IARARM_MODULE}")
151
TTornblomae979882020-04-24 13:39:23 +0200152 set (COMMON_COMPILE_FLAGS -e --dlib_config=full --vla --silent -DNO_TYPEOF --diag_suppress Pe546,Pe940,Pa082,Pa084)
TTornblom99f0be22019-12-17 16:22:38 +0100153 ##Shared compiler and linker settings.
154 function(config_setting_shared_compiler_flags tgt)
TTornblom17766722020-07-10 08:42:44 +0200155 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C APPEND FLAGS ${COMMON_COMPILE_FLAGS} )
TTornblom99f0be22019-12-17 16:22:38 +0100156 endfunction()
157
158 ##Shared linker settings.
159 function(config_setting_shared_linker_flags tgt)
160 #--no-wchar-size-warning flag is added because TF-M sources are compiled
161 #with short wchars, however the standard library is compiled with normal
162 #wchar, and this generates linker time warnings. TF-M code does not use
163 #wchar, so the warning can be suppressed.
164 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --silent --semihosting --redirect __write=__write_buffered)
165 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +0100166endif()
167
168#Create a string from the compile flags list, so that it can be used later
169#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +0000170list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100171
172#Settings which shall be set for all projects the same way based
173# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100174set (TFM_PARTITION_TEST_CORE OFF)
Jamie Foxadf02552019-05-16 17:44:52 +0100175set (TFM_PARTITION_TEST_CORE_IPC OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100176set (CORE_TEST_POSITIVE OFF)
177set (CORE_TEST_INTERACTIVE OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +0100178set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Kevin Pengc6d74502020-03-04 16:55:37 +0800179set (TFM_PARTITION_TEST_PS OFF)
Tamas Band90c81b2018-08-15 15:03:42 +0100180set (SERVICES_TEST_ENABLED OFF)
Marc Moreno Berenguecae2c532018-10-09 12:58:46 +0100181set (TEST_FRAMEWORK_S OFF)
182set (TEST_FRAMEWORK_NS OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800183set (TFM_PSA_API OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200184
David Hu60105382019-12-25 13:37:05 +0800185if (NOT DEFINED TFM_PARTITION_AUDIT_LOG)
186 # Enable the TF-M Audit Log partition
187 set(TFM_PARTITION_AUDIT_LOG ON)
188endif()
189if (NOT DEFINED TFM_PARTITION_PLATFORM)
190 # Enable the TF-M Platform partition
191 set(TFM_PARTITION_PLATFORM ON)
192endif()
Kevin Pengc6d74502020-03-04 16:55:37 +0800193if (NOT DEFINED TFM_PARTITION_PROTECTED_STORAGE)
194 # Enable the TF-M Protected storage partition
195 set(TFM_PARTITION_PROTECTED_STORAGE ON)
David Hu60105382019-12-25 13:37:05 +0800196endif()
197if (NOT DEFINED TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
198 # Enable the TF-M internal trusted storage partition
199 set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON)
200endif()
201if (NOT DEFINED TFM_PARTITION_CRYPTO)
202 # Enable the TF-M crypto partition
203 set(TFM_PARTITION_CRYPTO ON)
204endif()
205if (NOT DEFINED TFM_PARTITION_INITIAL_ATTESTATION)
206 # Enable the TF-M initial attestation partition
207 set(TFM_PARTITION_INITIAL_ATTESTATION ON)
208endif()
Kevin Pengc73130f2019-10-22 17:27:18 +0800209
Edison Ai1dfd7b12020-02-23 14:16:08 +0800210if (NOT TFM_LVL EQUAL 1 AND NOT DEFINED CONFIG_TFM_ENABLE_MEMORY_PROTECT)
211 set (CONFIG_TFM_ENABLE_MEMORY_PROTECT ON)
212endif()
213
Kevin Pengc6d74502020-03-04 16:55:37 +0800214if (TFM_PARTITION_INITIAL_ATTESTATION OR TFM_PARTITION_PROTECTED_STORAGE)
Kevin Pengc73130f2019-10-22 17:27:18 +0800215 #PSA Initial Attestation and Protected storage rely on Cryptography API
216 set(TFM_PARTITION_CRYPTO ON)
217endif()
Jamie Foxc78c62c2019-05-23 13:42:17 +0100218
Kevin Pengc6d74502020-03-04 16:55:37 +0800219if (TFM_PARTITION_PROTECTED_STORAGE)
Kevin Peng0b5acd32020-03-03 15:17:58 +0800220 set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON)
221endif()
222
Miklos Balint6cbeba62018-04-12 17:31:34 +0200223# Option to demonstrate usage of secure-only peripheral
224set (SECURE_UART1 OFF)
225
Alan DeMars61844692019-10-22 08:23:29 -0700226if (PLATFORM_SVC_HANDLERS)
227 add_definitions(-DPLATFORM_SVC_HANDLERS)
228endif()
229
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100230if (REGRESSION)
231 set(SERVICES_TEST_ENABLED ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100232endif()
233
Edison Aiec109cd2018-07-17 16:04:14 +0800234if (CORE_IPC)
235 set(TFM_PSA_API ON)
David Huf2cfa122019-08-27 15:32:38 +0800236
237 # Disable IPC Test by default if the config or platform doesn't explicitly
238 # require it
239 if (NOT DEFINED IPC_TEST)
240 set(IPC_TEST OFF)
241 endif()
242else()
243 set(IPC_TEST OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800244endif()
245
Miklos Balint87da2512018-04-19 13:45:50 +0200246if (TFM_PSA_API)
247 add_definitions(-DTFM_PSA_API)
248endif()
249
David Hu104388f2019-11-18 14:37:32 +0800250if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
251 add_definitions(-DTFM_MULTI_CORE_TOPOLOGY)
David Huaeaf2732019-10-10 14:32:53 +0800252
253 # Skip multi-core test cases if regression test is disabled
254 if (NOT REGRESSION)
255 set(TFM_MULTI_CORE_TEST OFF)
256 endif()
David Hu104388f2019-11-18 14:37:32 +0800257endif()
258
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100259if (SERVICES_TEST_ENABLED)
260 set(SERVICE_TEST_S ON)
261 set(SERVICE_TEST_NS ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100262endif()
263
264if (CORE_TEST)
Kevin Peng726ad7a2020-01-22 15:49:29 +0800265 if (NOT CORE_IPC OR TFM_LVL EQUAL 1)
266 set(CORE_TEST_POSITIVE ON)
267 endif()
Mate Toth-Pal6569a592019-06-07 12:09:50 +0200268 set(CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100269endif()
270
Ben Davis6d7256b2018-04-18 14:16:53 +0100271if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100272 add_definitions(-DCORE_TEST_INTERACTIVE)
273 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100274 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100275endif()
276
Ben Davis6d7256b2018-04-18 14:16:53 +0100277if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100278 add_definitions(-DCORE_TEST_POSITIVE)
279 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100280 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100281endif()
282
David Hu33f2fd22019-08-16 15:32:39 +0800283if (TFM_PARTITION_TEST_CORE)
284 # If the platform or the topology doesn't specify whether IRQ test is
285 # supported, enable it by default.
286 if (NOT DEFINED TFM_ENABLE_IRQ_TEST)
287 set(TFM_ENABLE_IRQ_TEST ON)
288 endif()
289
290 if (TFM_ENABLE_IRQ_TEST)
291 add_definitions(-DTFM_ENABLE_IRQ_TEST)
292 endif()
293else()
294 set(TFM_ENABLE_IRQ_TEST OFF)
295endif()
296
David Huf2cfa122019-08-27 15:32:38 +0800297if (IPC_TEST)
298 add_definitions(-DENABLE_IPC_TEST)
Jamie Foxadf02552019-05-16 17:44:52 +0100299 set(TEST_FRAMEWORK_NS ON)
300 set(TFM_PARTITION_TEST_CORE_IPC ON)
Edison Aiec109cd2018-07-17 16:04:14 +0800301endif()
302
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100303if (SERVICE_TEST_S)
304 add_definitions(-DSERVICES_TEST_S)
305 set(TEST_FRAMEWORK_S ON)
306endif()
307
308if (SERVICE_TEST_NS)
309 add_definitions(-DSERVICES_TEST_NS)
310 set(TEST_FRAMEWORK_NS ON)
311endif()
312
Ben Davis6d7256b2018-04-18 14:16:53 +0100313if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100314 add_definitions(-DTEST_FRAMEWORK_S)
Jamie Fox56da0992019-05-28 14:35:06 +0100315 # The secure client partition is required to run secure tests
316 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100317endif()
318
Ben Davis6d7256b2018-04-18 14:16:53 +0100319if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100320 add_definitions(-DTEST_FRAMEWORK_NS)
321endif()
322
Jamie Foxc78c62c2019-05-23 13:42:17 +0100323if (CORE_IPC)
324 set(TFM_PARTITION_AUDIT_LOG OFF)
325endif()
326
Kevin Pengc5781482020-07-08 15:30:24 +0800327include(${TEST_DIR}/TestConfig.cmake)
Kevin Pengedde1de2019-10-25 17:12:45 +0800328
Jamie Foxc78c62c2019-05-23 13:42:17 +0100329if (TFM_PARTITION_AUDIT_LOG)
330 add_definitions(-DTFM_PARTITION_AUDIT_LOG)
331endif()
332
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800333if (TFM_PARTITION_PLATFORM)
334 add_definitions(-DTFM_PARTITION_PLATFORM)
335endif()
336
Kevin Pengc6d74502020-03-04 16:55:37 +0800337if (TFM_PARTITION_PROTECTED_STORAGE)
338 add_definitions(-DTFM_PARTITION_PROTECTED_STORAGE)
Kevin Pengc73130f2019-10-22 17:27:18 +0800339endif()
340
341if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
342 add_definitions(-DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
343endif()
344
345if (TFM_PARTITION_CRYPTO)
346 add_definitions(-DTFM_PARTITION_CRYPTO)
347endif()
348
349if (TFM_PARTITION_INITIAL_ATTESTATION)
350 add_definitions(-DTFM_PARTITION_INITIAL_ATTESTATION)
David Hu724a12d2020-01-21 15:44:21 +0800351
352 if (NOT DEFINED SYMMETRIC_INITIAL_ATTESTATION)
353 set(SYMMETRIC_INITIAL_ATTESTATION OFF)
354 endif()
355
356 if (SYMMETRIC_INITIAL_ATTESTATION)
357 add_definitions(-DSYMMETRIC_INITIAL_ATTESTATION)
358 endif()
Kevin Pengc73130f2019-10-22 17:27:18 +0800359endif()
360
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100361if (TFM_PARTITION_TEST_CORE)
362 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100363endif()
364
Jamie Foxadf02552019-05-16 17:44:52 +0100365if (TFM_PARTITION_TEST_CORE_IPC)
366 add_definitions(-DTFM_PARTITION_TEST_CORE_IPC)
367endif()
368
Jamie Foxc78c62c2019-05-23 13:42:17 +0100369if (TFM_PARTITION_TEST_SECURE_SERVICES)
370 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
371endif()
372
Edison Ai1dfd7b12020-02-23 14:16:08 +0800373if (CONFIG_TFM_ENABLE_MEMORY_PROTECT)
374 add_definitions(-DCONFIG_TFM_ENABLE_MEMORY_PROTECT)
375endif()
376
Jamie Fox17c30bb2019-01-10 13:39:33 +0000377if (PSA_API_TEST)
378 add_definitions(-DPSA_API_TEST_NS)
379 set(PSA_API_TEST_NS ON)
380 if (NOT DEFINED PSA_API_TEST_CRYPTO)
381 set(PSA_API_TEST_CRYPTO OFF)
382 endif()
Vinay Kumar Kotegowder75641062020-04-24 16:44:12 +0530383 if (NOT DEFINED PSA_API_TEST_STORAGE)
384 set(PSA_API_TEST_STORAGE OFF)
385 endif()
Jamie Fox6b6a19b2019-09-30 16:54:17 +0100386 if (NOT DEFINED PSA_API_TEST_INTERNAL_TRUSTED_STORAGE)
387 set(PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OFF)
388 endif()
Karl Zhang1895a2c2020-03-08 18:27:32 +0800389 if (NOT DEFINED PSA_API_TEST_PROTECTED_STORAGE)
390 set(PSA_API_TEST_PROTECTED_STORAGE OFF)
Jamie Fox17c30bb2019-01-10 13:39:33 +0000391 endif()
Karl Zhang1895a2c2020-03-08 18:27:32 +0800392 if (NOT DEFINED PSA_API_TEST_INITIAL_ATTESTATION)
393 set(PSA_API_TEST_INITIAL_ATTESTATION OFF)
Jamie Fox17c30bb2019-01-10 13:39:33 +0000394 endif()
Jaykumar Pitambarbhai Patel38e6db52020-01-09 16:35:41 +0530395 if (NOT DEFINED PSA_API_TEST_IPC)
396 set(PSA_API_TEST_IPC OFF)
397 endif()
398
399 #Set PSA API compliance test build path
400 if(NOT DEFINED PSA_API_TEST_BUILD_PATH)
401 #If not specified, assume it's the default build folder checked out at the same level of TFM root dir
402 set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD")
403 endif()
Jamie Fox17c30bb2019-01-10 13:39:33 +0000404endif()
405
Kevin Penge9b61a72020-01-06 17:01:44 +0800406# The config for enable secure context management in TF-M
407if (NOT DEFINED CONFIG_TFM_ENABLE_CTX_MGMT)
408 set(CONFIG_TFM_ENABLE_CTX_MGMT ON)
409endif()
410
411if (CONFIG_TFM_ENABLE_CTX_MGMT)
412 add_definitions(-DCONFIG_TFM_ENABLE_CTX_MGMT)
413endif()
414
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100415# This flag indicates if the non-secure OS is capable of identify the non-secure clients
Mingyang Sun9ac02372019-08-26 15:59:14 +0800416# which call the secure services. It is diabled in IPC model.
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100417if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
Mingyang Sun9ac02372019-08-26 15:59:14 +0800418 if (TFM_PSA_API)
419 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
420 else()
Kevin Penge9b61a72020-01-06 17:01:44 +0800421 if (CONFIG_TFM_ENABLE_CTX_MGMT)
422 set(TFM_NS_CLIENT_IDENTIFICATION ON)
423 else()
424 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
425 endif()
Mingyang Sun9ac02372019-08-26 15:59:14 +0800426 endif()
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100427endif()
428
Kevin Penge9b61a72020-01-06 17:01:44 +0800429if (NOT CONFIG_TFM_ENABLE_CTX_MGMT AND TFM_NS_CLIENT_IDENTIFICATION)
430 # NS client ID is part of context management.
431 message(FATAL_ERROR "TFM_NS_CLIENT_IDENTIFICATION cannot be ON when CONFIG_TFM_ENABLE_CTX_MGMT is OFF")
432endif()
433
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100434if (BL2)
David Vincze63eda7a2019-08-09 17:42:51 +0200435 # Add MCUBOOT_IMAGE_NUMBER definition to the compiler command line.
436 add_definitions(-DMCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER})
437
David Vincze4638b2a2019-05-24 10:14:23 +0200438 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
Tamas Bandb69d522018-03-01 10:04:41 +0000439 set(LINK_TO_BOTH_MEMORY_REGION ON)
440 endif()
David Vincze53998032020-06-10 15:54:31 +0200441
442 if (MCUBOOT_REPO STREQUAL "TF-M")
443 # FixMe: LEGACY_TFM_TLV_HEADER could be removed when MCUBoot fork is deleted.
444 set(LEGACY_TFM_TLV_HEADER ON)
445 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100446endif()
447
Raef Coles1bb168e2019-10-17 09:04:55 +0100448##Set Mbed Crypto compiler flags and variables for crypto service
Mate Toth-Pal8f17a712020-03-02 16:22:19 +0100449set(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 +0100450
Kevin Pengc6d74502020-03-04 16:55:37 +0800451#Default TF-M protected storage flags.
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000452#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
Kevin Pengc6d74502020-03-04 16:55:37 +0800453#Documentation about these flags can be found in docs/user_guides/services/tfm_ps_integration_guide.rst
454if (NOT DEFINED PS_ENCRYPTION)
455 set (PS_ENCRYPTION ON)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000456endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000457
Kevin Pengc6d74502020-03-04 16:55:37 +0800458if (NOT DEFINED PS_ROLLBACK_PROTECTION)
459 set (PS_ROLLBACK_PROTECTION OFF)
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_CREATE_FLASH_LAYOUT)
463 set (PS_CREATE_FLASH_LAYOUT OFF)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000464endif()
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100465
Kevin Pengc6d74502020-03-04 16:55:37 +0800466if (NOT DEFINED PS_VALIDATE_METADATA_FROM_FLASH)
467 set (PS_VALIDATE_METADATA_FROM_FLASH ON)
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000468endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000469
Kevin Pengc6d74502020-03-04 16:55:37 +0800470if (NOT DEFINED PS_RAM_FS)
Jamie Foxf58bd222020-06-12 18:21:25 +0100471 set (PS_RAM_FS OFF)
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000472endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000473
Kevin Pengc6d74502020-03-04 16:55:37 +0800474if (NOT DEFINED PS_TEST_NV_COUNTERS)
475 if (REGRESSION AND ENABLE_PROTECTED_STORAGE_SERVICE_TESTS)
476 set(PS_TEST_NV_COUNTERS ON)
Jamie Fox95bacd42019-03-21 18:14:15 +0000477 else()
Kevin Pengc6d74502020-03-04 16:55:37 +0800478 set(PS_TEST_NV_COUNTERS OFF)
Jamie Fox95bacd42019-03-21 18:14:15 +0000479 endif()
480endif()
481
Kevin Pengc6d74502020-03-04 16:55:37 +0800482# The PS NV counter tests depend on the PS test partition to call
483# ps_system_prepare().
484if (PS_TEST_NV_COUNTERS)
485 set(TFM_PARTITION_TEST_PS ON)
486 add_definitions(-DTFM_PARTITION_TEST_PS)
Jamie Fox0e823a02019-10-28 17:28:19 +0000487endif()
488
TudorCretufb182bc2019-07-05 17:34:12 +0100489#Default TF-M internal trusted storage flags.
490#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
491#Documentation about these flags can be found in the TF-M ITS integration guide
492option(ITS_CREATE_FLASH_LAYOUT "Create an empty ITS Flash Layout" OFF)
493
494if (NOT DEFINED ITS_VALIDATE_METADATA_FROM_FLASH)
495 set (ITS_VALIDATE_METADATA_FROM_FLASH ON)
496endif()
497
498if (NOT DEFINED ITS_RAM_FS)
Jamie Foxf58bd222020-06-12 18:21:25 +0100499 set (ITS_RAM_FS OFF)
TudorCretufb182bc2019-07-05 17:34:12 +0100500endif()
501
Raef Coles1bb168e2019-10-17 09:04:55 +0100502if (NOT DEFINED MBEDCRYPTO_DEBUG)
503 set(MBEDCRYPTO_DEBUG OFF)
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000504endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100505
Tamas Ban01f64c52019-08-26 13:46:21 +0100506#Default TF-M initial-attestation service flags.
507#Documentation about these flags can be found in docs/user_guides/services/tfm_attestation_integration_guide.rst
508if (NOT DEFINED ATTEST_INCLUDE_OPTIONAL_CLAIMS)
509 set(ATTEST_INCLUDE_OPTIONAL_CLAIMS ON)
510endif()
511
Tamas Banabea89d2020-01-15 13:29:25 +0000512if (NOT DEFINED ATTEST_INCLUDE_COSE_KEY_ID)
513 set(ATTEST_INCLUDE_COSE_KEY_ID OFF)
514endif()
515
516if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
517 if (CMAKE_BUILD_TYPE STREQUAL "debug")
518 set(ATTEST_INCLUDE_TEST_CODE ON)
519 else()
520 set(ATTEST_INCLUDE_TEST_CODE OFF)
521 endif()
Tamas Ban303dd082019-08-27 10:43:03 +0100522endif()
523
David Vinczee13a48b2020-01-08 17:42:30 +0100524if (NOT DEFINED BOOT_DATA_AVAILABLE)
David Vincze141f2152020-02-19 09:42:07 +0100525 if (BL2)
David Vinczee13a48b2020-01-08 17:42:30 +0100526 set(BOOT_DATA_AVAILABLE ON)
527 else()
528 set(BOOT_DATA_AVAILABLE OFF)
529 endif()
530endif()
531
Balint Matyi95f58eb2020-05-22 08:52:32 +0100532if (NOT DEFINED ATTEST_CLAIM_VALUE_CHECK)
533 set(ATTEST_CLAIM_VALUE_CHECK OFF)
534endif()
535
Balint Matyi5c476312020-03-31 13:15:39 +0100536##Set common mbedTLS compiler flags for BL2 bootloader
537set(MBEDCRYPTO_C_FLAGS_BL2 "${CMSE_FLAGS} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-rsa.h\\\\\\\"")