blob: 339ebf0f71b6c1a608d35e1663fa0c0f0b7130f1 [file] [log] [blame]
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +00001#-------------------------------------------------------------------------------
Tamas Ban8f336232018-12-21 14:54:11 +00002# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8#This file gathers all MPS2/AN521 specific files in the application.
9
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010010#MPS2/AN521 has a Cortex M33 CPU.
11include("Common/CpuM33")
12
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +000013set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
14
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010015#Specify the location of platform specific build dependencies.
Mate Toth-Pal76867262018-03-09 13:15:36 +010016#FIXME use CMAKE_C_COMPILER_ID here instead?
17if(COMPILER STREQUAL "ARMCLANG")
Miklos Balint8fb91002019-05-24 14:17:44 +020018 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct")
Mate Toth-Pal76867262018-03-09 13:15:36 +010019 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an521/armclang/mps2_an521_bl2.sct")
Mate Toth-Pal76867262018-03-09 13:15:36 +010020 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an521/armclang/mps2_an521_ns.sct")
21 if (DEFINED CMSIS_5_DIR)
22 # not all project defines CMSIS_5_DIR, only the ones that use it.
23 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib")
24 endif()
25elseif(COMPILER STREQUAL "GNUARM")
Miklos Balint8fb91002019-05-24 14:17:44 +020026 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
Mate Toth-Pal76867262018-03-09 13:15:36 +010027 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an521/gcc/mps2_an521_bl2.ld")
Mate Toth-Pal76867262018-03-09 13:15:36 +010028 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an521/gcc/mps2_an521_ns.ld")
29 if (DEFINED CMSIS_5_DIR)
30 # not all project defines CMSIS_5_DIR, only the ones that use it.
31 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a")
32 endif()
33else()
34 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
35endif()
Gabor Kerteszd7d7d742018-07-04 11:50:05 +020036set (FLASH_LAYOUT "${PLATFORM_DIR}/target/mps2/an521/partition/flash_layout.h")
37set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an521/partition/")
38set (SIGN_BIN_SIZE 0x100000)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010039
40if (BL2)
41 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
David Vincze4638b2a2019-05-24 10:14:23 +020042 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
43 message(FATAL_ERROR "ERROR: RAM_LOADING upgrade strategy is not supported on target '${TARGET_PLATFORM}'.")
44 endif()
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010045endif()
46
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +000047embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
48embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2" ABSOLUTE)
49embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521" ABSOLUTE)
50embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/cmsis_core" ABSOLUTE)
51embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/retarget" ABSOLUTE)
52embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/native_drivers" ABSOLUTE)
53embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/partition" ABSOLUTE)
54
55#Gather all source files we need.
56if (NOT DEFINED BUILD_CMSIS_CORE)
57 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
58elseif(BUILD_CMSIS_CORE)
59 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/cmsis_core/system_cmsdk_mps2_an521.c")
60endif()
61
62if (NOT DEFINED BUILD_RETARGET)
63 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
64elseif(BUILD_RETARGET)
65 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/retarget/platform_retarget_dev.c")
66endif()
67
68if (NOT DEFINED BUILD_UART_STDOUT)
69 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
70elseif(BUILD_UART_STDOUT)
Miklos Balint6cbeba62018-04-12 17:31:34 +020071 if (NOT DEFINED SECURE_UART1)
72 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
73 elseif(SECURE_UART1)
74 add_definitions(-DSECURE_UART1)
75 endif()
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010076 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
Marc Moreno Berengue44af9272018-01-25 17:18:00 +000077 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +000078 set(BUILD_NATIVE_DRIVERS true)
79 set(BUILD_CMSIS_DRIVERS true)
80endif()
81
82if (NOT DEFINED BUILD_NATIVE_DRIVERS)
83 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
84elseif(BUILD_NATIVE_DRIVERS)
85 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/native_drivers/arm_uart_drv.c")
86
87 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/native_drivers/mpc_sie200_drv.c"
88 "${PLATFORM_DIR}/target/mps2/an521/native_drivers/ppc_sse200_drv.c"
89 )
90endif()
91
92if (NOT DEFINED BUILD_TIME)
93 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
94elseif(BUILD_TIME)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +010095 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/native_drivers/timer_cmsdk/timer_cmsdk.c")
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +000096 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/native_drivers/timer_cmsdk" ABSOLUTE)
97endif()
98
99if (NOT DEFINED BUILD_STARTUP)
100 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
101elseif(BUILD_STARTUP)
102 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
103 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an521/armclang/startup_cmsdk_mps2_an521_s.s")
104 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an521/armclang/startup_cmsdk_mps2_an521_ns.s")
105 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an521/armclang/startup_cmsdk_mps2_an521_bl2.s")
Mate Toth-Pal76867262018-03-09 13:15:36 +0100106 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
107 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an521/gcc/startup_cmsdk_mps2_an521_s.S")
108 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an521/gcc/startup_cmsdk_mps2_an521_ns.S")
109 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an521/gcc/startup_cmsdk_mps2_an521_bl2.S")
Mate Toth-Pal0e9d24d2018-03-27 15:20:02 +0200110 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
111 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000112 else()
113 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
114 endif()
115endif()
116
117if (NOT DEFINED BUILD_TARGET_CFG)
118 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
119elseif(BUILD_TARGET_CFG)
120 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/target_cfg.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200121 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/spm_hal.c")
Tamas Bana00f2852019-01-23 21:46:29 +0000122 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/attest_hal.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200123 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/native_drivers/mpu_armv8m_drv.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800124 if (TFM_PARTITION_PLATFORM)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +0200125 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/services/src/tfm_platform_system.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800126 endif()
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200127 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000128endif()
129
130if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
131 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
132elseif(BUILD_TARGET_HARDWARE_KEYS)
Tamas Ban8f336232018-12-21 14:54:11 +0000133 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100134 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/dummy_crypto_keys.c")
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000135endif()
136
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100137if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
138 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
139elseif(BUILD_TARGET_NV_COUNTERS)
140 # NOTE: This non-volatile counters implementation is a dummy
141 # implementation. Platform vendors have to implement the
142 # API ONLY if the target has non-volatile counters.
143 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/dummy_nv_counters.c")
144 set(TARGET_NV_COUNTERS_ENABLE ON)
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100145 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
146 # rollback protection code as the target supports nv counters.
147 set (SST_ROLLBACK_PROTECTION ON)
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100148endif()
149
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000150if (NOT DEFINED BUILD_CMSIS_DRIVERS)
151 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
152elseif(BUILD_CMSIS_DRIVERS)
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100153 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers/Driver_MPC.c"
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000154 "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers/Driver_PPC.c")
Mate Toth-Pal48fc6a02018-01-24 09:50:14 +0100155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers/Driver_USART.c")
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000156 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers" ABSOLUTE)
157 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
158endif()
159
160if (NOT DEFINED BUILD_FLASH)
161 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
162elseif(BUILD_FLASH)
Tamas Banc3828852018-02-01 12:24:16 +0000163 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers/Driver_Flash.c")
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000164 # There is no real flash memory for code on MPS2 board. Instead a code SRAM is
165 # used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash
166 # interface and behaviour on top of the SRAM memory.
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100167 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
168 # to be sure the SST service knows that when it starts the SST area does not contain any
169 # valid SST flash layout and it needs to create one.
170 set(SST_CREATE_FLASH_LAYOUT ON)
Marc Moreno Berengue02a23442018-08-15 14:28:45 +0100171 set(SST_RAM_FS OFF)
Tamas Banc3828852018-02-01 12:24:16 +0000172 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an521/cmsis_drivers" ABSOLUTE)
Marc Moreno Berenguea1f296f2018-01-25 15:21:22 +0000173endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100174
Tamas Ban3681ce02018-11-22 15:19:24 +0000175if (NOT DEFINED BUILD_BOOT_SEED)
176 message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!")
177elseif(BUILD_BOOT_SEED)
178 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/dummy_boot_seed.c")
179endif()
Tamas Ban38e17312018-11-22 15:26:35 +0000180
181if (NOT DEFINED BUILD_DEVICE_ID)
182 message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!")
183elseif(BUILD_DEVICE_ID)
184 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an521/dummy_device_id.c")
185endif()