blob: f59142333e03fbbc00c0ad691846dc117bcf1120 [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")
Kevin Peng2131fdb2020-05-21 15:51:36 +080050 if (DEFINED CMSIS_DIR)
51 # not all project defines CMSIS_DIR, only the ones that use it.
52 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/ARM/RTX_CM4F.lib")
Chris Brandb42fed52019-12-02 16:10:17 -080053 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")
Kevin Peng2131fdb2020-05-21 15:51:36 +080057 if (DEFINED CMSIS_DIR)
58 # not all project defines CMSIS_DIR, only the ones that use it.
Chris Brandb42fed52019-12-02 16:10:17 -080059 # [libRTX_CM3.a should be used for CM4 without FPU]
Kevin Peng2131fdb2020-05-21 15:51:36 +080060 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/GCC/libRTX_CM3.a")
Chris Brandb42fed52019-12-02 16:10:17 -080061 endif()
TTornblome3ef1fd2020-01-23 16:50:19 +010062elseif(COMPILER STREQUAL "IARARM")
63 set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/iar/tfm_common_s.icf")
64 set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/psoc6_ns.icf")
Kevin Peng2131fdb2020-05-21 15:51:36 +080065 if (DEFINED CMSIS_DIR)
66 # not all project defines CMSIS_DIR, only the ones that use it.
TTornblome3ef1fd2020-01-23 16:50:19 +010067 # [RTX_CM3.a should be used for CM4 without FPU]
Kevin Peng2131fdb2020-05-21 15:51:36 +080068 set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/IAR/RTX_CM3.a")
TTornblome3ef1fd2020-01-23 16:50:19 +010069 endif()
Chris Brandb42fed52019-12-02 16:10:17 -080070else()
71 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
72endif()
73set (FLASH_LAYOUT "${PLATFORM_DIR}/target/cypress/psoc64/partition/flash_layout.h")
74set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/cypress/psoc64/partition")
75
76embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE)
77embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64" ABSOLUTE)
78embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Config" ABSOLUTE)
79embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Config" ABSOLUTE)
80embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Include" ABSOLUTE)
81embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/include" ABSOLUTE)
82embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source" ABSOLUTE)
83embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/mailbox" ABSOLUTE)
84embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/partition" ABSOLUTE)
85embedded_include_directories(PATH "${TFM_ROOT_DIR}/interface/include" ABSOLUTE)
86embedded_include_directories(PATH "${TFM_ROOT_DIR}/platform/include" ABSOLUTE)
87embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/arch/include" ABSOLUTE)
88embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/ipc/include" ABSOLUTE)
89
90#Gather all source files we need.
91list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c")
92list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c")
93list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/mailbox_ipc_intr.c")
94list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_spe_mailbox.c")
95
96install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/ns_ipc_config.h
97 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.h
David Hu52c65f02020-01-10 11:19:19 +080098 DESTINATION export/tfm/include)
Chris Brandb42fed52019-12-02 16:10:17 -080099
100install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c
101 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c
102 DESTINATION export/tfm/src)
103
104if (NOT DEFINED BUILD_CMSIS_CORE)
105 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
106elseif(BUILD_CMSIS_CORE)
107 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm0plus.c")
108 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm4.c")
109endif()
110
111if (NOT DEFINED BUILD_RETARGET)
112 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
113elseif(BUILD_RETARGET)
114 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/device_definition.c")
115endif()
116
117if (NOT DEFINED BUILD_UART_STDOUT)
118 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
119elseif(BUILD_UART_STDOUT)
120 if (NOT DEFINED SECURE_UART1)
121 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
122 elseif(SECURE_UART1)
123 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
124 endif()
125 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c")
126 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
127 set(BUILD_NATIVE_DRIVERS true)
128 set(BUILD_CMSIS_DRIVERS true)
129endif()
130
131if (NOT DEFINED BUILD_NATIVE_DRIVERS)
132 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
133elseif(BUILD_NATIVE_DRIVERS)
134 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_device.c")
135 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_flash.c")
136 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_gpio.c")
137 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_prot.c")
138 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_drv.c")
139 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_pipe.c")
140 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_sema.c")
141 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_common.c")
142 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_uart.c")
143 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysclk.c")
144 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysint.c")
145 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syslib.c")
146 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syspm.c")
147 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_systick.c")
Alamy Liud33851f2019-11-21 13:17:58 -0800148 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_tcpwm_counter.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800149 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_trigmux.c")
150 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_wdt.c")
151 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg.c")
152 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
153 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
154 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_peripherals.c")
155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_pins.c")
156 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_routing.c")
157 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_system.c")
158 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
159 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/cy_syslib_mdk.s")
160 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
161 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/cy_syslib_gcc.S")
TTornblome3ef1fd2020-01-23 16:50:19 +0100162 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
163 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/cy_syslib_iar.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800164 else()
165 message(FATAL_ERROR "No cy_syslib is available for compiler '${CMAKE_C_COMPILER_ID}'.")
166 endif()
167endif()
168
169if (NOT DEFINED BUILD_TIME)
170 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
171elseif(BUILD_TIME)
172endif()
173
174if (NOT DEFINED BUILD_STARTUP)
175 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
176elseif(BUILD_STARTUP)
177 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
178 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_s.s")
179 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_ns.s")
180 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
181 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_s.S")
182 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_ns.S")
183 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" APPEND
184 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
TTornblome3ef1fd2020-01-23 16:50:19 +0100185 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
186 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/startup_psoc64_s.s")
187 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/startup_psoc64_ns.s")
Chris Brandb42fed52019-12-02 16:10:17 -0800188 else()
189 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
190 endif()
191endif()
192
Balint Matyi95f58eb2020-05-22 08:52:32 +0100193#Enable the checks of attestation claims against hard-coded values.
194set(ATTEST_CLAIM_VALUE_CHECK ON)
195
Chris Brandb42fed52019-12-02 16:10:17 -0800196if (NOT DEFINED BUILD_TARGET_CFG)
197 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
198elseif(BUILD_TARGET_CFG)
199 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/target_cfg.c")
200 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/spm_hal.c")
201 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/attest_hal.c")
202 if (TFM_PARTITION_PLATFORM)
203 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/services/src/tfm_platform_system.c")
204 endif()
205 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
206 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
207endif()
208
Alamy Liucc419f92019-11-21 15:55:33 -0800209if (NOT DEFINED BUILD_PLAT_TEST)
210 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
211elseif(BUILD_PLAT_TEST)
212 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/plat_test.c")
213endif()
214
Chris Brandb42fed52019-12-02 16:10:17 -0800215if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
216 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
217elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800218 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800219 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800220 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_crypto_keys.c")
221endif()
222
223if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
224 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
225elseif(BUILD_TARGET_NV_COUNTERS)
Chris Brandcfc51142020-03-23 14:02:28 -0700226 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/nv_counters.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800227 set(TARGET_NV_COUNTERS_ENABLE ON)
Kevin Pengc6d74502020-03-04 16:55:37 +0800228 # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services
Chris Brandb42fed52019-12-02 16:10:17 -0800229 # rollback protection code as the target supports nv counters.
Kevin Pengc6d74502020-03-04 16:55:37 +0800230 set (PS_ROLLBACK_PROTECTION ON)
Chris Brandb42fed52019-12-02 16:10:17 -0800231endif()
232
233if (NOT DEFINED BUILD_CMSIS_DRIVERS)
234 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
235elseif(BUILD_CMSIS_DRIVERS)
236 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_smpu.c")
237 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_ppu.c")
Andrei Narkevitch995bb452020-01-15 13:58:47 -0800238 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/driver_dap.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800239 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_USART.c")
240 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
241 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
242endif()
243
244if (NOT DEFINED BUILD_FLASH)
245 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
246elseif(BUILD_FLASH)
247 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_Flash.c")
Kevin Pengc6d74502020-03-04 16:55:37 +0800248 # As the PS area is going to be in RAM, it is required to set PS_CREATE_FLASH_LAYOUT
249 # to be sure the PS service knows that when it starts the PS area does not contain any
250 # valid PS flash layout and it needs to create one.
251 set(PS_CREATE_FLASH_LAYOUT ON)
Chris Brandb42fed52019-12-02 16:10:17 -0800252 set(ITS_CREATE_FLASH_LAYOUT ON)
253 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
254 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
255endif()
256
257list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_boot_seed.c")
258list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_device_id.c")