blob: 841892233b93e5c91a1fbe332839e4b90bb54ec9 [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")
Tamas Band90c81b2018-08-15 15:03:42 +010014elseif(NOT DEFINED TFM_LVL)
15 message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_LVL 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
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010024set(BUILD_CMSIS_CORE Off)
25set(BUILD_RETARGET Off)
26set(BUILD_NATIVE_DRIVERS Off)
27set(BUILD_TIME Off)
28set(BUILD_STARTUP Off)
29set(BUILD_TARGET_CFG Off)
30set(BUILD_TARGET_HARDWARE_KEYS Off)
Marc Moreno Berengue4cc81fc2018-08-10 14:32:01 +010031set(BUILD_TARGET_NV_COUNTERS Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010032set(BUILD_CMSIS_DRIVERS Off)
33set(BUILD_UART_STDOUT Off)
34set(BUILD_FLASH Off)
Tamas Ban3681ce02018-11-22 15:19:24 +000035set(BUILD_BOOT_SEED Off)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010036if(NOT DEFINED PLATFORM_CMAKE_FILE)
37 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
38elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
39 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
40else()
41 include(${PLATFORM_CMAKE_FILE})
42endif()
43
Oliver Swede21440442018-07-10 09:31:32 +010044if (NOT DEFINED IMAGE_VERSION)
Jamie Fox7a4170d2018-08-15 14:13:42 +010045 set(IMAGE_VERSION 0.0.0+0)
Oliver Swede21440442018-07-10 09:31:32 +010046endif()
47
Mate Toth-Palee551bc2018-06-12 16:40:45 +020048if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +010049 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
50 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
51 #must be present with a matching version.
52 include("Common/FindArmClang")
53 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010054
Mate Toth-Pal76867262018-03-09 13:15:36 +010055 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
Tamas Bandb69d522018-03-01 10:04:41 +000056 ##Shared compiler settings.
57 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010058 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 +000059 endfunction()
60
61 ##Shared linker settings.
62 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010063 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
64 endfunction()
65elseif(${COMPILER} STREQUAL "GNUARM")
66 #Use any GNUARM version found on PATH. Note: Only versions supported by the
67 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
68 #must be present with a matching version.
69 include("Common/FindGNUARM")
70 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010071
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020072 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse --specs=nano.specs)
Mate Toth-Pal76867262018-03-09 13:15:36 +010073 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +000074 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010075 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 +000076 endfunction()
77
78 ##Shared linker settings.
79 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010080 #--no-wchar-size-warning flag is added because TF-M sources are compiled
81 #with short wchars, however the standard library is compiled with normal
82 #wchar, and this generates linker time warnings. TF-M code does not use
83 #wchar, so the warning can be suppressed.
Karl Zhangb3b9d952018-08-07 21:47:11 +080084 embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Xlinker -check-sections -Xlinker -fatal-warnings --entry=Reset_Handler -Wl,--no-wchar-size-warning --specs=nano.specs
85 -Wl,--print-memory-usage)
Mate Toth-Pal76867262018-03-09 13:15:36 +010086 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +010087endif()
88
89#Create a string from the compile flags list, so that it can be used later
90#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +000091list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010092
93#Settings which shall be set for all projects the same way based
94# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010095set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010096set (CORE_TEST_POSITIVE OFF)
97set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010098set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010099set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200100set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +0100101set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Tamas Band90c81b2018-08-15 15:03:42 +0100102set (SERVICES_TEST_ENABLED OFF)
Marc Moreno Berenguecae2c532018-10-09 12:58:46 +0100103set (TEST_FRAMEWORK_S OFF)
104set (TEST_FRAMEWORK_NS OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200105
106if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
107 set (REFERENCE_PLATFORM ON)
108endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100109
Miklos Balint6cbeba62018-04-12 17:31:34 +0200110# Option to demonstrate usage of secure-only peripheral
111set (SECURE_UART1 OFF)
112
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100113if (REGRESSION)
114 set(SERVICES_TEST_ENABLED ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100115endif()
116
117if (SERVICES_TEST_ENABLED)
118 set(SERVICE_TEST_S ON)
119 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200120 if (REFERENCE_PLATFORM)
121 set(CORE_TEST_POSITIVE ON)
122 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100123endif()
124
125if (CORE_TEST)
126 set(CORE_TEST_POSITIVE ON)
127 set(CORE_TEST_INTERACTIVE OFF)
Tamas Ban244f08c2018-09-20 22:02:30 +0100128 set (TFM_PARTITION_TEST_SECURE_SERVICES ON)
129 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100130endif()
131
Ben Davis6d7256b2018-04-18 14:16:53 +0100132if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100133 add_definitions(-DCORE_TEST_INTERACTIVE)
134 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100135 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100136endif()
137
Ben Davis6d7256b2018-04-18 14:16:53 +0100138if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100139 add_definitions(-DCORE_TEST_POSITIVE)
140 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100141 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100142endif()
143
144if (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)
Tamas Band90c81b2018-08-15 15:03:42 +0100149 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100150endif()
151
152if (SERVICE_TEST_NS)
153 add_definitions(-DSERVICES_TEST_NS)
154 set(TEST_FRAMEWORK_NS ON)
155endif()
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
Marc Moreno Berenguec2e4db82018-09-14 16:32:24 +0100173# This flag indicates if the non-secure OS is capable of identify the non-secure clients
174# which call the secure services
175if (NOT DEFINED TFM_NS_CLIENT_IDENTIFICATION)
176 set (TFM_NS_CLIENT_IDENTIFICATION ON)
177endif()
178
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100179if (BL2)
180 add_definitions(-DBL2)
Tamas Bandb69d522018-03-01 10:04:41 +0000181 if (MCUBOOT_NO_SWAP)
182 set(LINK_TO_BOTH_MEMORY_REGION ON)
183 endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100184 if (MCUBOOT_NO_SWAP AND MCUBOOT_RAM_LOADING)
185 message (FATAL_ERROR "Bootloader: MCUBOOT_RAM_LOADING and MCUBOOT_NO_SWAP are not supported together")
186 endif()
Tamas Bandb69d522018-03-01 10:04:41 +0000187else()
188 if (MCUBOOT_NO_SWAP)
189 message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
190 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100191endif()
192
Antonio de Angelis8908f472018-08-31 15:44:25 +0100193##Set mbedTLS compiler flags and variables for secure storage, audit log and crypto
194set(MBEDTLS_C_FLAGS_SERVICES "-D__ARM_FEATURE_CMSE=3 -D__thumb2__ ${COMMON_COMPILE_FLAGS_STR} -DMBEDTLS_CONFIG_FILE=\\\\\\\"tfm_mbedtls_config.h\\\\\\\" -I${CMAKE_CURRENT_LIST_DIR}/platform/ext/common")
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100195
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000196#Default TF-M secure storage flags.
197#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
Marc Moreno Berenguef6a64f72018-07-26 17:33:38 +0100198#Documentation about these flags can be found in docs/user_guides/services/tfm_sst_integration_guide.md
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000199if (NOT DEFINED ENABLE_SECURE_STORAGE)
200 set (ENABLE_SECURE_STORAGE ON)
201
202 if (NOT DEFINED SST_ENCRYPTION)
203 set (SST_ENCRYPTION ON)
204 endif()
205
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100206 if (NOT DEFINED SST_ROLLBACK_PROTECTION)
207 set (SST_ROLLBACK_PROTECTION OFF)
208 endif()
209
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100210 if (NOT DEFINED SST_CREATE_FLASH_LAYOUT)
211 set (SST_CREATE_FLASH_LAYOUT OFF)
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000212 endif()
213
214 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
215 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
216 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100217
218 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
219 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
220 endif()
Marc Moreno Berengue02a23442018-08-15 14:28:45 +0100221
222 if (NOT DEFINED SST_RAM_FS)
223 if (REGRESSION)
224 set (SST_RAM_FS ON)
225 else()
226 set (SST_RAM_FS OFF)
227 endif()
228 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000229endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000230
231if (NOT DEFINED MBEDTLS_DEBUG)
Jamie Fox7a4170d2018-08-15 14:13:42 +0100232 if (${COMPILER} STREQUAL "GNUARM" AND ${TARGET_PLATFORM} MATCHES "MUSCA_A|MUSCA_B1" AND BL2)
233 #The size of the MCUboot binary compiled with GCC exceeds the size limit on
234 #Musca-A/B1. By turning off the mbed TLS debug build is a good way to go below
235 #that limit, while it is still possible to debug TFM/bootloader code.
236 set (MBEDTLS_DEBUG OFF)
237 else ()
238 set (MBEDTLS_DEBUG ON)
239 endif ()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000240endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100241
Tamas Bandb69d522018-03-01 10:04:41 +0000242##Set mbedTLS compiler flags for BL2 bootloader
Mate Toth-Pal76867262018-03-09 13:15:36 +0100243set(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")