blob: 26a55a759599c7407326741e047a96615ac2565d [file] [log] [blame]
Kevin Peng0a142112018-09-21 10:42:22 +08001#-------------------------------------------------------------------------------
Andrei Narkevitchb0be4612020-01-27 17:26:19 -08002# Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Kevin Peng0a142112018-09-21 10:42:22 +08003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#This file gathers all MPS3/AN524 specific files in the application.
9
10#MPS3/AN524 has a Cortex-M33 CPU.
11include("Common/CpuM33")
12
13#Remap option for MPS3, default is BRAM
14set(REMAP_QSPI True)
15if (REMAP_QSPI)
16 add_definitions(-DREMAP_QSPI)
17endif()
18
19set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
20
21set(AN524_DIR ${PLATFORM_DIR}/target/mps3/an524)
22
23#Specify the location of platform specific build dependencies.
24if(COMPILER STREQUAL "ARMCLANG")
25 set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_bl2.sct")
26 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct")
27 set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_ns.sct")
28 if (DEFINED CMSIS_5_DIR)
29 # not all project defines CMSIS_5_DIR, only the ones that use it.
30 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib")
31 endif()
32elseif(COMPILER STREQUAL "GNUARM")
33 set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_bl2.ld")
34 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
35 set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_ns.ld")
36 if (DEFINED CMSIS_5_DIR)
37 # Not all projects define CMSIS_5_DIR, only the ones that use it.
38 set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a")
39 endif()
40else()
41 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
42endif()
43set (FLASH_LAYOUT "${AN524_DIR}/partition/flash_layout.h")
44set (PLATFORM_LINK_INCLUDES "${AN524_DIR}/partition/")
Kevin Peng0a142112018-09-21 10:42:22 +080045
46if (BL2)
47 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
48 if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP")
49 message(WARNING "NO_SWAP upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
David Vincze63eda7a2019-08-09 17:42:51 +020050 mcuboot_override_upgrade_strategy("NO_SWAP")
Kevin Peng0a142112018-09-21 10:42:22 +080051 endif()
Tamas Ban5db57532019-07-17 10:59:02 +010052
David Hu086ffe32019-12-06 10:36:56 +080053 #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/template/tfm_rotpk.c
Tamas Ban5db57532019-07-17 10:59:02 +010054 # instead independently loaded from secure code as a blob.
55 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048")
56 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048)
57 endif()
58 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
59 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072)
60 endif()
Kevin Peng0a142112018-09-21 10:42:22 +080061endif()
62
63embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
64embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps3/common" ABSOLUTE)
65embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
66embedded_include_directories(PATH "${AN524_DIR}" ABSOLUTE)
67embedded_include_directories(PATH "${AN524_DIR}/partition" ABSOLUTE)
68embedded_include_directories(PATH "${AN524_DIR}/device/include" ABSOLUTE)
69embedded_include_directories(PATH "${AN524_DIR}/device/config" ABSOLUTE)
70embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers/config" ABSOLUTE)
71embedded_include_directories(PATH "${AN524_DIR}/native_drivers" ABSOLUTE)
72
73#Gather all source files we need.
74if (NOT DEFINED BUILD_CMSIS_CORE)
75 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
76elseif(BUILD_CMSIS_CORE)
77 list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/system_core_init.c")
78endif()
79
80if (NOT DEFINED BUILD_RETARGET)
81 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
82elseif(BUILD_RETARGET)
83 list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/device_definition.c")
84endif()
85
86if (NOT DEFINED BUILD_UART_STDOUT)
87 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
88elseif(BUILD_UART_STDOUT)
89 if (NOT DEFINED SECURE_UART1)
90 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
91 elseif(SECURE_UART1)
92 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
93 endif()
94 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
95 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
96 set(BUILD_NATIVE_DRIVERS true)
97 set(BUILD_CMSIS_DRIVERS true)
98endif()
99
100if (NOT DEFINED BUILD_NATIVE_DRIVERS)
101 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
102elseif(BUILD_NATIVE_DRIVERS)
103 list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/uart_cmsdk_drv.c")
104
105 list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpc_sie200_drv.c"
106 "${AN524_DIR}/native_drivers/ppc_sse200_drv.c")
107endif()
108
109if (NOT DEFINED BUILD_TIME)
110 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
111elseif(BUILD_TIME)
112 list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/timer_cmsdk_drv.c")
113endif()
114
115if (NOT DEFINED BUILD_STARTUP)
116 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
117elseif(BUILD_STARTUP)
118 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
119 list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_s.s")
120 list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_ns.s")
121 list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_bl2.s")
122 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
123 list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_s.S")
124 list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_ns.S")
125 list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_bl2.S")
126 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
127 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
128 else()
129 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
130 endif()
131endif()
132
133if (NOT DEFINED BUILD_TARGET_CFG)
134 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
135elseif(BUILD_TARGET_CFG)
136 list(APPEND ALL_SRC_C "${AN524_DIR}/target_cfg.c")
137 list(APPEND ALL_SRC_C_S "${AN524_DIR}/spm_hal.c")
David Hua6ceeb62019-12-05 17:48:05 +0800138 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
Kevin Peng0a142112018-09-21 10:42:22 +0800139 list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpu_armv8m_drv.c")
140 list(APPEND ALL_SRC_C_S "${AN524_DIR}/services/src/tfm_platform_system.c")
Andrei Narkevitch5bba54c2019-09-23 14:09:13 -0700141 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
Kevin Peng0a142112018-09-21 10:42:22 +0800142 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
143endif()
144
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100145if (NOT DEFINED BUILD_PLAT_TEST)
146 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
147elseif(BUILD_PLAT_TEST)
Mate Toth-Pala9f8e9e2019-03-05 16:11:14 +0100148 list(APPEND ALL_SRC_C "${AN524_DIR}/plat_test.c")
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100149endif()
150
Tamas Band4bf3472019-09-06 12:59:56 +0100151if (NOT DEFINED BUILD_BOOT_HAL)
152 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
153elseif(BUILD_BOOT_HAL)
Andrei Narkevitchb0be4612020-01-27 17:26:19 -0800154 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
Tamas Band4bf3472019-09-06 12:59:56 +0100155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps3/an524/boot_hal.c")
156endif()
157
Kevin Peng0a142112018-09-21 10:42:22 +0800158if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
159 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
160elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800161 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800162 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
David Hu31c574dc2019-12-05 18:25:44 +0800163 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c")
Kevin Peng0a142112018-09-21 10:42:22 +0800164endif()
165
166if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
167 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
168elseif (BUILD_TARGET_NV_COUNTERS)
169 # NOTE: This non-volatile counters implementation is a dummy
170 # implementation. Platform vendors have to implement the
171 # API ONLY if the target has non-volatile counters.
David Hu2fa07382019-12-06 10:09:28 +0800172 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c")
Kevin Peng0a142112018-09-21 10:42:22 +0800173 set(TARGET_NV_COUNTERS_ENABLE ON)
174 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
175 # rollback protection code as the target supports nv counters.
176 set(SST_ROLLBACK_PROTECTION ON)
177endif()
178
179if (NOT DEFINED BUILD_CMSIS_DRIVERS)
180 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
181elseif(BUILD_CMSIS_DRIVERS)
182 list(APPEND ALL_SRC_C_S "${AN524_DIR}/cmsis_drivers/Driver_MPC.c"
183 "${AN524_DIR}/cmsis_drivers/Driver_PPC.c")
184 list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_USART.c")
185 embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE)
186 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
187endif()
188
189if (NOT DEFINED BUILD_FLASH)
190 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
191elseif(BUILD_FLASH)
192 list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_Flash.c")
193 # For AN524 currently BRAM is used for SST The Driver_Flash driver just emulates a flash
194 # interface and behaviour on top of the BRAM memory.
195 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
196 # to be sure the SST service knows that when it starts the SST area does not contain any
TudorCretuba8a3fa2019-07-22 10:05:12 +0100197 # valid SST flash layout and it needs to create one. The same for ITS.
Kevin Peng0a142112018-09-21 10:42:22 +0800198 set(SST_CREATE_FLASH_LAYOUT ON)
199 set(SST_RAM_FS OFF)
TudorCretuba8a3fa2019-07-22 10:05:12 +0100200 set(ITS_CREATE_FLASH_LAYOUT ON)
201 set(ITS_RAM_FS OFF)
Kevin Peng0a142112018-09-21 10:42:22 +0800202 embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE)
203 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
204endif()
205
206if (MCUBOOT_RAM_LOADING)
207 message (FATAL_ERROR "MCUBOOT_RAM_LOADING is not supported on " ${TARGET_PLATFORM})
208endif()