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