Chris Brand | b42fed5 | 2019-12-02 16:10:17 -0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 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 | |
| 11 | include("Common/MultiCore") |
| 12 | |
| 13 | # Select configuration of multi-core topology |
| 14 | enable_multi_core_topology_config() |
| 15 | |
| 16 | set(TFM_NS_CLIENT_IDENTIFICATION OFF) |
| 17 | |
| 18 | add_definitions(-DCYB0644ABZI_S2D44=1) |
| 19 | |
| 20 | add_definitions(-DTFM_CORE_DEBUG) |
| 21 | |
| 22 | # psoc64 platform doesn't yet use TF-M BL2 |
| 23 | set(BL2 False) |
| 24 | remove_definitions(-DBL2) |
| 25 | |
| 26 | # Skip Core Test temporarily |
| 27 | set(CORE_TEST OFF) |
| 28 | # Skip peripheral access test |
| 29 | set(TFM_ENABLE_PERIPH_ACCESS_TEST OFF) |
| 30 | |
| 31 | # Set Cortex-M0plus as secure core |
| 32 | set_secure_cpu_type("CpuM0p") |
| 33 | # Set Cortex-M4 as non-secure core |
| 34 | set_ns_cpu_type("CpuM4") |
| 35 | |
| 36 | # Set PSoC62 specific secure definitions |
| 37 | add_platform_secure_definitions(CY_PSOC6_CM0P=1) |
| 38 | |
| 39 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 40 | |
| 41 | #Specify the location of platform specific build dependencies. |
| 42 | if(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() |
| 49 | elseif(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() |
| 57 | else() |
| 58 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 59 | endif() |
| 60 | set (FLASH_LAYOUT "${PLATFORM_DIR}/target/cypress/psoc64/partition/flash_layout.h") |
| 61 | set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/cypress/psoc64/partition") |
| 62 | |
| 63 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 64 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64" ABSOLUTE) |
| 65 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/CMSIS_Driver/Config" ABSOLUTE) |
| 66 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Config" ABSOLUTE) |
| 67 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Device/Include" ABSOLUTE) |
| 68 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/include" ABSOLUTE) |
| 69 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/Native_Driver/generated_source" ABSOLUTE) |
| 70 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/mailbox" ABSOLUTE) |
| 71 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/cypress/psoc64/partition" ABSOLUTE) |
| 72 | embedded_include_directories(PATH "${TFM_ROOT_DIR}/interface/include" ABSOLUTE) |
| 73 | embedded_include_directories(PATH "${TFM_ROOT_DIR}/platform/include" ABSOLUTE) |
| 74 | embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/arch/include" ABSOLUTE) |
| 75 | embedded_include_directories(PATH "${TFM_ROOT_DIR}/secure_fw/core/ipc/include" ABSOLUTE) |
| 76 | |
| 77 | #Gather all source files we need. |
| 78 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_multicore.c") |
| 79 | list(APPEND ALL_SRC_C_NS "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_ns_mailbox.c") |
| 80 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/mailbox_ipc_intr.c") |
| 81 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/mailbox/platform_spe_mailbox.c") |
| 82 | |
| 83 | install(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 | |
| 87 | install(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 | |
| 91 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 92 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 93 | elseif(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") |
| 96 | endif() |
| 97 | |
| 98 | if (NOT DEFINED BUILD_RETARGET) |
| 99 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 100 | elseif(BUILD_RETARGET) |
| 101 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/cypress/psoc64/Device/Source/device_definition.c") |
| 102 | endif() |
| 103 | |
| 104 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 105 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 106 | elseif(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) |
| 116 | endif() |
| 117 | |
| 118 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 119 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 120 | elseif(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() |
| 151 | endif() |
| 152 | |
| 153 | if (NOT DEFINED BUILD_TIME) |
| 154 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 155 | elseif(BUILD_TIME) |
| 156 | endif() |
| 157 | |
| 158 | if (NOT DEFINED BUILD_STARTUP) |
| 159 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 160 | elseif(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() |
| 172 | endif() |
| 173 | |
| 174 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 175 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 176 | elseif(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) |
| 185 | endif() |
| 186 | |
| 187 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 188 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 189 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
David Hu | b3d2d62 | 2019-12-06 10:24:44 +0800 | [diff] [blame^] | 190 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c") |
Chris Brand | b42fed5 | 2019-12-02 16:10:17 -0800 | [diff] [blame] | 191 | 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") |
| 193 | endif() |
| 194 | |
| 195 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 196 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 197 | elseif(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) |
| 206 | endif() |
| 207 | |
| 208 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 209 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 210 | elseif(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) |
| 216 | endif() |
| 217 | |
| 218 | if (NOT DEFINED BUILD_FLASH) |
| 219 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 220 | elseif(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) |
| 229 | endif() |
| 230 | |
| 231 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_boot_seed.c") |
| 232 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/cypress/psoc64/dummy_device_id.c") |