blob: b99933238e62260875348645ff0239e894480716 [file] [log] [blame]
Chris Brandb42fed52019-12-02 16:10:17 -08001#-------------------------------------------------------------------------------
David Hu52c65f02020-01-10 11:19:19 +08002# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Alamy Liud33851f2019-11-21 13:17:58 -08003# Copyright (c) 2019-2020, Cypress Semiconductor Corporation. All rights reserved.
Chris Brandb42fed52019-12-02 16:10:17 -08004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7#-------------------------------------------------------------------------------
8
9#This file gathers all Cypress PSoC 6 specific files in the application.
10
11include("Common/MultiCore")
12
13# Select configuration of multi-core topology
14enable_multi_core_topology_config()
15
16set(TFM_NS_CLIENT_IDENTIFICATION OFF)
17
18add_definitions(-DCYB0644ABZI_S2D44=1)
19
20add_definitions(-DTFM_CORE_DEBUG)
21
22# psoc64 platform doesn't yet use TF-M BL2
23set(BL2 False)
24remove_definitions(-DBL2)
25
26# Skip Core Test temporarily
27set(CORE_TEST OFF)
28# Skip peripheral access test
29set(TFM_ENABLE_PERIPH_ACCESS_TEST OFF)
30
31# Set Cortex-M0plus as secure core
32set_secure_cpu_type("CpuM0p")
33# Set Cortex-M4 as non-secure core
34set_ns_cpu_type("CpuM4")
35
36# Set PSoC62 specific secure definitions
37add_platform_secure_definitions(CY_PSOC6_CM0P=1)
38
39set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR})
40
41#Specify the location of platform specific build dependencies.
42if(COMPILER STREQUAL "ARMCLANG")
43 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct")
44 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/psoc6_ns.sct")
45 if (DEFINED CMSIS_5_DIR)
46 # not all project defines CMSIS_5_DIR, only the ones that use it.
47 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_CM4F.lib")
48 endif()
49elseif(COMPILER STREQUAL "GNUARM")
50 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld")
51 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/psoc6_ns.ld")
52 if (DEFINED CMSIS_5_DIR)
53 # not all project defines CMSIS_5_DIR, only the ones that use it.
54 # [libRTX_CM3.a should be used for CM4 without FPU]
55 set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_CM3.a")
56 endif()
57else()
58 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
59endif()
60set (FLASH_LAYOUT "${PLATFORM_DIR}/target/cypress/psoc64/partition/flash_layout.h")
61set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/cypress/psoc64/partition")
62
63embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
64embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64" ABSOLUTE)
65embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Config" ABSOLUTE)
66embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Config" ABSOLUTE)
67embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Include" ABSOLUTE)
68embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/include" ABSOLUTE)
69embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source" ABSOLUTE)
70embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/mailbox" ABSOLUTE)
71embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/partition" ABSOLUTE)
72embedded_include_directories(PATH "${TFM_ROOT_DIR}/interface/include" ABSOLUTE)
73embedded_include_directories(PATH "${TFM_ROOT_DIR}/platform/include" ABSOLUTE)
74embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/arch/include" ABSOLUTE)
75embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/ipc/include" ABSOLUTE)
76
77#Gather all source files we need.
78list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c")
79list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c")
80list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/mailbox_ipc_intr.c")
81list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_spe_mailbox.c")
82
83install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/ns_ipc_config.h
84 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.h
David Hu52c65f02020-01-10 11:19:19 +080085 DESTINATION export/tfm/include)
Chris Brandb42fed52019-12-02 16:10:17 -080086
87install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c
88 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c
89 DESTINATION export/tfm/src)
90
91if (NOT DEFINED BUILD_CMSIS_CORE)
92 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
93elseif(BUILD_CMSIS_CORE)
94 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm0plus.c")
95 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm4.c")
96endif()
97
98if (NOT DEFINED BUILD_RETARGET)
99 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
100elseif(BUILD_RETARGET)
101 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/device_definition.c")
102endif()
103
104if (NOT DEFINED BUILD_UART_STDOUT)
105 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
106elseif(BUILD_UART_STDOUT)
107 if (NOT DEFINED SECURE_UART1)
108 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
109 elseif(SECURE_UART1)
110 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
111 endif()
112 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
113 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
114 set(BUILD_NATIVE_DRIVERS true)
115 set(BUILD_CMSIS_DRIVERS true)
116endif()
117
118if (NOT DEFINED BUILD_NATIVE_DRIVERS)
119 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
120elseif(BUILD_NATIVE_DRIVERS)
121 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_device.c")
122 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_flash.c")
123 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_gpio.c")
124 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_prot.c")
125 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_drv.c")
126 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_pipe.c")
127 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_sema.c")
128 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_common.c")
129 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_uart.c")
130 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysclk.c")
131 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysint.c")
132 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syslib.c")
133 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syspm.c")
134 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_systick.c")
Alamy Liud33851f2019-11-21 13:17:58 -0800135 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_tcpwm_counter.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800136 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_trigmux.c")
137 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_wdt.c")
138 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg.c")
139 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
140 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
141 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_peripherals.c")
142 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_pins.c")
143 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_routing.c")
144 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_system.c")
145 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
146 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/cy_syslib_mdk.s")
147 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
148 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/cy_syslib_gcc.S")
149 else()
150 message(FATAL_ERROR "No cy_syslib is available for compiler '${CMAKE_C_COMPILER_ID}'.")
151 endif()
152endif()
153
154if (NOT DEFINED BUILD_TIME)
155 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
156elseif(BUILD_TIME)
157endif()
158
159if (NOT DEFINED BUILD_STARTUP)
160 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
161elseif(BUILD_STARTUP)
162 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
163 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_s.s")
164 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_ns.s")
165 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
166 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_s.S")
167 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_ns.S")
168 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" APPEND
169 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
170 else()
171 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
172 endif()
173endif()
174
175if (NOT DEFINED BUILD_TARGET_CFG)
176 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
177elseif(BUILD_TARGET_CFG)
178 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/target_cfg.c")
179 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/spm_hal.c")
180 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/attest_hal.c")
181 if (TFM_PARTITION_PLATFORM)
182 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/services/src/tfm_platform_system.c")
183 endif()
184 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
185 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
186endif()
187
Alamy Liucc419f92019-11-21 15:55:33 -0800188if (NOT DEFINED BUILD_PLAT_TEST)
189 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
190elseif(BUILD_PLAT_TEST)
191 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/plat_test.c")
192endif()
193
Chris Brandb42fed52019-12-02 16:10:17 -0800194if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
195 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
196elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800197 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800198 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800199 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_crypto_keys.c")
200endif()
201
202if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
203 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
204elseif(BUILD_TARGET_NV_COUNTERS)
205 # NOTE: This non-volatile counters implementation is a dummy
206 # implementation. Platform vendors have to implement the
207 # API ONLY if the target has non-volatile counters.
208 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_nv_counters.c")
209 set(TARGET_NV_COUNTERS_ENABLE ON)
210 # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services
211 # rollback protection code as the target supports nv counters.
212 set (SST_ROLLBACK_PROTECTION ON)
213endif()
214
215if (NOT DEFINED BUILD_CMSIS_DRIVERS)
216 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
217elseif(BUILD_CMSIS_DRIVERS)
218 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_smpu.c")
219 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_ppu.c")
220 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_USART.c")
221 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
222 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
223endif()
224
225if (NOT DEFINED BUILD_FLASH)
226 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
227elseif(BUILD_FLASH)
228 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_Flash.c")
229 # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT
230 # to be sure the SST service knows that when it starts the SST area does not contain any
231 # valid SST flash layout and it needs to create one.
232 set(SST_CREATE_FLASH_LAYOUT ON)
233 set(ITS_CREATE_FLASH_LAYOUT ON)
234 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
235 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
236endif()
237
238list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_boot_seed.c")
239list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_device_id.c")