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