blob: d011bfe3925810833177260f2be75eacda6419f8 [file] [log] [blame]
Mate Toth-Pal2e94d132018-01-26 17:27:52 +01001#-------------------------------------------------------------------------------
Andrei Narkevitchb0be4612020-01-27 17:26:19 -08002# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Chris Brandc47d7102020-02-20 11:12:18 -08003# Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
Mate Toth-Pal2e94d132018-01-26 17:27:52 +01004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
9#This file gathers all MPS2/AN519 specific files in the application.
10
11#MPS2/AN519 has a Cortex M23 CPU.
12include("Common/CpuM23")
13
14set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
15
16#Specify the location of platform specific build dependencies.
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020017if(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-Pal7ed189e2018-03-28 17:58:59 +020019 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020020 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct")
Kevin Peng2131fdb2020-05-21 15:51:36 +080021 if (DEFINED CMSIS_DIR)
22 # not all project defines CMSIS_DIR, only the ones that use it.
23 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020024 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-Pal7ed189e2018-03-28 17:58:59 +020027 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_bl2.ld")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020028 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_ns.ld")
Kevin Peng2131fdb2020-05-21 15:51:36 +080029 if (DEFINED CMSIS_DIR)
30 # not all project defines CMSIS_DIR, only the ones that use it.
31 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/GCC/libRTX_V8MBN.a")
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020032 endif()
TTornblomc29a77b2020-02-04 16:15:08 +010033elseif(COMPILER STREQUAL "IARARM")
34 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/iar/tfm_common_s.icf")
35 set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/iar/mps2_an519_bl2.icf")
36 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/iar/mps2_an519_ns.icf")
Kevin Peng2131fdb2020-05-21 15:51:36 +080037 if (DEFINED CMSIS_DIR)
38 # not all project defines CMSIS_DIR, only the ones that use it.
39 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/IAR/RTX_V8MBN.a")
TTornblomc29a77b2020-02-04 16:15:08 +010040 endif()
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020041else()
42 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010043endif()
Mate Toth-Pal7ed189e2018-03-28 17:58:59 +020044set (FLASH_LAYOUT "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h")
45set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an519/partition/")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010046
47if (BL2)
48 set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME})
David Vincze4638b2a2019-05-24 10:14:23 +020049 if (${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "RAM_LOADING")
50 message(FATAL_ERROR "ERROR: RAM_LOADING upgrade strategy is not supported on target '${TARGET_PLATFORM}'.")
51 endif()
David Hu086ffe32019-12-06 10:36:56 +080052 #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 +010053 # instead independently loaded from secure code as a blob.
54 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048")
55 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048)
56 endif()
57 if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072")
58 add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072)
59 endif()
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010060endif()
61
62embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
63embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2" ABSOLUTE)
64embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519" ABSOLUTE)
65embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_core" ABSOLUTE)
66embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/retarget" ABSOLUTE)
67embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers" ABSOLUTE)
68embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/partition" ABSOLUTE)
Mate Toth-Pald3c77662019-02-20 16:23:00 +010069embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010070
Shawn Shan61afaa22020-09-15 16:11:42 +080071add_definitions(-DTFM_SPM_LOG_LEVEL=1)
72
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010073#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 "${PLATFORM_DIR}/target/mps2/an519/cmsis_core/system_cmsdk_mps2_an519.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 "${PLATFORM_DIR}/target/mps2/an519/retarget/platform_retarget_dev.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)
Miklos Balint6cbeba62018-04-12 17:31:34 +020089 if (NOT DEFINED SECURE_UART1)
90 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
91 elseif(SECURE_UART1)
92 add_definitions(-DSECURE_UART1)
93 endif()
Shawn Shan61afaa22020-09-15 16:11:42 +080094 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c"
95 "${PLATFORM_DIR}/common/tfm_hal_spm_logdev_peripheral.c")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +010096 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
97 set(BUILD_NATIVE_DRIVERS true)
98 set(BUILD_CMSIS_DRIVERS true)
99endif()
100
101if (NOT DEFINED BUILD_NATIVE_DRIVERS)
102 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
103elseif(BUILD_NATIVE_DRIVERS)
104 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/arm_uart_drv.c")
105
106 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpc_sie200_drv.c"
107 "${PLATFORM_DIR}/target/mps2/an519/native_drivers/ppc_sse200_drv.c"
108 )
109endif()
110
111if (NOT DEFINED BUILD_TIME)
112 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
113elseif(BUILD_TIME)
114 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk/timer_cmsdk.c")
115 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk" ABSOLUTE)
116endif()
117
118if (NOT DEFINED BUILD_STARTUP)
119 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
120elseif(BUILD_STARTUP)
121 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
122 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_s.s")
123 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_ns.s")
124 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 +0200125 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
126 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_s.S")
127 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_ns.S")
128 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_bl2.S")
129 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND
130 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
TTornblomc29a77b2020-02-04 16:15:08 +0100131 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
132 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/iar/startup_cmsdk_mps2_an519_s.s")
133 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/iar/startup_cmsdk_mps2_an519_ns.s")
134 list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/iar/startup_cmsdk_mps2_an519_bl2.s")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100135 else()
136 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
137 endif()
138endif()
139
Balint Matyi95f58eb2020-05-22 08:52:32 +0100140#Enable the checks of attestation claims against hard-coded values.
141set(ATTEST_CLAIM_VALUE_CHECK ON)
142
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100143if (NOT DEFINED BUILD_TARGET_CFG)
144 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
145elseif(BUILD_TARGET_CFG)
146 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/target_cfg.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200147 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/spm_hal.c")
David Hua6ceeb62019-12-05 17:48:05 +0800148 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200149 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpu_armv8m_drv.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800150 if (TFM_PARTITION_PLATFORM)
Miklos Balintc7b1b6c2019-04-24 12:38:36 +0200151 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/services/src/tfm_platform_system.c")
Mingyang Sun9511e5e2019-05-29 18:18:44 +0800152 endif()
Chris Brandc47d7102020-02-20 11:12:18 -0800153 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
154 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
Andrei Narkevitch5bba54c2019-09-23 14:09:13 -0700155 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
Mate Toth-Pal936c33b2018-04-10 14:02:07 +0200156 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100157endif()
158
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100159if (NOT DEFINED BUILD_PLAT_TEST)
160 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
161elseif(BUILD_PLAT_TEST)
Mate Toth-Pala9f8e9e2019-03-05 16:11:14 +0100162 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/plat_test.c")
Mate Toth-Pald3c77662019-02-20 16:23:00 +0100163endif()
164
Tamas Band4bf3472019-09-06 12:59:56 +0100165if (NOT DEFINED BUILD_BOOT_HAL)
166 message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!")
167elseif(BUILD_BOOT_HAL)
Andrei Narkevitchb0be4612020-01-27 17:26:19 -0800168 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c")
Tamas Band4bf3472019-09-06 12:59:56 +0100169 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/boot_hal.c")
170endif()
171
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100172if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
173 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
174elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800175 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800176 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
David Hu31c574dc2019-12-05 18:25:44 +0800177 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c")
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100178endif()
179
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100180if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
181 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
182elseif(BUILD_TARGET_NV_COUNTERS)
183 # NOTE: This non-volatile counters implementation is a dummy
184 # implementation. Platform vendors have to implement the
185 # API ONLY if the target has non-volatile counters.
David Hu2fa07382019-12-06 10:09:28 +0800186 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c")
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100187 set(TARGET_NV_COUNTERS_ENABLE ON)
Kevin Pengc6d74502020-03-04 16:55:37 +0800188 # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services
Marc Moreno Berengue184d2032018-08-14 12:51:43 +0100189 # rollback protection code as the target supports nv counters.
Kevin Pengc6d74502020-03-04 16:55:37 +0800190 set (PS_ROLLBACK_PROTECTION ON)
Marc Moreno Berengueb2c17ae2018-08-10 15:47:42 +0100191endif()
192
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100193if (NOT DEFINED BUILD_CMSIS_DRIVERS)
194 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
195elseif(BUILD_CMSIS_DRIVERS)
196 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_MPC.c"
197 "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_PPC.c")
198 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_USART.c")
199 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE)
200 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
201endif()
202
203if (NOT DEFINED BUILD_FLASH)
204 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
205elseif(BUILD_FLASH)
Tamas Banc3828852018-02-01 12:24:16 +0000206 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_Flash.c")
Marc Moreno Berengue792fc682018-02-20 11:53:30 +0000207 # There is no real flash memory for code on MPS2 board. Instead a code SRAM is
208 # used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash
209 # interface and behaviour on top of the SRAM memory.
Kevin Pengc6d74502020-03-04 16:55:37 +0800210 # As the PS area is going to be in RAM, it is required to set PS_CREATE_FLASH_LAYOUT
211 # to be sure the PS service knows that when it starts the PS area does not contain any
212 # valid PS flash layout and it needs to create one. The same for ITS.
213 set(PS_CREATE_FLASH_LAYOUT ON)
TudorCretuba8a3fa2019-07-22 10:05:12 +0100214 set(ITS_CREATE_FLASH_LAYOUT ON)
Tamas Banc3828852018-02-01 12:24:16 +0000215 embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE)
Mate Toth-Pal2e94d132018-01-26 17:27:52 +0100216endif()