blob: 0aaf3ff362a83341a55572e72084b39964a81b6c [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)
31set(BUILD_CMSIS_DRIVERS Off)
32set(BUILD_UART_STDOUT Off)
33set(BUILD_FLASH Off)
34if(NOT DEFINED PLATFORM_CMAKE_FILE)
35 message (FATAL_ERROR "Platform specific CMake is not defined. Please set PLATFORM_CMAKE_FILE.")
36elseif(NOT EXISTS ${PLATFORM_CMAKE_FILE})
37 message (FATAL_ERROR "Platform specific CMake \"${PLATFORM_CMAKE_FILE}\" file does not exist. Please fix value of PLATFORM_CMAKE_FILE.")
38else()
39 include(${PLATFORM_CMAKE_FILE})
40endif()
41
Oliver Swede21440442018-07-10 09:31:32 +010042if (NOT DEFINED IMAGE_VERSION)
43 set(IMAGE_VERSION 0.0.0+0)
44endif()
45
Mate Toth-Palee551bc2018-06-12 16:40:45 +020046if(${COMPILER} STREQUAL "ARMCLANG")
Mate Toth-Pal76867262018-03-09 13:15:36 +010047 #Use any ARMCLANG version found on PATH. Note: Only versions supported by the
48 #build system will work. A file cmake/Common/CompilerArmClangXY.cmake
49 #must be present with a matching version.
50 include("Common/FindArmClang")
51 include("Common/${ARMCLANG_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010052
Mate Toth-Pal76867262018-03-09 13:15:36 +010053 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -mfpu=none -mcmse)
Tamas Bandb69d522018-03-01 10:04:41 +000054 ##Shared compiler settings.
55 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010056 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 +000057 endfunction()
58
59 ##Shared linker settings.
60 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010061 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
62 endfunction()
63elseif(${COMPILER} STREQUAL "GNUARM")
64 #Use any GNUARM version found on PATH. Note: Only versions supported by the
65 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
66 #must be present with a matching version.
67 include("Common/FindGNUARM")
68 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010069
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020070 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse --specs=nano.specs)
Mate Toth-Pal76867262018-03-09 13:15:36 +010071 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +000072 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010073 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 +000074 endfunction()
75
76 ##Shared linker settings.
77 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010078 #--no-wchar-size-warning flag is added because TF-M sources are compiled
79 #with short wchars, however the standard library is compiled with normal
80 #wchar, and this generates linker time warnings. TF-M code does not use
81 #wchar, so the warning can be suppressed.
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020082 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 +010083 endfunction()
Mate Toth-Pal76867262018-03-09 13:15:36 +010084endif()
85
86#Create a string from the compile flags list, so that it can be used later
87#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +000088list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010089
90#Settings which shall be set for all projects the same way based
91# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010092set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010093set (CORE_TEST_POSITIVE OFF)
94set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010095set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010096set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020097set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010098set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Tamas Band90c81b2018-08-15 15:03:42 +010099set (SERVICES_TEST_ENABLED OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +0200100
101if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
102 set (REFERENCE_PLATFORM ON)
Avinash Mehta788036c2018-03-15 12:38:43 +0000103elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
104 add_definitions(-DTARGET_MUSCA_A)
Miklos Balintf13ec022018-04-06 17:21:22 +0200105endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100106
Miklos Balint6cbeba62018-04-12 17:31:34 +0200107# Option to demonstrate usage of secure-only peripheral
108set (SECURE_UART1 OFF)
109
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100110if (REGRESSION)
111 set(SERVICES_TEST_ENABLED ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100112endif()
113
114if (SERVICES_TEST_ENABLED)
115 set(SERVICE_TEST_S ON)
116 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200117 if (REFERENCE_PLATFORM)
118 set(CORE_TEST_POSITIVE ON)
119 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100120endif()
121
122if (CORE_TEST)
123 set(CORE_TEST_POSITIVE ON)
124 set(CORE_TEST_INTERACTIVE OFF)
125endif()
126
Ben Davis6d7256b2018-04-18 14:16:53 +0100127if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100128 add_definitions(-DCORE_TEST_INTERACTIVE)
129 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100130 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100131endif()
132
Ben Davis6d7256b2018-04-18 14:16:53 +0100133if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100134 add_definitions(-DCORE_TEST_POSITIVE)
135 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100136 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100137endif()
138
139if (SERVICE_TEST_S)
140 add_definitions(-DSERVICES_TEST_S)
Ben Davis6d7256b2018-04-18 14:16:53 +0100141 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100142 set(TEST_FRAMEWORK_S ON)
Ben Davis6d7256b2018-04-18 14:16:53 +0100143 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Tamas Band90c81b2018-08-15 15:03:42 +0100144 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100145endif()
146
147if (SERVICE_TEST_NS)
148 add_definitions(-DSERVICES_TEST_NS)
149 set(TEST_FRAMEWORK_NS ON)
150endif()
151
Ben Davis6d7256b2018-04-18 14:16:53 +0100152if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100153 add_definitions(-DTEST_FRAMEWORK_S)
154endif()
155
Ben Davis6d7256b2018-04-18 14:16:53 +0100156if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100157 add_definitions(-DTEST_FRAMEWORK_NS)
158endif()
159
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100160if (TFM_PARTITION_TEST_CORE)
161 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100162endif()
163
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100164if (TFM_PARTITION_TEST_SST)
165 add_definitions(-DTFM_PARTITION_TEST_SST)
Jamie Fox5592db02017-12-18 16:48:29 +0000166endif()
167
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100168if (BL2)
169 add_definitions(-DBL2)
Tamas Bandb69d522018-03-01 10:04:41 +0000170 if (MCUBOOT_NO_SWAP)
171 set(LINK_TO_BOTH_MEMORY_REGION ON)
172 endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100173 if (MCUBOOT_NO_SWAP AND MCUBOOT_RAM_LOADING)
174 message (FATAL_ERROR "Bootloader: MCUBOOT_RAM_LOADING and MCUBOOT_NO_SWAP are not supported together")
175 endif()
Tamas Bandb69d522018-03-01 10:04:41 +0000176else()
177 if (MCUBOOT_NO_SWAP)
178 message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
179 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100180endif()
181
Tamas Bandb69d522018-03-01 10:04:41 +0000182##Set mbedTLS compiler flags and variables for secure storage and audit log
183set(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 +0100184
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000185#Default TF-M secure storage flags.
186#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
Marc Moreno Berenguef6a64f72018-07-26 17:33:38 +0100187#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 +0000188if (NOT DEFINED ENABLE_SECURE_STORAGE)
189 set (ENABLE_SECURE_STORAGE ON)
190
191 if (NOT DEFINED SST_ENCRYPTION)
192 set (SST_ENCRYPTION ON)
193 endif()
194
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100195 if (NOT DEFINED SST_CREATE_FLASH_LAYOUT)
196 set (SST_CREATE_FLASH_LAYOUT OFF)
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000197 endif()
198
199 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
200 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
201 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100202
203 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
204 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
205 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000206endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000207
208if (NOT DEFINED MBEDTLS_DEBUG)
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +0200209 if (${COMPILER} STREQUAL "GNUARM" AND ${TARGET_PLATFORM} STREQUAL "MUSCA_A" AND BL2)
210 #The size of the MCUboot binary compiled with GCC exceeds the size limit on
211 #Musca A. By turning off the mbed TLS debug build is a good way to go below
212 #that limit, while it is still possible to debug TFM/bootloader code.
213 set (MBEDTLS_DEBUG OFF)
214 else ()
215 set (MBEDTLS_DEBUG ON)
216 endif ()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000217endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100218
Tamas Bandb69d522018-03-01 10:04:41 +0000219##Set mbedTLS compiler flags for BL2 bootloader
Mate Toth-Pal76867262018-03-09 13:15:36 +0100220set(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")