blob: 244a3c2711659510437c332156f519b60ad7b4bb [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)
Summer Qin8f231c42020-06-29 17:59:35 +080087embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/spm/arch" ABSOLUTE)
88embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/spm/model_ipc/include" ABSOLUTE)
Chris Brandb42fed52019-12-02 16:10:17 -080089
Shawn Shan61afaa22020-09-15 16:11:42 +080090add_definitions(-DTFM_SPM_LOG_LEVEL=1)
91
Chris Brandb42fed52019-12-02 16:10:17 -080092#Gather all source files we need.
93list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c")
94list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c")
95list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/mailbox_ipc_intr.c")
96list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_spe_mailbox.c")
97
98install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/ns_ipc_config.h
99 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.h
David Hu52c65f02020-01-10 11:19:19 +0800100 DESTINATION export/tfm/include)
Chris Brandb42fed52019-12-02 16:10:17 -0800101
102install(FILES ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c
103 ${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c
104 DESTINATION export/tfm/src)
105
106if (NOT DEFINED BUILD_CMSIS_CORE)
107 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!")
108elseif(BUILD_CMSIS_CORE)
109 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm0plus.c")
110 list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/system_psoc6_cm4.c")
111endif()
112
113if (NOT DEFINED BUILD_RETARGET)
114 message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!")
115elseif(BUILD_RETARGET)
116 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/device_definition.c")
117endif()
118
119if (NOT DEFINED BUILD_UART_STDOUT)
120 message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!")
121elseif(BUILD_UART_STDOUT)
122 if (NOT DEFINED SECURE_UART1)
123 message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!")
124 elseif(SECURE_UART1)
125 message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!")
126 endif()
Shawn Shan61afaa22020-09-15 16:11:42 +0800127 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c"
128 "${PLATFORM_DIR}/common/tfm_hal_spm_logdev_peripheral.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800129 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
130 set(BUILD_NATIVE_DRIVERS true)
131 set(BUILD_CMSIS_DRIVERS true)
132endif()
133
134if (NOT DEFINED BUILD_NATIVE_DRIVERS)
135 message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!")
136elseif(BUILD_NATIVE_DRIVERS)
137 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_device.c")
138 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_flash.c")
139 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_gpio.c")
140 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_prot.c")
141 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_drv.c")
142 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_pipe.c")
143 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_ipc_sema.c")
144 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_common.c")
145 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_scb_uart.c")
146 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysclk.c")
147 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_sysint.c")
148 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syslib.c")
149 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_syspm.c")
150 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_systick.c")
Alamy Liud33851f2019-11-21 13:17:58 -0800151 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_tcpwm_counter.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800152 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_trigmux.c")
153 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/source/cy_wdt.c")
154 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg.c")
155 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
156 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_clocks.c")
157 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_peripherals.c")
158 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_pins.c")
159 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_routing.c")
160 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source/cycfg_system.c")
161 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
162 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/cy_syslib_mdk.s")
163 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
164 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/cy_syslib_gcc.S")
TTornblome3ef1fd2020-01-23 16:50:19 +0100165 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
166 list(APPEND ALL_SRC_ASM "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/cy_syslib_iar.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800167 else()
168 message(FATAL_ERROR "No cy_syslib is available for compiler '${CMAKE_C_COMPILER_ID}'.")
169 endif()
170endif()
171
172if (NOT DEFINED BUILD_TIME)
173 message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!")
174elseif(BUILD_TIME)
175endif()
176
177if (NOT DEFINED BUILD_STARTUP)
178 message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!")
179elseif(BUILD_STARTUP)
180 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG")
181 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_s.s")
182 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/armclang/startup_psoc64_ns.s")
183 elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM")
184 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_s.S")
185 list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/gcc/startup_psoc64_ns.S")
186 set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" APPEND
187 PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE")
TTornblome3ef1fd2020-01-23 16:50:19 +0100188 elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM")
189 list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/iar/startup_psoc64_s.s")
190 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 -0800191 else()
192 message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.")
193 endif()
194endif()
195
Balint Matyi95f58eb2020-05-22 08:52:32 +0100196#Enable the checks of attestation claims against hard-coded values.
197set(ATTEST_CLAIM_VALUE_CHECK ON)
198
Chris Brandb42fed52019-12-02 16:10:17 -0800199if (NOT DEFINED BUILD_TARGET_CFG)
200 message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!")
201elseif(BUILD_TARGET_CFG)
202 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/target_cfg.c")
203 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/spm_hal.c")
204 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/attest_hal.c")
205 if (TFM_PARTITION_PLATFORM)
206 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/services/src/tfm_platform_system.c")
207 endif()
Chris Brandc47d7102020-02-20 11:12:18 -0800208 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c")
209 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800210 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c")
211 embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE)
212endif()
213
Alamy Liucc419f92019-11-21 15:55:33 -0800214if (NOT DEFINED BUILD_PLAT_TEST)
215 message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!")
216elseif(BUILD_PLAT_TEST)
217 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/plat_test.c")
218endif()
219
Chris Brandb42fed52019-12-02 16:10:17 -0800220if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS)
221 message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!")
222elseif(BUILD_TARGET_HARDWARE_KEYS)
David Hub3d2d622019-12-06 10:24:44 +0800223 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c")
David Hu086ffe32019-12-06 10:36:56 +0800224 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_rotpk.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800225 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_crypto_keys.c")
226endif()
227
228if (NOT DEFINED BUILD_TARGET_NV_COUNTERS)
229 message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!")
230elseif(BUILD_TARGET_NV_COUNTERS)
Chris Brandcfc51142020-03-23 14:02:28 -0700231 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/nv_counters.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800232 set(TARGET_NV_COUNTERS_ENABLE ON)
Kevin Pengc6d74502020-03-04 16:55:37 +0800233 # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services
Chris Brandb42fed52019-12-02 16:10:17 -0800234 # rollback protection code as the target supports nv counters.
Kevin Pengc6d74502020-03-04 16:55:37 +0800235 set (PS_ROLLBACK_PROTECTION ON)
Chris Brandb42fed52019-12-02 16:10:17 -0800236endif()
237
238if (NOT DEFINED BUILD_CMSIS_DRIVERS)
239 message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!")
240elseif(BUILD_CMSIS_DRIVERS)
241 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_smpu.c")
242 list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/driver_ppu.c")
Andrei Narkevitch995bb452020-01-15 13:58:47 -0800243 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/driver_dap.c")
Chris Brandb42fed52019-12-02 16:10:17 -0800244 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_USART.c")
245 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
246 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
247endif()
248
249if (NOT DEFINED BUILD_FLASH)
250 message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!")
251elseif(BUILD_FLASH)
252 list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Driver_Flash.c")
Kevin Pengc6d74502020-03-04 16:55:37 +0800253 # As the PS area is going to be in RAM, it is required to set PS_CREATE_FLASH_LAYOUT
254 # to be sure the PS service knows that when it starts the PS area does not contain any
255 # valid PS flash layout and it needs to create one.
256 set(PS_CREATE_FLASH_LAYOUT ON)
Chris Brandb42fed52019-12-02 16:10:17 -0800257 set(ITS_CREATE_FLASH_LAYOUT ON)
258 embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver" ABSOLUTE)
259 embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE)
260endif()
261
262list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_boot_seed.c")
263list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_device_id.c")