blob: 7550ae31ae7c80c342b11a48954977dae73f43e3 [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")
20elseif((NOT ${COMPILER} STREQUAL "ARMCLANG") AND (NOT ${COMPILER} STREQUAL "GNUARM"))
21 message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
22endif()
23
Tamas Bandd10fe52019-09-18 11:52:32 +010024#Configure the default build type
25set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (i.e. Debug)")
26
Raef Colesb321c0b2019-10-15 08:49:17 +010027#Ignore case on the cmake build types
28string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
29
Edison Aicb0ecf62019-07-10 18:43:51 +080030if(CORE_IPC)
31 if (TFM_LVL EQUAL 3)
32 message(FATAL_ERROR "ERROR: Invalid isolation level!")
33 endif()
34else()
35 if(NOT TFM_LVL EQUAL 1)
36 message(FATAL_ERROR "ERROR: Invalid isolation level!")
37 endif()
38endif()
39
David Vincze4638b2a2019-05-24 10:14:23 +020040#BL2 bootloader (MCUBoot) related settings
David Vincze54d05552019-08-05 12:58:47 +020041include(${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/MCUBootConfig.cmake)
David Vincze4638b2a2019-05-24 10:14:23 +020042
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010043set(BUILD_CMSIS_CORE Off)
44set(BUILD_RETARGET Off)
45set(BUILD_NATIVE_DRIVERS Off)
46set(BUILD_TIME Off)
47set(BUILD_STARTUP Off)
48set(BUILD_TARGET_CFG Off)
49set(BUILD_TARGET_HARDWARE_KEYS Off)
Marc Moreno Berengue4cc81fc2018-08-10 14:32:01 +010050set(BUILD_TARGET_NV_COUNTERS Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010051set(BUILD_CMSIS_DRIVERS Off)
52set(BUILD_UART_STDOUT Off)
53set(BUILD_FLASH Off)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010054set(BUILD_PLAT_TEST Off)
Tamas Band4bf3472019-09-06 12:59:56 +010055set(BUILD_BOOT_HAL Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010056if(NOT DEFINED PLATFORM_CMAKE_FILE)
57 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
58elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
59 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
60else()
61 include(${PLATFORM_CMAKE_FILE})
62endif()
63
David Hu857bfa52019-05-21 13:54:50 +080064# Select the corresponding CPU type and configuration according to current
65# building status in multi-core scenario.
66# The updated configuration will be used in following compiler setting.
67if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
David Hu104388f2019-11-18 14:37:32 +080068 if (NOT CORE_IPC)
69 message(FATAL_ERROR "CORE_IPC is OFF. Multi-core topology should work in IPC model.")
70 endif()
71
David Hu857bfa52019-05-21 13:54:50 +080072 include("Common/MultiCore")
73
74 if (NOT DEFINED TFM_BUILD_IN_SPE)
75 message(FATAL_ERROR "Flag of building in SPE is not specified. Please set TFM_BUILD_IN_SPE.")
76 else()
77 select_arm_cpu_type(${TFM_BUILD_IN_SPE})
78 endif()
David Hu857bfa52019-05-21 13:54:50 +080079
David Hufeae0f92019-06-17 13:42:20 +080080 # CMSE is unnecessary in multi-core scenarios.
81 # TODO: Need further discussion about if CMSE is required when an Armv8-M
82 # core acts as secure core in multi-core scenario.
83 set (CMSE_FLAGS "")
84 set (ARM_FEATURE_CMSE 0)
85else()
86 set (CMSE_FLAGS "-mcmse")
87 set (ARM_FEATURE_CMSE 3)
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
Mate Toth-Palee551bc2018-06-12 16:40:45 +020093if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +010094 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
95 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
96 #must be present with a matching version.
97 include("Common/FindArmClang")
98 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010099
David Hufeae0f92019-06-17 13:42:20 +0800100 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none ${CMSE_FLAGS} -ffunction-sections -fdata-sections)
Tamas Bandb69d522018-03-01 10:04:41 +0000101 ##Shared compiler settings.
102 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100103 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror)
Tamas Bandb69d522018-03-01 10:04:41 +0000104 endfunction()
105
106 ##Shared linker settings.
107 function(config_setting_shared_linker_flags tgt)
Antonio de Angelis3302f452019-07-19 10:36:33 +0100108 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 +0100109 endfunction()
110elseif(${COMPILER} STREQUAL "GNUARM")
111 #Use any GNUARM version found on PATH. Note: Only versions supported by the
112 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
113 #must be present with a matching version.
114 include("Common/FindGNUARM")
115 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100116
David Hufeae0f92019-06-17 13:42:20 +0800117 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float ${CMSE_FLAGS} -ffunction-sections -fdata-sections --specs=nano.specs)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100118 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +0000119 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100120 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 Bandb69d522018-03-01 10:04:41 +0000121 endfunction()
122
123 ##Shared linker settings.
124 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100125 #--no-wchar-size-warning flag is added because TF-M sources are compiled
126 #with short wchars, however the standard library is compiled with normal
127 #wchar, and this generates linker time warnings. TF-M code does not use
128 #wchar, so the warning can be suppressed.
Antonio de Angelis3302f452019-07-19 10:36:33 +0100129 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 +0100130 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +0100131endif()
132
133#Create a string from the compile flags list, so that it can be used later
134#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +0000135list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100136
137#Settings which shall be set for all projects the same way based
138# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100139set (TFM_PARTITION_TEST_CORE OFF)
Jamie Foxadf02552019-05-16 17:44:52 +0100140set (TFM_PARTITION_TEST_CORE_IPC OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100141set (CORE_TEST_POSITIVE OFF)
142set (CORE_TEST_INTERACTIVE OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200143set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +0100144set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Jamie Fox0e823a02019-10-28 17:28:19 +0000145set (TFM_PARTITION_TEST_SST OFF)
Tamas Band90c81b2018-08-15 15:03:42 +0100146set (SERVICES_TEST_ENABLED OFF)
Marc Moreno Berenguecae2c532018-10-09 12:58:46 +0100147set (TEST_FRAMEWORK_S OFF)
148set (TEST_FRAMEWORK_NS OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800149set (TFM_PSA_API OFF)
Miklos Balint87da2512018-04-19 13:45:50 +0200150set (TFM_LEGACY_API ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200151
Jamie Foxc78c62c2019-05-23 13:42:17 +0100152option(TFM_PARTITION_AUDIT_LOG "Enable the TF-M Audit Log partition" ON)
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800153option(TFM_PARTITION_PLATFORM "Enable the TF-M Platform partition" ON)
Kevin Pengc73130f2019-10-22 17:27:18 +0800154option(TFM_PARTITION_SECURE_STORAGE "Enable the TF-M secure storage partition" ON)
155option(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE "Enable the TF-M internal trusted storage partition" ON)
156option(TFM_PARTITION_CRYPTO "Enable the TF-M crypto partition" ON)
157option(TFM_PARTITION_INITIAL_ATTESTATION "Enable the TF-M initial attestation partition" ON)
158
159if (TFM_PARTITION_INITIAL_ATTESTATION OR TFM_PARTITION_SECURE_STORAGE)
160 #PSA Initial Attestation and Protected storage rely on Cryptography API
161 set(TFM_PARTITION_CRYPTO ON)
162endif()
Jamie Foxc78c62c2019-05-23 13:42:17 +0100163
Marton Berke6fd21f12019-07-02 13:43:07 +0200164if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519" OR ${TARGET_PLATFORM} STREQUAL "AN539")
Miklos Balintf13ec022018-04-06 17:21:22 +0200165 set (REFERENCE_PLATFORM ON)
166endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100167
Miklos Balint6cbeba62018-04-12 17:31:34 +0200168# Option to demonstrate usage of secure-only peripheral
169set (SECURE_UART1 OFF)
170
Alan DeMars61844692019-10-22 08:23:29 -0700171if (PLATFORM_SVC_HANDLERS)
172 add_definitions(-DPLATFORM_SVC_HANDLERS)
173endif()
174
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100175if (REGRESSION)
176 set(SERVICES_TEST_ENABLED ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100177endif()
178
Edison Aiec109cd2018-07-17 16:04:14 +0800179if (CORE_IPC)
180 set(TFM_PSA_API ON)
David Huf2cfa122019-08-27 15:32:38 +0800181
182 # Disable IPC Test by default if the config or platform doesn't explicitly
183 # require it
184 if (NOT DEFINED IPC_TEST)
185 set(IPC_TEST OFF)
186 endif()
187else()
188 set(IPC_TEST OFF)
Edison Aiec109cd2018-07-17 16:04:14 +0800189endif()
190
Miklos Balint87da2512018-04-19 13:45:50 +0200191if (TFM_PSA_API)
192 add_definitions(-DTFM_PSA_API)
193endif()
194
David Hu104388f2019-11-18 14:37:32 +0800195if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY)
196 add_definitions(-DTFM_MULTI_CORE_TOPOLOGY)
David Huaeaf2732019-10-10 14:32:53 +0800197
198 # Skip multi-core test cases if regression test is disabled
199 if (NOT REGRESSION)
200 set(TFM_MULTI_CORE_TEST OFF)
201 endif()
David Hu104388f2019-11-18 14:37:32 +0800202endif()
203
Miklos Balint87da2512018-04-19 13:45:50 +0200204if (TFM_LEGACY_API)
205 add_definitions(-DTFM_LEGACY_API)
206endif()
207
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100208if (SERVICES_TEST_ENABLED)
209 set(SERVICE_TEST_S ON)
210 set(SERVICE_TEST_NS ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100211endif()
212
213if (CORE_TEST)
Mate Toth-Pal6569a592019-06-07 12:09:50 +0200214 set(CORE_TEST_POSITIVE ON)
215 set(CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100216endif()
217
Ben Davis6d7256b2018-04-18 14:16:53 +0100218if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100219 add_definitions(-DCORE_TEST_INTERACTIVE)
220 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100221 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100222endif()
223
Ben Davis6d7256b2018-04-18 14:16:53 +0100224if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100225 add_definitions(-DCORE_TEST_POSITIVE)
226 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100227 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100228endif()
229
David Hu33f2fd22019-08-16 15:32:39 +0800230if (TFM_PARTITION_TEST_CORE)
231 # If the platform or the topology doesn't specify whether IRQ test is
232 # supported, enable it by default.
233 if (NOT DEFINED TFM_ENABLE_IRQ_TEST)
234 set(TFM_ENABLE_IRQ_TEST ON)
235 endif()
236
237 if (TFM_ENABLE_IRQ_TEST)
238 add_definitions(-DTFM_ENABLE_IRQ_TEST)
239 endif()
240else()
241 set(TFM_ENABLE_IRQ_TEST OFF)
242endif()
243
David Huf2cfa122019-08-27 15:32:38 +0800244if (IPC_TEST)
245 add_definitions(-DENABLE_IPC_TEST)
Jamie Foxadf02552019-05-16 17:44:52 +0100246 set(TEST_FRAMEWORK_NS ON)
247 set(TFM_PARTITION_TEST_CORE_IPC ON)
Edison Aiec109cd2018-07-17 16:04:14 +0800248endif()
249
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100250if (SERVICE_TEST_S)
251 add_definitions(-DSERVICES_TEST_S)
252 set(TEST_FRAMEWORK_S ON)
253endif()
254
255if (SERVICE_TEST_NS)
256 add_definitions(-DSERVICES_TEST_NS)
257 set(TEST_FRAMEWORK_NS ON)
258endif()
259
Ben Davis6d7256b2018-04-18 14:16:53 +0100260if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100261 add_definitions(-DTEST_FRAMEWORK_S)
Jamie Fox56da0992019-05-28 14:35:06 +0100262 # The secure client partition is required to run secure tests
263 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100264endif()
265
Ben Davis6d7256b2018-04-18 14:16:53 +0100266if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100267 add_definitions(-DTEST_FRAMEWORK_NS)
268endif()
269
Jamie Foxc78c62c2019-05-23 13:42:17 +0100270if (CORE_IPC)
271 set(TFM_PARTITION_AUDIT_LOG OFF)
272endif()
273
Kevin Pengedde1de2019-10-25 17:12:45 +0800274include(${CMAKE_CURRENT_LIST_DIR}/test/TestConfig.cmake)
275
Jamie Foxc78c62c2019-05-23 13:42:17 +0100276if (TFM_PARTITION_AUDIT_LOG)
277 add_definitions(-DTFM_PARTITION_AUDIT_LOG)
278endif()
279
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800280if (TFM_PARTITION_PLATFORM)
281 add_definitions(-DTFM_PARTITION_PLATFORM)
282endif()
283
Kevin Pengc73130f2019-10-22 17:27:18 +0800284if (TFM_PARTITION_SECURE_STORAGE)
285 add_definitions(-DTFM_PARTITION_SECURE_STORAGE)
286endif()
287
288if (TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
289 add_definitions(-DTFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
290endif()
291
292if (TFM_PARTITION_CRYPTO)
293 add_definitions(-DTFM_PARTITION_CRYPTO)
294endif()
295
296if (TFM_PARTITION_INITIAL_ATTESTATION)
297 add_definitions(-DTFM_PARTITION_INITIAL_ATTESTATION)
298endif()
299
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100300if (TFM_PARTITION_TEST_CORE)
301 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100302endif()
303
Jamie Foxadf02552019-05-16 17:44:52 +0100304if (TFM_PARTITION_TEST_CORE_IPC)
305 add_definitions(-DTFM_PARTITION_TEST_CORE_IPC)
306endif()
307
Jamie Foxc78c62c2019-05-23 13:42:17 +0100308if (TFM_PARTITION_TEST_SECURE_SERVICES)
309 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
310endif()
311
Jamie Fox17c30bb2019-01-10 13:39:33 +0000312if (PSA_API_TEST)
313 add_definitions(-DPSA_API_TEST_NS)
314 set(PSA_API_TEST_NS ON)
315 if (NOT DEFINED PSA_API_TEST_CRYPTO)
316 set(PSA_API_TEST_CRYPTO OFF)
317 endif()
Jamie Fox6b6a19b2019-09-30 16:54:17 +0100318 if (NOT DEFINED PSA_API_TEST_INTERNAL_TRUSTED_STORAGE)
319 set(PSA_API_TEST_INTERNAL_TRUSTED_STORAGE OFF)
320 endif()
Jamie Fox17c30bb2019-01-10 13:39:33 +0000321 if (NOT DEFINED PSA_API_TEST_SECURE_STORAGE)
322 set(PSA_API_TEST_SECURE_STORAGE OFF)
323 endif()
324 if (NOT DEFINED PSA_API_TEST_ATTESTATION)
325 set(PSA_API_TEST_ATTESTATION OFF)
326 endif()
327endif()
328
Kevin Penge9b61a72020-01-06 17:01:44 +0800329# The config for enable secure context management in TF-M
330if (NOT DEFINED CONFIG_TFM_ENABLE_CTX_MGMT)
331 set(CONFIG_TFM_ENABLE_CTX_MGMT ON)
332endif()
333
334if (CONFIG_TFM_ENABLE_CTX_MGMT)
335 add_definitions(-DCONFIG_TFM_ENABLE_CTX_MGMT)
336endif()
337
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100338# This flag indicates if the non-secure OS is capable of identify the non-secure clients
Mingyang Sun9ac02372019-08-26 15:59:14 +0800339# which call the secure services. It is diabled in IPC model.
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100340if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
Mingyang Sun9ac02372019-08-26 15:59:14 +0800341 if (TFM_PSA_API)
342 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
343 else()
Kevin Penge9b61a72020-01-06 17:01:44 +0800344 if (CONFIG_TFM_ENABLE_CTX_MGMT)
345 set(TFM_NS_CLIENT_IDENTIFICATION ON)
346 else()
347 set(TFM_NS_CLIENT_IDENTIFICATION OFF)
348 endif()
Mingyang Sun9ac02372019-08-26 15:59:14 +0800349 endif()
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100350endif()
351
Kevin Penge9b61a72020-01-06 17:01:44 +0800352if (NOT CONFIG_TFM_ENABLE_CTX_MGMT AND TFM_NS_CLIENT_IDENTIFICATION)
353 # NS client ID is part of context management.
354 message(FATAL_ERROR "TFM_NS_CLIENT_IDENTIFICATION cannot be ON when CONFIG_TFM_ENABLE_CTX_MGMT is OFF")
355endif()
356
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100357if (BL2)
David Vincze63eda7a2019-08-09 17:42:51 +0200358 # Add MCUBOOT_IMAGE_NUMBER definition to the compiler command line.
359 add_definitions(-DMCUBOOT_IMAGE_NUMBER=${MCUBOOT_IMAGE_NUMBER})
360
David Vincze4638b2a2019-05-24 10:14:23 +0200361 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
Tamas Bandb69d522018-03-01 10:04:41 +0000362 set(LINK_TO_BOTH_MEMORY_REGION ON)
363 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100364endif()
365
Raef Coles1bb168e2019-10-17 09:04:55 +0100366##Set Mbed Crypto compiler flags and variables for crypto service
367set(MBEDCRYPTO_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-Pal65c935e2018-01-17 18:42:13 +0100368
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000369#Default TF-M secure storage flags.
370#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
Tamas Ban01f64c52019-08-26 13:46:21 +0100371#Documentation about these flags can be found in docs/user_guides/services/tfm_sst_integration_guide.rst
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000372if (NOT DEFINED SST_ENCRYPTION)
373 set (SST_ENCRYPTION ON)
374endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000375
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000376if (NOT DEFINED SST_ROLLBACK_PROTECTION)
377 set (SST_ROLLBACK_PROTECTION OFF)
378endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000379
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000380if (NOT DEFINED SST_CREATE_FLASH_LAYOUT)
381 set (SST_CREATE_FLASH_LAYOUT OFF)
382endif()
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100383
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000384if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
385 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
386endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000387
Marc Moreno Berengue8385e8e2019-01-21 11:49:50 +0000388if (NOT DEFINED SST_RAM_FS)
389 if (REGRESSION)
390 set (SST_RAM_FS ON)
391 else()
392 set (SST_RAM_FS OFF)
Marc Moreno Berengue02a23442018-08-15 14:28:45 +0100393 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000394endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000395
Jamie Fox95bacd42019-03-21 18:14:15 +0000396if (NOT DEFINED SST_TEST_NV_COUNTERS)
Kevin Pengedde1de2019-10-25 17:12:45 +0800397 if (REGRESSION AND ENABLE_SECURE_STORAGE_SERVICE_TESTS)
Jamie Fox95bacd42019-03-21 18:14:15 +0000398 set(SST_TEST_NV_COUNTERS ON)
399 else()
400 set(SST_TEST_NV_COUNTERS OFF)
401 endif()
402endif()
403
Jamie Fox0e823a02019-10-28 17:28:19 +0000404# The SST NV counter tests depend on the SST test partition to call
405# sst_system_prepare().
406if (SST_TEST_NV_COUNTERS)
407 set(TFM_PARTITION_TEST_SST ON)
408 add_definitions(-DTFM_PARTITION_TEST_SST)
409endif()
410
TudorCretufb182bc2019-07-05 17:34:12 +0100411#Default TF-M internal trusted storage flags.
412#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
413#Documentation about these flags can be found in the TF-M ITS integration guide
414option(ITS_CREATE_FLASH_LAYOUT "Create an empty ITS Flash Layout" OFF)
415
416if (NOT DEFINED ITS_VALIDATE_METADATA_FROM_FLASH)
417 set (ITS_VALIDATE_METADATA_FROM_FLASH ON)
418endif()
419
420if (NOT DEFINED ITS_RAM_FS)
421 if (REGRESSION)
422 set (ITS_RAM_FS ON)
423 else()
424 set (ITS_RAM_FS OFF)
425 endif()
426endif()
427
Raef Coles1bb168e2019-10-17 09:04:55 +0100428if (NOT DEFINED MBEDCRYPTO_DEBUG)
429 set(MBEDCRYPTO_DEBUG OFF)
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000430endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100431
Tamas Ban01f64c52019-08-26 13:46:21 +0100432#Default TF-M initial-attestation service flags.
433#Documentation about these flags can be found in docs/user_guides/services/tfm_attestation_integration_guide.rst
434if (NOT DEFINED ATTEST_INCLUDE_OPTIONAL_CLAIMS)
435 set(ATTEST_INCLUDE_OPTIONAL_CLAIMS ON)
436endif()
437
Tamas Banabea89d2020-01-15 13:29:25 +0000438if (NOT DEFINED ATTEST_INCLUDE_COSE_KEY_ID)
439 set(ATTEST_INCLUDE_COSE_KEY_ID OFF)
440endif()
441
442if (NOT DEFINED ATTEST_INCLUDE_TEST_CODE)
443 if (CMAKE_BUILD_TYPE STREQUAL "debug")
444 set(ATTEST_INCLUDE_TEST_CODE ON)
445 else()
446 set(ATTEST_INCLUDE_TEST_CODE OFF)
447 endif()
Tamas Ban303dd082019-08-27 10:43:03 +0100448endif()
449
David Vincze00dceb12019-09-17 17:34:03 +0200450set(ATTEST_BOOT_INTERFACE "CBOR_ENCODED_CLAIMS" CACHE STRING "Set the format in which to pass the claims to the initial-attestation service.")
David Vincze219a1752019-10-14 11:35:09 +0200451set_property(CACHE ATTEST_BOOT_INTERFACE PROPERTY STRINGS "INDIVIDUAL_CLAIMS;CBOR_ENCODED_CLAIMS")
452validate_cache_value(ATTEST_BOOT_INTERFACE)
453
David Vinczee13a48b2020-01-08 17:42:30 +0100454if (NOT DEFINED BOOT_DATA_AVAILABLE)
David Vinczec3e313a2020-01-06 17:31:11 +0100455 if (BL2 AND (NOT MCUBOOT_REPO STREQUAL "UPSTREAM"))
David Vinczee13a48b2020-01-08 17:42:30 +0100456 set(BOOT_DATA_AVAILABLE ON)
457 else()
458 set(BOOT_DATA_AVAILABLE OFF)
459 endif()
460endif()
461
Tamas Bandb69d522018-03-01 10:04:41 +0000462##Set mbedTLS compiler flags for BL2 bootloader
David Vinczecea8b592019-10-29 16:09:51 +0100463set(MBEDCRYPTO_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=${ARM_FEATURE_CMSE} -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-rsa.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include")
Tamas Ban7801ed42019-05-20 13:21:53 +0100464if (MCUBOOT_SIGNATURE_TYPE STREQUAL "RSA-3072")
Raef Coles1bb168e2019-10-17 09:04:55 +0100465 string(APPEND MBEDCRYPTO_C_FLAGS_BL2 " -DMCUBOOT_SIGN_RSA_LEN=3072")
Jamie Foxc78c62c2019-05-23 13:42:17 +0100466endif()