blob: 4b9ff8bacc337e2e9d1a6a15001187b3f669c641 [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
Oliver Swede21440442018-07-10 09:31:32 +010040if (NOT DEFINED IMAGE_VERSION)
41 set(IMAGE_VERSION 0.0.0+0)
42endif()
43
Mate Toth-Palee551bc2018-06-12 16:40:45 +020044if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +010045 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
46 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
47 #must be present with a matching version.
48 include("Common/FindArmClang")
49 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010050
Mate Toth-Pal76867262018-03-09 13:15:36 +010051 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
Tamas Bandb69d522018-03-01 10:04:41 +000052 ##Shared compiler settings.
53 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010054 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 +000055 endfunction()
56
57 ##Shared linker settings.
58 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010059 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
60 endfunction()
61elseif(${COMPILER} STREQUAL "GNUARM")
62 #Use any GNUARM version found on PATH. Note: Only versions supported by the
63 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
64 #must be present with a matching version.
65 include("Common/FindGNUARM")
66 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010067
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020068 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse --specs=nano.specs)
Mate Toth-Pal76867262018-03-09 13:15:36 +010069 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +000070 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010071 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 +000072 endfunction()
73
74 ##Shared linker settings.
75 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010076 #--no-wchar-size-warning flag is added because TF-M sources are compiled
77 #with short wchars, however the standard library is compiled with normal
78 #wchar, and this generates linker time warnings. TF-M code does not use
79 #wchar, so the warning can be suppressed.
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020080 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 +010081 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +010082endif()
83
84#Create a string from the compile flags list, so that it can be used later
85#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +000086list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010087
88#Settings which shall be set for all projects the same way based
89# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010090set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010091set (CORE_TEST_POSITIVE OFF)
92set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010093set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010094set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020095set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010096set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020097
98if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
99 set (REFERENCE_PLATFORM ON)
Avinash Mehta788036c2018-03-15 12:38:43 +0000100elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
101 add_definitions(-DTARGET_MUSCA_A)
Miklos Balintf13ec022018-04-06 17:21:22 +0200102endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100103
Miklos Balint6cbeba62018-04-12 17:31:34 +0200104# Option to demonstrate usage of secure-only peripheral
105set (SECURE_UART1 OFF)
106
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100107if (REGRESSION)
108 set(SERVICES_TEST_ENABLED ON)
109else()
110 set(SERVICES_TEST_ENABLED OFF)
111endif()
112
113if (SERVICES_TEST_ENABLED)
114 set(SERVICE_TEST_S ON)
115 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200116 if (REFERENCE_PLATFORM)
117 set(CORE_TEST_POSITIVE ON)
118 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100119endif()
120
121if (CORE_TEST)
122 set(CORE_TEST_POSITIVE ON)
123 set(CORE_TEST_INTERACTIVE OFF)
124endif()
125
Ben Davis6d7256b2018-04-18 14:16:53 +0100126if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100127 add_definitions(-DCORE_TEST_INTERACTIVE)
128 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100129 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100130endif()
131
Ben Davis6d7256b2018-04-18 14:16:53 +0100132if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100133 add_definitions(-DCORE_TEST_POSITIVE)
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
138if (SERVICE_TEST_S)
139 add_definitions(-DSERVICES_TEST_S)
Ben Davis6d7256b2018-04-18 14:16:53 +0100140 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100141 set(TEST_FRAMEWORK_S ON)
Ben Davis6d7256b2018-04-18 14:16:53 +0100142 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100143endif()
144
145if (SERVICE_TEST_NS)
146 add_definitions(-DSERVICES_TEST_NS)
147 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100148 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100149endif()
150
Ben Davis6d7256b2018-04-18 14:16:53 +0100151if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100152 add_definitions(-DTEST_FRAMEWORK_S)
153endif()
154
Ben Davis6d7256b2018-04-18 14:16:53 +0100155if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100156 add_definitions(-DTEST_FRAMEWORK_NS)
157endif()
158
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100159if (TFM_PARTITION_TEST_CORE)
160 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100161endif()
162
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100163if (TFM_PARTITION_TEST_SST)
164 add_definitions(-DTFM_PARTITION_TEST_SST)
Jamie Fox5592db02017-12-18 16:48:29 +0000165endif()
166
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100167if (BL2)
168 add_definitions(-DBL2)
Tamas Bandb69d522018-03-01 10:04:41 +0000169 if (MCUBOOT_NO_SWAP)
170 set(LINK_TO_BOTH_MEMORY_REGION ON)
171 endif()
172else()
173 if (MCUBOOT_NO_SWAP)
174 message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
175 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100176endif()
177
Tamas Bandb69d522018-03-01 10:04:41 +0000178##Set mbedTLS compiler flags and variables for secure storage and audit log
179set(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 +0100180
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000181#Default TF-M secure storage flags.
182#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
183if (NOT DEFINED ENABLE_SECURE_STORAGE)
184 set (ENABLE_SECURE_STORAGE ON)
185
186 if (NOT DEFINED SST_ENCRYPTION)
187 set (SST_ENCRYPTION ON)
188 endif()
189
190 if (NOT DEFINED SST_RAM_FS)
191 set (SST_RAM_FS OFF)
192 endif()
193
194 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
195 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
196 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100197
198 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
199 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
200 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000201endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000202
203if (NOT DEFINED MBEDTLS_DEBUG)
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +0200204 if (${COMPILER} STREQUAL "GNUARM" AND ${TARGET_PLATFORM} STREQUAL "MUSCA_A" AND BL2)
205 #The size of the MCUboot binary compiled with GCC exceeds the size limit on
206 #Musca A. By turning off the mbed TLS debug build is a good way to go below
207 #that limit, while it is still possible to debug TFM/bootloader code.
208 set (MBEDTLS_DEBUG OFF)
209 else ()
210 set (MBEDTLS_DEBUG ON)
211 endif ()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000212endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100213
Tamas Bandb69d522018-03-01 10:04:41 +0000214##Set mbedTLS compiler flags for BL2 bootloader
Mate Toth-Pal76867262018-03-09 13:15:36 +0100215set(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")