blob: 78a00685e1c96d2e664767a0110c2e011fe458d8 [file] [log] [blame]
Mate Toth-Pal65c935e2018-01-17 18:42:13 +01001#-------------------------------------------------------------------------------
2# Copyright (c) 2018, Arm Limited. All rights reserved.
3#
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")
12elseif(NOT DEFINED BL2)
13 message(FATAL_ERROR "ERROR: Incomplete Configuration: BL2 not defined, Include this file from a Config*.cmake")
14endif()
15
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010016set(BUILD_CMSIS_CORE Off)
17set(BUILD_RETARGET Off)
18set(BUILD_NATIVE_DRIVERS Off)
19set(BUILD_TIME Off)
20set(BUILD_STARTUP Off)
21set(BUILD_TARGET_CFG Off)
22set(BUILD_TARGET_HARDWARE_KEYS Off)
23set(BUILD_CMSIS_DRIVERS Off)
24set(BUILD_UART_STDOUT Off)
25set(BUILD_FLASH Off)
26if(NOT DEFINED PLATFORM_CMAKE_FILE)
27 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
28elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
29 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
30else()
31 include(${PLATFORM_CMAKE_FILE})
32endif()
33
Mate Toth-Pal76867262018-03-09 13:15:36 +010034if(NOT DEFINED COMPILER)
35 message(FATAL_ERROR "ERROR: COMPILER is not set in command line")
36elseif(${COMPILER} STREQUAL "ARMCLANG")
37 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
38 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
39 #must be present with a matching version.
40 include("Common/FindArmClang")
41 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010042
Mate Toth-Pal76867262018-03-09 13:15:36 +010043 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
44 ##Shared compiler and linker settings.
45 function(config_setting_shared_flags tgt)
46 embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS -xc -std=c99 ${COMMON_COMPILE_FLAGS} -Wall -Werror)
47 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
48 endfunction()
49elseif(${COMPILER} STREQUAL "GNUARM")
50 #Use any GNUARM version found on PATH. Note: Only versions supported by the
51 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
52 #must be present with a matching version.
53 include("Common/FindGNUARM")
54 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010055
Mate Toth-Pal76867262018-03-09 13:15:36 +010056 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse)
57 ##Shared compiler and linker settings.
58 function(config_setting_shared_flags tgt)
59 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)
60 #--no-wchar-size-warning flag is added because TF-M sources are compiled
61 #with short wchars, however the standard library is compiled with normal
62 #wchar, and this generates linker time warnings. TF-M code does not use
63 #wchar, so the warning can be suppressed.
64 embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Xlinker -check-sections -Xlinker -fatal-warnings --entry=Reset_Handler -Wl,--no-wchar-size-warning)
65 endfunction()
66else()
67 message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
68endif()
69
70#Create a string from the compile flags list, so that it can be used later
71#in this file to set mbedtls and BL2 flags
72string(REPLACE ";" " " COMMON_COMPILE_FLAGS_STR "${COMMON_COMPILE_FLAGS}")
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010073
74#Settings which shall be set for all projects the same way based
75# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010076set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010077set (CORE_TEST_POSITIVE OFF)
78set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010079set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010080set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020081set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010082set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Edison Ai56c42022018-07-17 16:04:14 +080083set (TFM_PSA_API OFF)
Miklos Balint2c41b9c2018-04-19 13:45:50 +020084set (TFM_LEGACY_API ON)
Edison Ai56c42022018-07-17 16:04:14 +080085set (CORE_TEST_IPC OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020086
87if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
88 set (REFERENCE_PLATFORM ON)
Avinash Mehta788036c2018-03-15 12:38:43 +000089elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
90 add_definitions(-DTARGET_MUSCA_A)
Miklos Balintf13ec022018-04-06 17:21:22 +020091endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010092
Miklos Balint6cbeba62018-04-12 17:31:34 +020093# Option to demonstrate usage of secure-only peripheral
94set (SECURE_UART1 OFF)
95
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010096if (REGRESSION)
97 set(SERVICES_TEST_ENABLED ON)
98else()
99 set(SERVICES_TEST_ENABLED OFF)
100endif()
101
Edison Ai56c42022018-07-17 16:04:14 +0800102if (CORE_IPC)
103 set(TFM_PSA_API ON)
104 set(CORE_TEST_IPC ON)
105endif()
106
Miklos Balint2c41b9c2018-04-19 13:45:50 +0200107if (TFM_PSA_API)
108 add_definitions(-DTFM_PSA_API)
109endif()
110
111if (TFM_LEGACY_API)
112 add_definitions(-DTFM_LEGACY_API)
113endif()
114
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100115if (SERVICES_TEST_ENABLED)
116 set(SERVICE_TEST_S ON)
117 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200118 if (REFERENCE_PLATFORM)
119 set(CORE_TEST_POSITIVE ON)
120 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100121endif()
122
123if (CORE_TEST)
124 set(CORE_TEST_POSITIVE ON)
125 set(CORE_TEST_INTERACTIVE OFF)
126endif()
127
Ben Davis6d7256b2018-04-18 14:16:53 +0100128if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100129 add_definitions(-DCORE_TEST_INTERACTIVE)
130 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100131 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100132endif()
133
Ben Davis6d7256b2018-04-18 14:16:53 +0100134if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100135 add_definitions(-DCORE_TEST_POSITIVE)
136 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100137 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100138endif()
139
Edison Ai56c42022018-07-17 16:04:14 +0800140if (CORE_TEST_IPC)
141 add_definitions(-DCORE_TEST_IPC)
142endif()
143
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100144if (SERVICE_TEST_S)
145 add_definitions(-DSERVICES_TEST_S)
Ben Davis6d7256b2018-04-18 14:16:53 +0100146 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100147 set(TEST_FRAMEWORK_S ON)
Ben Davis6d7256b2018-04-18 14:16:53 +0100148 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100149endif()
150
151if (SERVICE_TEST_NS)
152 add_definitions(-DSERVICES_TEST_NS)
153 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100154 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100155endif()
156
Ben Davis6d7256b2018-04-18 14:16:53 +0100157if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100158 add_definitions(-DTEST_FRAMEWORK_S)
159endif()
160
Ben Davis6d7256b2018-04-18 14:16:53 +0100161if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100162 add_definitions(-DTEST_FRAMEWORK_NS)
163endif()
164
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100165if (TFM_PARTITION_TEST_CORE)
166 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100167endif()
168
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100169if (TFM_PARTITION_TEST_SST)
170 add_definitions(-DTFM_PARTITION_TEST_SST)
Jamie Fox5592db02017-12-18 16:48:29 +0000171endif()
172
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100173if (BL2)
174 add_definitions(-DBL2)
175endif()
176
177##Secure side
178config_setting_shared_flags(tfm_s)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100179
180##Non secure side
181config_setting_shared_flags(tfm_ns)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100182
183##TF-M storage
184config_setting_shared_flags(tfm_storage)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100185set(MBEDTLS_C_FLAGS "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"mbedtls_config.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common")
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100186
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000187#Default TF-M secure storage flags.
188#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
189if (NOT DEFINED ENABLE_SECURE_STORAGE)
190 set (ENABLE_SECURE_STORAGE ON)
191
192 if (NOT DEFINED SST_ENCRYPTION)
193 set (SST_ENCRYPTION ON)
194 endif()
195
196 if (NOT DEFINED SST_RAM_FS)
197 set (SST_RAM_FS OFF)
198 endif()
199
200 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
201 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
202 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100203
204 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
205 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
206 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000207endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000208
209if (NOT DEFINED MBEDTLS_DEBUG)
210 set (MBEDTLS_DEBUG ON)
211endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100212
Antonio de Angeliscc657b32018-02-05 15:56:47 +0000213##TF-M audit logging
214config_setting_shared_flags(tfm_audit)
215
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100216##Tests
217config_setting_shared_flags(tfm_secure_tests)
218config_setting_shared_flags(tfm_non_secure_tests)
219
220##BL2
221config_setting_shared_flags(mcuboot)
Mate Toth-Pal76867262018-03-09 13:15:36 +0100222set(MBEDTLS_C_FLAGS_BL2 "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"config-boot.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/bl2/ext/mcuboot/include")