blob: d0fb2033fd78bceedc58b65fd73a13949b96d30c [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-Palee551bc2018-06-12 16:40:45 +020016if(NOT DEFINED COMPILER)
17 message(FATAL_ERROR "ERROR: COMPILER is not set in command line")
18elseif((NOT ${COMPILER} STREQUAL "ARMCLANG") AND (NOT ${COMPILER} STREQUAL "GNUARM"))
19 message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
20endif()
21
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010022set(BUILD_CMSIS_CORE Off)
23set(BUILD_RETARGET Off)
24set(BUILD_NATIVE_DRIVERS Off)
25set(BUILD_TIME Off)
26set(BUILD_STARTUP Off)
27set(BUILD_TARGET_CFG Off)
28set(BUILD_TARGET_HARDWARE_KEYS Off)
29set(BUILD_CMSIS_DRIVERS Off)
30set(BUILD_UART_STDOUT Off)
31set(BUILD_FLASH Off)
32if(NOT DEFINED PLATFORM_CMAKE_FILE)
33 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
34elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
35 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
36else()
37 include(${PLATFORM_CMAKE_FILE})
38endif()
39
Mate Toth-Palee551bc2018-06-12 16:40:45 +020040if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +010041 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
42 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
43 #must be present with a matching version.
44 include("Common/FindArmClang")
45 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010046
Mate Toth-Pal76867262018-03-09 13:15:36 +010047 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
Tamas Bandb69d522018-03-01 10:04:41 +000048 ##Shared compiler settings.
49 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010050 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 +000051 endfunction()
52
53 ##Shared linker settings.
54 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010055 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
56 endfunction()
57elseif(${COMPILER} STREQUAL "GNUARM")
58 #Use any GNUARM version found on PATH. Note: Only versions supported by the
59 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
60 #must be present with a matching version.
61 include("Common/FindGNUARM")
62 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010063
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020064 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse --specs=nano.specs)
Mate Toth-Pal76867262018-03-09 13:15:36 +010065 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +000066 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010067 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 +000068 endfunction()
69
70 ##Shared linker settings.
71 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010072 #--no-wchar-size-warning flag is added because TF-M sources are compiled
73 #with short wchars, however the standard library is compiled with normal
74 #wchar, and this generates linker time warnings. TF-M code does not use
75 #wchar, so the warning can be suppressed.
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020076 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)
Mate Toth-Pal76867262018-03-09 13:15:36 +010077 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +010078endif()
79
80#Create a string from the compile flags list, so that it can be used later
81#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +000082list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010083
84#Settings which shall be set for all projects the same way based
85# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010086set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010087set (CORE_TEST_POSITIVE OFF)
88set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010089set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010090set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020091set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010092set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020093
94if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
95 set (REFERENCE_PLATFORM ON)
Avinash Mehta788036c2018-03-15 12:38:43 +000096elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
97 add_definitions(-DTARGET_MUSCA_A)
Miklos Balintf13ec022018-04-06 17:21:22 +020098endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010099
Miklos Balint6cbeba62018-04-12 17:31:34 +0200100# Option to demonstrate usage of secure-only peripheral
101set (SECURE_UART1 OFF)
102
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100103if (REGRESSION)
104 set(SERVICES_TEST_ENABLED ON)
105else()
106 set(SERVICES_TEST_ENABLED OFF)
107endif()
108
109if (SERVICES_TEST_ENABLED)
110 set(SERVICE_TEST_S ON)
111 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200112 if (REFERENCE_PLATFORM)
113 set(CORE_TEST_POSITIVE ON)
114 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100115endif()
116
117if (CORE_TEST)
118 set(CORE_TEST_POSITIVE ON)
119 set(CORE_TEST_INTERACTIVE OFF)
120endif()
121
Ben Davis6d7256b2018-04-18 14:16:53 +0100122if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100123 add_definitions(-DCORE_TEST_INTERACTIVE)
124 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100125 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100126endif()
127
Ben Davis6d7256b2018-04-18 14:16:53 +0100128if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100129 add_definitions(-DCORE_TEST_POSITIVE)
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
134if (SERVICE_TEST_S)
135 add_definitions(-DSERVICES_TEST_S)
Ben Davis6d7256b2018-04-18 14:16:53 +0100136 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100137 set(TEST_FRAMEWORK_S ON)
Ben Davis6d7256b2018-04-18 14:16:53 +0100138 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100139endif()
140
141if (SERVICE_TEST_NS)
142 add_definitions(-DSERVICES_TEST_NS)
143 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100144 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100145endif()
146
Ben Davis6d7256b2018-04-18 14:16:53 +0100147if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100148 add_definitions(-DTEST_FRAMEWORK_S)
149endif()
150
Ben Davis6d7256b2018-04-18 14:16:53 +0100151if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100152 add_definitions(-DTEST_FRAMEWORK_NS)
153endif()
154
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100155if (TFM_PARTITION_TEST_CORE)
156 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100157endif()
158
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100159if (TFM_PARTITION_TEST_SST)
160 add_definitions(-DTFM_PARTITION_TEST_SST)
Jamie Fox5592db02017-12-18 16:48:29 +0000161endif()
162
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100163if (BL2)
164 add_definitions(-DBL2)
Tamas Bandb69d522018-03-01 10:04:41 +0000165 if (MCUBOOT_NO_SWAP)
166 set(LINK_TO_BOTH_MEMORY_REGION ON)
167 endif()
168else()
169 if (MCUBOOT_NO_SWAP)
170 message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
171 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100172endif()
173
Tamas Bandb69d522018-03-01 10:04:41 +0000174##Set mbedTLS compiler flags and variables for secure storage and audit log
175set(MBEDTLS_C_FLAGS_SST_LOG "-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 +0100176
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000177#Default TF-M secure storage flags.
178#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
179if (NOT DEFINED ENABLE_SECURE_STORAGE)
180 set (ENABLE_SECURE_STORAGE ON)
181
182 if (NOT DEFINED SST_ENCRYPTION)
183 set (SST_ENCRYPTION ON)
184 endif()
185
186 if (NOT DEFINED SST_RAM_FS)
187 set (SST_RAM_FS OFF)
188 endif()
189
190 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
191 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
192 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100193
194 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
195 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
196 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000197endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000198
199if (NOT DEFINED MBEDTLS_DEBUG)
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +0200200 if (${COMPILER} STREQUAL "GNUARM" AND ${TARGET_PLATFORM} STREQUAL "MUSCA_A" AND BL2)
201 #The size of the MCUboot binary compiled with GCC exceeds the size limit on
202 #Musca A. By turning off the mbed TLS debug build is a good way to go below
203 #that limit, while it is still possible to debug TFM/bootloader code.
204 set (MBEDTLS_DEBUG OFF)
205 else ()
206 set (MBEDTLS_DEBUG ON)
207 endif ()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000208endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100209
Tamas Bandb69d522018-03-01 10:04:41 +0000210##Set mbedTLS compiler flags for BL2 bootloader
Mate Toth-Pal76867262018-03-09 13:15:36 +0100211set(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")