blob: ad7c42321ad55cecb9758299e944dd425d6dc3c2 [file] [log] [blame]
Avinash Mehta788036c2018-03-15 12:38:43 +00001#-------------------------------------------------------------------------------
Andrei Narkevitchb0be4612020-01-27 17:26:19 -08002# Copyright (c) 2018-2020, 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()
TTornblom99f0be22019-12-17 16:22:38 +010032elseif(COMPILER STREQUAL "IARARM")
33 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/iar/tfm_common_s.icf")
34 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/iar/musca_bl2.icf")
35 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/iar/musca_ns.icf")
36 if (DEFINED CMSIS_5_DIR)
37 # not all project defines CMSIS_5_DIR, only the ones that use it.
38 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/IAR/RTX_V8MMN.a")
39 endif()
Mate Toth-Palf64f1eb2018-04-26 17:22:37 +020040else()
41 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
42endif()
43set (FLASH_LAYOUT "${PLATFORM_DIR}/target/musca_a/partition/flash_layout.h")
Gabor Kerteszd7d7d742018-07-04 11:50:05 +020044set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_a/partition")
Avinash Mehta788036c2018-03-15 12:38:43 +000045
Avinash Mehta788036c2018-03-15 12:38:43 +000046embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
47embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a" ABSOLUTE)
48embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Config" ABSOLUTE)
49embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Config" ABSOLUTE)
50embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Include" ABSOLUTE)
51embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE)
52embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/partition" ABSOLUTE)
Tamas Kamand3261422019-11-17 15:34:47 +010053embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/services/include" ABSOLUTE)
David Vincze26e8c8a2018-08-28 16:59:41 +020054embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Libraries" ABSOLUTE)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010055embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +000056
57#Gather all source files we need.
Tamas Kamand3261422019-11-17 15:34:47 +010058if (TFM_PARTITION_PLATFORM)
59 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/musca_a/services/src/tfm_ioctl_ns_api.c")
60endif()
61
Avinash Mehta788036c2018-03-15 12:38:43 +000062if (NOT DEFINED BUILD_CMSIS_CORE)
63 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
64elseif(BUILD_CMSIS_CORE)
Kevin Peng8f76da92019-01-28 16:18:20 +080065 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/system_core_init.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000066endif()
67
68if (NOT DEFINED BUILD_RETARGET)
69 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
70elseif(BUILD_RETARGET)
Kevin Peng8f76da92019-01-28 16:18:20 +080071 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/device_definition.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000072endif()
73
74if (NOT DEFINED BUILD_UART_STDOUT)
75 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
76elseif(BUILD_UART_STDOUT)
Miklos Balint6cbeba62018-04-12 17:31:34 +020077 if (NOT DEFINED SECURE_UART1)
78 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
79 elseif(SECURE_UART1)
80 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
81 endif()
Avinash Mehta788036c2018-03-15 12:38:43 +000082 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
83 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
84 set(BUILD_NATIVE_DRIVERS true)
85 set(BUILD_CMSIS_DRIVERS true)
86endif()
87
88if (NOT DEFINED BUILD_NATIVE_DRIVERS)
89 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
90elseif(BUILD_NATIVE_DRIVERS)
91 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/uart_pl011_drv.c")
Gabor Kertesz5c1756f2018-07-18 12:25:12 +020092 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/musca_a1_scc_drv.c")
Oliver Swede8ee18a92018-08-24 18:18:26 +010093 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c")
Tamas Kamand3261422019-11-17 15:34:47 +010094 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/gpio_cmsdk_drv.c")
Avinash Mehta788036c2018-03-15 12:38:43 +000095
96 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpc_sie200_drv.c"
97 "${PLATFORM_DIR}/target/musca_a/Native_Driver/ppc_sse200_drv.c")
David Vincze26e8c8a2018-08-28 16:59:41 +020098 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c")
99 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Libraries/mt25ql_flash_lib.c")
Avinash Mehta788036c2018-03-15 12:38:43 +0000100endif()
101
102if (NOT DEFINED BUILD_TIME)
103 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
104elseif(BUILD_TIME)
Mate Toth-Pala9f8e9e2019-03-05 16:11:14 +0100105 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/timer_cmsdk_drv.c")
Avinash Mehta788036c2018-03-15 12:38:43 +0000106 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE)
107endif()
108
109if (NOT DEFINED BUILD_STARTUP)
110 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
111elseif(BUILD_STARTUP)
112 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
113 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_s.s")
114 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_ns.s")
115 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 +0200116 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
117 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_s.S")
118 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_ns.S")
119 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_bl2.S")
120 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
121 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
TTornblom99f0be22019-12-17 16:22:38 +0100122 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
123 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/iar/startup_cmsdk_musca_s.s")
124 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/iar/startup_cmsdk_musca_ns.s")
125 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/iar/startup_cmsdk_musca_bl2.s")
Avinash Mehta788036c2018-03-15 12:38:43 +0000126 else()
127 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
128 endif()
129endif()
130
131if (NOT DEFINED BUILD_TARGET_CFG)
132 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
133elseif(BUILD_TARGET_CFG)
134 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/target_cfg.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200135 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/spm_hal.c")
David Hua6ceeb62019-12-05 17:48:05 +0800136 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200137 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpu_armv8m_drv.c")
Andrei Narkevitch5bba54c2019-09-23 14:09:13 -0700138 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800139 if (TFM_PARTITION_PLATFORM)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +0200140 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/services/src/tfm_platform_system.c")
Tamas Kamand3261422019-11-17 15:34:47 +0100141 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/services/src/tfm_ioctl_s_api.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800142 endif()
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200143 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +0000144endif()
145
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100146if (NOT DEFINED BUILD_PLAT_TEST)
147 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
148elseif(BUILD_PLAT_TEST)
Mate Toth-Pala9f8e9e2019-03-05 16:11:14 +0100149 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/plat_test.c")
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100150endif()
151
Tamas Band4bf3472019-09-06 12:59:56 +0100152if (NOT DEFINED BUILD_BOOT_HAL)
153 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
154elseif(BUILD_BOOT_HAL)
Andrei Narkevitchb0be4612020-01-27 17:26:19 -0800155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
Tamas Band4bf3472019-09-06 12:59:56 +0100156 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/boot_hal.c")
157endif()
158
Avinash Mehta788036c2018-03-15 12:38:43 +0000159if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
160 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
161elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800162 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800163 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
David Hu31c574dc2019-12-05 18:25:44 +0800164 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c")
Avinash Mehta788036c2018-03-15 12:38:43 +0000165endif()
166
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100167if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
168 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
169elseif(BUILD_TARGET_NV_COUNTERS)
170 # NOTE: This non-volatile counters implementation is a dummy
171 # implementation. Platform vendors have to implement the
172 # API ONLY if the target has non-volatile counters.
David Hu2fa07382019-12-06 10:09:28 +0800173 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c")
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100174 set(TARGET_NV_COUNTERS_ENABLE ON)
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100175 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
176 # rollback protection code as the target supports nv counters.
177 set (SST_ROLLBACK_PROTECTION ON)
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100178endif()
179
Avinash Mehta788036c2018-03-15 12:38:43 +0000180if (NOT DEFINED BUILD_CMSIS_DRIVERS)
181 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
182elseif(BUILD_CMSIS_DRIVERS)
183 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_MPC.c"
184 "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_PPC.c")
185 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_USART.c")
186 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE)
187 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
188endif()
189
190if (NOT DEFINED BUILD_FLASH)
191 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
192elseif(BUILD_FLASH)
Kevin Peng8f76da92019-01-28 16:18:20 +0800193 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_QSPI_Flash.c")
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100194 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
195 # to be sure the SST service knows that when it starts the SST area does not contain any
TudorCretuba8a3fa2019-07-22 10:05:12 +0100196 # valid SST flash layout and it needs to create one. The same for ITS.
Marc Moreno Berengue95d65722018-07-26 17:24:02 +0100197 set(SST_CREATE_FLASH_LAYOUT ON)
TudorCretuba8a3fa2019-07-22 10:05:12 +0100198 set(ITS_CREATE_FLASH_LAYOUT ON)
Avinash Mehta2e1b9bc2018-05-03 12:55:50 +0100199 embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE)
David Vincze26e8c8a2018-08-28 16:59:41 +0200200 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
Avinash Mehta788036c2018-03-15 12:38:43 +0000201endif()
Oliver Swedef9982442018-08-24 18:37:44 +0100202
203if (NOT BL2)
David Vincze4638b2a2019-05-24 10:14:23 +0200204 message(WARNING "BL2 is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
David Vincze54d05552019-08-05 12:58:47 +0200205 add_definitions(-DBL2)
David Vincze4638b2a2019-05-24 10:14:23 +0200206 set(BL2 True)
David Vincze63eda7a2019-08-09 17:42:51 +0200207 set(MCUBOOT_IMAGE_NUMBER 1)
208 mcuboot_override_upgrade_strategy("RAM_LOADING")
David Vincze54d05552019-08-05 12:58:47 +0200209 message(STATUS "MCUBOOT_UPGRADE_STRATEGY was not set, using the mandatory value for '${TARGET_PLATFORM}': ${MCUBOOT_UPGRADE_STRATEGY}.")
210 set(MCUBOOT_SIGNATURE_TYPE "RSA-3072")
211 message(STATUS "MCUBOOT_SIGNATURE_TYPE was not set, using default value: ${MCUBOOT_SIGNATURE_TYPE}.")
David Vincze4638b2a2019-05-24 10:14:23 +0200212else() #BL2 is True
213 if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
214 message(WARNING "RAM_LOADING upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.")
David Vincze63eda7a2019-08-09 17:42:51 +0200215 mcuboot_override_upgrade_strategy("RAM_LOADING")
David Vincze4638b2a2019-05-24 10:14:23 +0200216 endif()
Jamie Fox7a4170d2018-08-15 14:13:42 +0100217endif()
Tamas Ban3681ce02018-11-22 15:19:24 +0000218
David Vincze54d05552019-08-05 12:58:47 +0200219if (BL2)
220 set(BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
Tamas Ban5db57532019-07-17 10:59:02 +0100221
David Hu086ffe32019-12-06 10:36:56 +0800222 #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 +0100223 # instead independently loaded from secure code as a blob.
224 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048")
225 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048)
226 endif()
227 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
228 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072)
229 endif()
David Vincze54d05552019-08-05 12:58:47 +0200230endif()