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