blob: d8db31aa9c79122f2912f079c498d0309dd66c8c [file] [log] [blame]
Avinash Mehta788036c2018-03-15 12:38:43 +00001#-------------------------------------------------------------------------------
Tamas Ban8f336232018-12-21 14:54:11 +00002# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
Avinash Mehta788036c2018-03-15 12:38:43 +00003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Jamie Fox7a4170d2018-08-15 14:13:42 +01008#This file gathers all Musca-A specific files in the application.
Avinash Mehta788036c2018-03-15 12:38:43 +00009
Jamie Fox284690d2018-11-01 16:52:50 +000010#Musca-A has a Cortex M33 CPU.
Avinash Mehta788036c2018-03-15 12:38:43 +000011include("Common/CpuM33")
12
13set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
14
15#Specify the location of platform specific build dependencies.
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +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-Palf64f1eb2018-04-26 17:22:37 +020018 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_bl2.sct")
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020019 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_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_V8MMN.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-Palf64f1eb2018-04-26 17:22:37 +020026 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/musca_bl2.ld")
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020027 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/musca_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_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_a/partition/flash_layout.h")
Gabor Kerteszd7d7d742018-07-04 11:50:05 +020036set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_a/partition")
Oliver Swede7cbf7ef2018-08-31 11:49:12 +010037set (SIGN_BIN_SIZE 0x100000)
Avinash Mehta788036c2018-03-15 12:38:43 +000038
39if (BL2)
40 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
41endif()
42
43embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
44embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a" ABSOLUTE)
45embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Config" ABSOLUTE)
46embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Config" ABSOLUTE)
47embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Include" ABSOLUTE)
48embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE)
49embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/partition" ABSOLUTE)
David Vincze26e8c8a2018-08-28 16:59:41 +020050embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Libraries" ABSOLUTE)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010051embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +000052
53#Gather all source files we need.
54if (NOT DEFINED BUILD_CMSIS_CORE)
55 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
56elseif(BUILD_CMSIS_CORE)
Kevin Peng8f76da92019-01-28 16:18:20 +080057 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/system_core_init.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000058endif()
59
60if (NOT DEFINED BUILD_RETARGET)
61 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
62elseif(BUILD_RETARGET)
Kevin Peng8f76da92019-01-28 16:18:20 +080063 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/device_definition.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000064endif()
65
66if (NOT DEFINED BUILD_UART_STDOUT)
67 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
68elseif(BUILD_UART_STDOUT)
Miklos Balint6cbeba62018-04-12 17:31:34 +020069 if (NOT DEFINED SECURE_UART1)
70 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
71 elseif(SECURE_UART1)
72 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
73 endif()
Avinash Mehta788036c2018-03-15 12:38:43 +000074 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
75 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
76 set(BUILD_NATIVE_DRIVERS true)
77 set(BUILD_CMSIS_DRIVERS true)
78endif()
79
80if (NOT DEFINED BUILD_NATIVE_DRIVERS)
81 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
82elseif(BUILD_NATIVE_DRIVERS)
83 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/uart_pl011_drv.c")
Gabor Kertesz5c1756f2018-07-18 12:25:12 +020084 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/musca_a1_scc_drv.c")
Oliver Swede8ee18a92018-08-24 18:18:26 +010085 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000086
87 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpc_sie200_drv.c"
88 "${PLATFORM_DIR}/target/musca_a/Native_Driver/ppc_sse200_drv.c")
David Vincze26e8c8a2018-08-28 16:59:41 +020089 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c")
90 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Libraries/mt25ql_flash_lib.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000091endif()
92
93if (NOT DEFINED BUILD_TIME)
94 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
95elseif(BUILD_TIME)
96 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/timer_cmsdk.c")
97 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE)
98endif()
99
100if (NOT DEFINED BUILD_STARTUP)
101 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
102elseif(BUILD_STARTUP)
103 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
104 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_s.s")
105 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_ns.s")
106 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_bl2.s")
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +0200107 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
108 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_s.S")
109 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_ns.S")
110 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_bl2.S")
111 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
112 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
Avinash Mehta788036c2018-03-15 12:38:43 +0000113 else()
114 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
115 endif()
116endif()
117
118if (NOT DEFINED BUILD_TARGET_CFG)
119 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
120elseif(BUILD_TARGET_CFG)
121 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/target_cfg.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200122 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/spm_hal.c")
Tamas Bana00f2852019-01-23 21:46:29 +0000123 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/attest_hal.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200124 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpu_armv8m_drv.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800125 if (TFM_PARTITION_PLATFORM)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +0200126 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/services/src/tfm_platform_system.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800127 endif()
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200128 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +0000129endif()
130
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100131if (NOT DEFINED BUILD_PLAT_TEST)
132 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
133elseif(BUILD_PLAT_TEST)
134 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/plat_test.c")
135endif()
136
Avinash Mehta788036c2018-03-15 12:38:43 +0000137if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
138 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
139elseif(BUILD_TARGET_HARDWARE_KEYS)
Tamas Ban8f336232018-12-21 14:54:11 +0000140 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c")
Avinash Mehta788036c2018-03-15 12:38:43 +0000141 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/dummy_crypto_keys.c")
142endif()
143
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100144if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
145 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
146elseif(BUILD_TARGET_NV_COUNTERS)
147 # NOTE: This non-volatile counters implementation is a dummy
148 # implementation. Platform vendors have to implement the
149 # API ONLY if the target has non-volatile counters.
150 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/dummy_nv_counters.c")
151 set(TARGET_NV_COUNTERS_ENABLE ON)
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100152 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
153 # rollback protection code as the target supports nv counters.
154 set (SST_ROLLBACK_PROTECTION ON)
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100155endif()
156
Avinash Mehta788036c2018-03-15 12:38:43 +0000157if (NOT DEFINED BUILD_CMSIS_DRIVERS)
158 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
159elseif(BUILD_CMSIS_DRIVERS)
160 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_MPC.c"
161 "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_PPC.c")
162 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_USART.c")
163 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE)
164 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
165endif()
166
167if (NOT DEFINED BUILD_FLASH)
168 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
169elseif(BUILD_FLASH)
Kevin Peng8f76da92019-01-28 16:18:20 +0800170 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_QSPI_Flash.c")
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100171 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
172 # to be sure the SST service knows that when it starts the SST area does not contain any
173 # valid SST flash layout and it needs to create one.
174 set(SST_CREATE_FLASH_LAYOUT ON)
Avinash Mehta2e1b9bc2018-05-03 12:55:50 +0100175 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE)
David Vincze26e8c8a2018-08-28 16:59:41 +0200176 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +0000177endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100178
179if (NOT BL2)
David Vincze4638b2a2019-05-24 10:14:23 +0200180 message(WARNING "BL2 is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
181 set(BL2 True)
182 set(MCUBOOT_UPGRADE_STRATEGY "RAM_LOADING")
183else() #BL2 is True
184 if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
185 message(WARNING "RAM_LOADING upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
186 set(MCUBOOT_UPGRADE_STRATEGY "RAM_LOADING")
187 endif()
Jamie Fox7a4170d2018-08-15 14:13:42 +0100188endif()
Tamas Ban3681ce02018-11-22 15:19:24 +0000189
190if (NOT DEFINED BUILD_BOOT_SEED)
191 message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!")
192elseif(BUILD_BOOT_SEED)
193 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/dummy_boot_seed.c")
194endif()
Tamas Ban38e17312018-11-22 15:26:35 +0000195
196if (NOT DEFINED BUILD_DEVICE_ID)
197 message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!")
198elseif(BUILD_DEVICE_ID)
199 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/dummy_device_id.c")
200endif()