blob: 8f09654fb2cacdc6ed158e65d2efabe5d551ddfa [file] [log] [blame]
Mate Toth-Pal2e94d132018-01-26 17:27:52 +01001#-------------------------------------------------------------------------------
Tamas Ban8f336232018-12-21 14:54:11 +00002# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Mate Toth-Pal2e94d132018-01-26 17:27:52 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#This file gathers all MPS2/AN519 specific files in the application.
9
10#MPS2/AN519 has a Cortex M23 CPU.
11include("Common/CpuM23")
12
13set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
14
15#Specify the location of platform specific build dependencies.
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020016if(COMPILER STREQUAL "ARMCLANG")
Miklos Balint8fb91002019-05-24 14:17:44 +020017 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020018 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020019 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct")
20 if (DEFINED CMSIS_5_DIR)
21 # not all project defines CMSIS_5_DIR, only the ones that use it.
22 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib")
23 endif()
24elseif(COMPILER STREQUAL "GNUARM")
Miklos Balint8fb91002019-05-24 14:17:44 +020025 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020026 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_bl2.ld")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020027 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_ns.ld")
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/GCC/libRTX_V8MBN.a")
31 endif()
32else()
33 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010034endif()
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020035set (FLASH_LAYOUT "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h")
36set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an519/partition/")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010037
38if (BL2)
39 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
David Vincze4638b2a2019-05-24 10:14:23 +020040 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
41 message(FATAL_ERROR "ERROR: RAM_LOADING upgrade strategy is not supported on target '${TARGET_PLATFORM}'.")
42 endif()
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010043endif()
44
45embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
46embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2" ABSOLUTE)
47embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519" ABSOLUTE)
48embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_core" ABSOLUTE)
49embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/retarget" ABSOLUTE)
50embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers" ABSOLUTE)
51embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/partition" ABSOLUTE)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010052embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010053
54#Gather all source files we need.
55if (NOT DEFINED BUILD_CMSIS_CORE)
56 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
57elseif(BUILD_CMSIS_CORE)
58 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_core/system_cmsdk_mps2_an519.c")
59endif()
60
61if (NOT DEFINED BUILD_RETARGET)
62 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
63elseif(BUILD_RETARGET)
64 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/retarget/platform_retarget_dev.c")
65endif()
66
67if (NOT DEFINED BUILD_UART_STDOUT)
68 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
69elseif(BUILD_UART_STDOUT)
Miklos Balint6cbeba62018-04-12 17:31:34 +020070 if (NOT DEFINED SECURE_UART1)
71 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
72 elseif(SECURE_UART1)
73 add_definitions(-DSECURE_UART1)
74 endif()
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010075 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
76 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
77 set(BUILD_NATIVE_DRIVERS true)
78 set(BUILD_CMSIS_DRIVERS true)
79endif()
80
81if (NOT DEFINED BUILD_NATIVE_DRIVERS)
82 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
83elseif(BUILD_NATIVE_DRIVERS)
84 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/arm_uart_drv.c")
85
86 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpc_sie200_drv.c"
87 "${PLATFORM_DIR}/target/mps2/an519/native_drivers/ppc_sse200_drv.c"
88 )
89endif()
90
91if (NOT DEFINED BUILD_TIME)
92 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
93elseif(BUILD_TIME)
94 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk/timer_cmsdk.c")
95 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk" ABSOLUTE)
96endif()
97
98if (NOT DEFINED BUILD_STARTUP)
99 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
100elseif(BUILD_STARTUP)
101 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
102 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_s.s")
103 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_ns.s")
104 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_bl2.s")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +0200105 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
106 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_s.S")
107 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_ns.S")
108 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_bl2.S")
109 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
110 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100111 else()
112 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
113 endif()
114endif()
115
116if (NOT DEFINED BUILD_TARGET_CFG)
117 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
118elseif(BUILD_TARGET_CFG)
119 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/target_cfg.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200120 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/spm_hal.c")
Tamas Bana00f2852019-01-23 21:46:29 +0000121 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/attest_hal.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200122 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpu_armv8m_drv.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800123 if (TFM_PARTITION_PLATFORM)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +0200124 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/services/src/tfm_platform_system.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800125 endif()
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200126 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100127endif()
128
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100129if (NOT DEFINED BUILD_PLAT_TEST)
130 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
131elseif(BUILD_PLAT_TEST)
Mate Toth-Pala9f8e9e2019-03-05 16:11:14 +0100132 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/plat_test.c")
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100133endif()
134
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100135if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
136 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
137elseif(BUILD_TARGET_HARDWARE_KEYS)
Tamas Ban8f336232018-12-21 14:54:11 +0000138 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100139 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_crypto_keys.c")
140endif()
141
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100142if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
143 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
144elseif(BUILD_TARGET_NV_COUNTERS)
145 # NOTE: This non-volatile counters implementation is a dummy
146 # implementation. Platform vendors have to implement the
147 # API ONLY if the target has non-volatile counters.
148 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_nv_counters.c")
149 set(TARGET_NV_COUNTERS_ENABLE ON)
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100150 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
151 # rollback protection code as the target supports nv counters.
152 set (SST_ROLLBACK_PROTECTION ON)
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100153endif()
154
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100155if (NOT DEFINED BUILD_CMSIS_DRIVERS)
156 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
157elseif(BUILD_CMSIS_DRIVERS)
158 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_MPC.c"
159 "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_PPC.c")
160 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_USART.c")
161 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE)
162 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
163endif()
164
165if (NOT DEFINED BUILD_FLASH)
166 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
167elseif(BUILD_FLASH)
Tamas Banc3828852018-02-01 12:24:16 +0000168 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_Flash.c")
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000169 # There is no real flash memory for code on MPS2 board. Instead a code SRAM is
170 # used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash
171 # interface and behaviour on top of the SRAM memory.
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100172 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
173 # to be sure the SST service knows that when it starts the SST area does not contain any
174 # valid SST flash layout and it needs to create one.
175 set(SST_CREATE_FLASH_LAYOUT ON)
Marc Moreno Berengue02a23442018-08-15 14:28:45 +0100176 set(SST_RAM_FS OFF)
Tamas Banc3828852018-02-01 12:24:16 +0000177 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100178endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100179
Tamas Ban3681ce02018-11-22 15:19:24 +0000180if (NOT DEFINED BUILD_BOOT_SEED)
181 message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!")
182elseif(BUILD_BOOT_SEED)
183 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_boot_seed.c")
184endif()
Tamas Ban38e17312018-11-22 15:26:35 +0000185
186if (NOT DEFINED BUILD_DEVICE_ID)
187 message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!")
188elseif(BUILD_DEVICE_ID)
189 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_device_id.c")
190endif()