blob: 935e8885a13b142a53c86767969a47ef4d009d3d [file] [log] [blame]
Bence Kaposzta9076e822019-10-08 09:44:17 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8# This file gathers all Musca-S1 specific files in the application.
9
10# Musca-S1 has a Cortex-M33 CPU.
11include("Common/CpuM33")
12
13set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
14
15# Specify the location of platform specific build dependencies.
16if (COMPILER STREQUAL "ARMCLANG")
17 set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct")
18 set(BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/musca_bl2.sct")
19 set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/musca_ns.sct")
20 if (DEFINED CMSIS_5_DIR)
21 # Not all projects define CMSIS_5_DIR, only the ones that use it.
22 set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib")
23 endif()
24elseif (COMPILER STREQUAL "GNUARM")
25 set(S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
26 set(BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/musca_bl2.ld")
27 set(NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/musca_ns.ld")
28 if (DEFINED CMSIS_5_DIR)
29 # Not all projects define CMSIS_5_DIR, only the ones that use it.
30 set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a")
31 endif()
32else()
33 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
34endif()
35set(FLASH_LAYOUT "${PLATFORM_DIR}/target/musca_s1/partition/flash_layout.h")
36set(PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_s1/partition")
37
38if (BL2)
39 set(BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
40 if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
41 message(WARNING "NO_SWAP upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
42 mcuboot_override_upgrade_strategy("NO_SWAP")
43 endif()
44
45 #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/tfm_rotpk.c
46 # instead independently loaded from secure code as a blob.
47 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048")
48 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048)
49 endif()
50 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
51 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072)
52 endif()
53endif()
54
55embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
56embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1" ABSOLUTE)
57embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Config" ABSOLUTE)
58embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Device/Config" ABSOLUTE)
59embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Device/Include" ABSOLUTE)
60embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Native_Driver" ABSOLUTE)
61embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/partition" ABSOLUTE)
62embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/services/include" ABSOLUTE)
63embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
64
65# Gather all source files we need.
66if (NOT DEFINED BUILD_CMSIS_CORE)
67 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
68elseif (BUILD_CMSIS_CORE)
69 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Device/Source/system_core_init.c")
70endif()
71
72if (NOT DEFINED BUILD_RETARGET)
73 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
74elseif (BUILD_RETARGET)
75 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Device/Source/device_definition.c")
76endif()
77
78if (NOT DEFINED BUILD_UART_STDOUT)
79 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
80elseif (BUILD_UART_STDOUT)
81 if (NOT DEFINED SECURE_UART1)
82 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
83 elseif (SECURE_UART1)
84 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
85 endif()
86 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
87 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
88 set(BUILD_NATIVE_DRIVERS True)
89 set(BUILD_CMSIS_DRIVERS True)
90endif()
91
92if (NOT DEFINED BUILD_NATIVE_DRIVERS)
93 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
94elseif (BUILD_NATIVE_DRIVERS)
95 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/uart_pl011_drv.c")
96 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/Native_Driver/mpc_sie200_drv.c")
97 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/ppc_sse200_drv.c")
98endif()
99
100if (NOT DEFINED BUILD_TIME)
101 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
102elseif (BUILD_TIME)
103 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/Native_Driver/timer_cmsdk_drv.c")
104 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/Native_Driver" ABSOLUTE)
105endif()
106
107if (NOT DEFINED BUILD_STARTUP)
108 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
109elseif (BUILD_STARTUP)
110 if (CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
111 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_s.s")
112 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_ns.s")
113 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_s1/Device/Source/armclang/startup_cmsdk_musca_bl2.s")
114 elseif (CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
115 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_s.S")
116 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_ns.S")
117 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_s1/Device/Source/gcc/startup_cmsdk_musca_bl2.S")
118 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
119 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
120 else()
121 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
122 endif()
123endif()
124
125if (NOT DEFINED BUILD_TARGET_CFG)
126 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
127elseif (BUILD_TARGET_CFG)
128 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/target_cfg.c")
129 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/spm_hal.c")
David Hua6ceeb62019-12-05 17:48:05 +0800130 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
Bence Kaposzta9076e822019-10-08 09:44:17 +0200131 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/Native_Driver/mpu_armv8m_drv.c")
132 if (TFM_PARTITION_PLATFORM)
133 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/services/src/tfm_platform_system.c")
134 endif()
Andrei Narkevitch5bba54c2019-09-23 14:09:13 -0700135 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
Bence Kaposzta9076e822019-10-08 09:44:17 +0200136 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
137endif()
138
139if (NOT DEFINED BUILD_PLAT_TEST)
140 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
141elseif(BUILD_PLAT_TEST)
142 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/plat_test.c")
143endif()
144
145if (NOT DEFINED BUILD_BOOT_HAL)
146 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
147elseif(BUILD_BOOT_HAL)
148 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/boot_hal.c")
149endif()
150
151if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
152 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
153elseif(BUILD_TARGET_HARDWARE_KEYS)
154 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c")
155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_rotpk.c")
156 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_crypto_keys.c")
157endif()
158
159if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
160 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
161elseif (BUILD_TARGET_NV_COUNTERS)
162 # NOTE: This non-volatile counters implementation is a dummy
163 # implementation. Platform vendors have to implement the
164 # API ONLY if the target has non-volatile counters.
165 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_nv_counters.c")
166 set(TARGET_NV_COUNTERS_ENABLE ON)
167 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
168 # rollback protection code as the target supports nv counters.
169 set(SST_ROLLBACK_PROTECTION ON)
170endif()
171
172if (NOT DEFINED BUILD_CMSIS_DRIVERS)
173 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
174elseif (BUILD_CMSIS_DRIVERS)
175 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_MPC.c"
176 "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_PPC.c")
177 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_USART.c")
178 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver" ABSOLUTE)
179 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
180endif()
181
182if (NOT DEFINED BUILD_FLASH)
183 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
184elseif (BUILD_FLASH)
185 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver/Driver_Flash_MRAM.c")
186 # As the SST area is going to be in RAM, it is required to set
187 # SST_CREATE_FLASH_LAYOUT to be sure the SST service knows that when it
188 # starts the SST area does not contain any valid SST flash layout and it
189 # needs to create one. The same for ITS.
190 set(SST_CREATE_FLASH_LAYOUT ON)
191 set(ITS_CREATE_FLASH_LAYOUT ON)
192 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_s1/CMSIS_Driver" ABSOLUTE)
193 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
194endif()
195
196if (NOT DEFINED BUILD_BOOT_SEED)
197 message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!")
198elseif (BUILD_BOOT_SEED)
199 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_boot_seed.c")
200endif()
201
202if (NOT DEFINED BUILD_DEVICE_ID)
203 message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!")
204elseif (BUILD_DEVICE_ID)
205 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_s1/dummy_device_id.c")
206endif()