blob: b05561a0e005cfea84361cd06f175573ea7d3bee [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)
Tamas Bandb69d522018-03-01 10:04:41 +000044 ##Shared compiler settings.
45 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010046 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 +000047 endfunction()
48
49 ##Shared linker settings.
50 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010051 embedded_set_target_link_flags(TARGET ${tgt} FLAGS --strict --map --symbols --xref --entry=Reset_Handler --info=summarysizes,sizes,totals,unused,veneers)
52 endfunction()
53elseif(${COMPILER} STREQUAL "GNUARM")
54 #Use any GNUARM version found on PATH. Note: Only versions supported by the
55 #build system will work. A file cmake/Common/CompilerGNUARMXY.cmake
56 #must be present with a matching version.
57 include("Common/FindGNUARM")
58 include("Common/${GNUARM_MODULE}")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010059
Mate Toth-Pal76867262018-03-09 13:15:36 +010060 set (COMMON_COMPILE_FLAGS -fshort-enums -fshort-wchar -funsigned-char -msoft-float -mcmse)
61 ##Shared compiler and linker settings.
Tamas Bandb69d522018-03-01 10:04:41 +000062 function(config_setting_shared_compiler_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010063 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 +000064 endfunction()
65
66 ##Shared linker settings.
67 function(config_setting_shared_linker_flags tgt)
Mate Toth-Pal76867262018-03-09 13:15:36 +010068 #--no-wchar-size-warning flag is added because TF-M sources are compiled
69 #with short wchars, however the standard library is compiled with normal
70 #wchar, and this generates linker time warnings. TF-M code does not use
71 #wchar, so the warning can be suppressed.
72 embedded_set_target_link_flags(TARGET ${tgt} FLAGS -Xlinker -check-sections -Xlinker -fatal-warnings --entry=Reset_Handler -Wl,--no-wchar-size-warning)
73 endfunction()
74else()
75 message(FATAL_ERROR "ERROR: Compiler \"${COMPILER}\" is not supported.")
76endif()
77
78#Create a string from the compile flags list, so that it can be used later
79#in this file to set mbedtls and BL2 flags
Tamas Bandb69d522018-03-01 10:04:41 +000080list_to_string(COMMON_COMPILE_FLAGS_STR ${COMMON_COMPILE_FLAGS})
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010081
82#Settings which shall be set for all projects the same way based
83# on the variables above.
Mate Toth-Pal349714a2018-02-23 15:30:24 +010084set (TFM_PARTITION_TEST_CORE OFF)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010085set (CORE_TEST_POSITIVE OFF)
86set (CORE_TEST_INTERACTIVE OFF)
Mate Toth-Pal349714a2018-02-23 15:30:24 +010087set (TFM_PARTITION_TEST_SST OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010088set (TEST_FRAMEWORK_S OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020089set (REFERENCE_PLATFORM OFF)
Ben Davis6d7256b2018-04-18 14:16:53 +010090set (TFM_PARTITION_TEST_SECURE_SERVICES OFF)
Miklos Balintf13ec022018-04-06 17:21:22 +020091
92if(${TARGET_PLATFORM} STREQUAL "AN521" OR ${TARGET_PLATFORM} STREQUAL "AN519")
93 set (REFERENCE_PLATFORM ON)
Avinash Mehta788036c2018-03-15 12:38:43 +000094elseif(${TARGET_PLATFORM} STREQUAL "MUSCA_A")
95 add_definitions(-DTARGET_MUSCA_A)
Miklos Balintf13ec022018-04-06 17:21:22 +020096endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +010097
Miklos Balint6cbeba62018-04-12 17:31:34 +020098# Option to demonstrate usage of secure-only peripheral
99set (SECURE_UART1 OFF)
100
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100101if (REGRESSION)
102 set(SERVICES_TEST_ENABLED ON)
103else()
104 set(SERVICES_TEST_ENABLED OFF)
105endif()
106
107if (SERVICES_TEST_ENABLED)
108 set(SERVICE_TEST_S ON)
109 set(SERVICE_TEST_NS ON)
Miklos Balintf13ec022018-04-06 17:21:22 +0200110 if (REFERENCE_PLATFORM)
111 set(CORE_TEST_POSITIVE ON)
112 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100113endif()
114
115if (CORE_TEST)
116 set(CORE_TEST_POSITIVE ON)
117 set(CORE_TEST_INTERACTIVE OFF)
118endif()
119
Ben Davis6d7256b2018-04-18 14:16:53 +0100120if (CORE_TEST_INTERACTIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100121 add_definitions(-DCORE_TEST_INTERACTIVE)
122 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100123 set(TFM_PARTITION_TEST_CORE ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100124endif()
125
Ben Davis6d7256b2018-04-18 14:16:53 +0100126if (CORE_TEST_POSITIVE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100127 add_definitions(-DCORE_TEST_POSITIVE)
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
132if (SERVICE_TEST_S)
133 add_definitions(-DSERVICES_TEST_S)
Ben Davis6d7256b2018-04-18 14:16:53 +0100134 add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100135 set(TEST_FRAMEWORK_S ON)
Ben Davis6d7256b2018-04-18 14:16:53 +0100136 set(TFM_PARTITION_TEST_SECURE_SERVICES ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100137endif()
138
139if (SERVICE_TEST_NS)
140 add_definitions(-DSERVICES_TEST_NS)
141 set(TEST_FRAMEWORK_NS ON)
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100142 set(TFM_PARTITION_TEST_SST ON)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100143endif()
144
Ben Davis6d7256b2018-04-18 14:16:53 +0100145if (TEST_FRAMEWORK_S)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100146 add_definitions(-DTEST_FRAMEWORK_S)
147endif()
148
Ben Davis6d7256b2018-04-18 14:16:53 +0100149if (TEST_FRAMEWORK_NS)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100150 add_definitions(-DTEST_FRAMEWORK_NS)
151endif()
152
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100153if (TFM_PARTITION_TEST_CORE)
154 add_definitions(-DTFM_PARTITION_TEST_CORE)
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100155endif()
156
Mate Toth-Pal349714a2018-02-23 15:30:24 +0100157if (TFM_PARTITION_TEST_SST)
158 add_definitions(-DTFM_PARTITION_TEST_SST)
Jamie Fox5592db02017-12-18 16:48:29 +0000159endif()
160
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100161if (BL2)
162 add_definitions(-DBL2)
Tamas Bandb69d522018-03-01 10:04:41 +0000163 if (MCUBOOT_NO_SWAP)
164 set(LINK_TO_BOTH_MEMORY_REGION ON)
165 endif()
166else()
167 if (MCUBOOT_NO_SWAP)
168 message (FATAL_ERROR "Bootloader build is turned off, not possible to specify bootloader behavior")
169 endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100170endif()
171
Tamas Bandb69d522018-03-01 10:04:41 +0000172##Set mbedTLS compiler flags and variables for secure storage and audit log
173set(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 +0100174
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000175#Default TF-M secure storage flags.
176#These flags values can be overwritten by setting them in platform/ext/<TARGET_NAME>.cmake
177if (NOT DEFINED ENABLE_SECURE_STORAGE)
178 set (ENABLE_SECURE_STORAGE ON)
179
180 if (NOT DEFINED SST_ENCRYPTION)
181 set (SST_ENCRYPTION ON)
182 endif()
183
184 if (NOT DEFINED SST_RAM_FS)
185 set (SST_RAM_FS OFF)
186 endif()
187
188 if (NOT DEFINED SST_VALIDATE_METADATA_FROM_FLASH)
189 set (SST_VALIDATE_METADATA_FROM_FLASH ON)
190 endif()
Ben Davis38902c82018-05-01 15:36:31 +0100191
192 if (NOT DEFINED SST_ENABLE_PARTIAL_ASSET_RW)
193 set (SST_ENABLE_PARTIAL_ASSET_RW ON)
194 endif()
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000195endif()
Marc Moreno Berengue6ffb22f2018-02-20 13:46:30 +0000196
197if (NOT DEFINED MBEDTLS_DEBUG)
198 set (MBEDTLS_DEBUG ON)
199endif()
Mate Toth-Pal65c935e2018-01-17 18:42:13 +0100200
Tamas Bandb69d522018-03-01 10:04:41 +0000201##Set mbedTLS compiler flags for BL2 bootloader
Mate Toth-Pal76867262018-03-09 13:15:36 +0100202set(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")