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