Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
Andrei Narkevitch | b0be461 | 2020-01-27 17:26:19 -0800 | [diff] [blame] | 2 | # Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 3 | # Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved. |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | #------------------------------------------------------------------------------- |
| 8 | |
| 9 | #This file gathers all MPS3/AN524 specific files in the application. |
| 10 | |
| 11 | #MPS3/AN524 has a Cortex-M33 CPU. |
| 12 | include("Common/CpuM33") |
| 13 | |
| 14 | #Remap option for MPS3, default is BRAM |
| 15 | set(REMAP_QSPI True) |
| 16 | if (REMAP_QSPI) |
| 17 | add_definitions(-DREMAP_QSPI) |
| 18 | endif() |
| 19 | |
| 20 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 21 | |
| 22 | set(AN524_DIR ${PLATFORM_DIR}/target/mps3/an524) |
| 23 | |
| 24 | #Specify the location of platform specific build dependencies. |
| 25 | if(COMPILER STREQUAL "ARMCLANG") |
| 26 | set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_bl2.sct") |
| 27 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct") |
| 28 | set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_ns.sct") |
Kevin Peng | 2131fdb | 2020-05-21 15:51:36 +0800 | [diff] [blame] | 29 | if (DEFINED CMSIS_DIR) |
| 30 | # not all project defines CMSIS_DIR, only the ones that use it. |
| 31 | set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 32 | endif() |
| 33 | elseif(COMPILER STREQUAL "GNUARM") |
| 34 | set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_bl2.ld") |
| 35 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld") |
| 36 | set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_ns.ld") |
Kevin Peng | 2131fdb | 2020-05-21 15:51:36 +0800 | [diff] [blame] | 37 | if (DEFINED CMSIS_DIR) |
| 38 | # Not all projects define CMSIS_DIR, only the ones that use it. |
| 39 | set(RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 40 | endif() |
TTornblom | c29a77b | 2020-02-04 16:15:08 +0100 | [diff] [blame] | 41 | elseif(COMPILER STREQUAL "IARARM") |
| 42 | set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/iar/mps3_an524_bl2.icf") |
| 43 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/iar/tfm_common_s.icf") |
| 44 | set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/iar/mps3_an524_ns.icf") |
Kevin Peng | 2131fdb | 2020-05-21 15:51:36 +0800 | [diff] [blame] | 45 | if (DEFINED CMSIS_DIR) |
| 46 | # not all project defines CMSIS_DIR, only the ones that use it. |
| 47 | set (RTX_LIB_PATH "${CMSIS_DIR}/RTOS2/RTX/Library/IAR/RTX_V8MMN.a") |
TTornblom | c29a77b | 2020-02-04 16:15:08 +0100 | [diff] [blame] | 48 | endif() |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 49 | else() |
| 50 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 51 | endif() |
| 52 | set (FLASH_LAYOUT "${AN524_DIR}/partition/flash_layout.h") |
| 53 | set (PLATFORM_LINK_INCLUDES "${AN524_DIR}/partition/") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 54 | |
| 55 | if (BL2) |
| 56 | set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME}) |
| 57 | if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP") |
| 58 | message(WARNING "NO_SWAP upgrade strategy is mandatory on target '${TARGET_PLATFORM}'. Your choice was overriden.") |
David Vincze | 63eda7a | 2019-08-09 17:42:51 +0200 | [diff] [blame] | 59 | mcuboot_override_upgrade_strategy("NO_SWAP") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 60 | endif() |
Tamas Ban | 5db5753 | 2019-07-17 10:59:02 +0100 | [diff] [blame] | 61 | |
David Hu | 086ffe3 | 2019-12-06 10:36:56 +0800 | [diff] [blame] | 62 | #FixMe: MCUBOOT_SIGN_RSA_LEN can be removed when ROTPK won't be hard coded in platform/ext/common/template/tfm_rotpk.c |
Tamas Ban | 5db5753 | 2019-07-17 10:59:02 +0100 | [diff] [blame] | 63 | # instead independently loaded from secure code as a blob. |
| 64 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-2048") |
| 65 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=2048) |
| 66 | endif() |
| 67 | if (${MCUBOOT_SIGNATURE_TYPE} STREQUAL "RSA-3072") |
| 68 | add_definitions(-DMCUBOOT_SIGN_RSA_LEN=3072) |
| 69 | endif() |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 70 | endif() |
| 71 | |
| 72 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 73 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps3/common" ABSOLUTE) |
| 74 | embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE) |
| 75 | embedded_include_directories(PATH "${AN524_DIR}" ABSOLUTE) |
| 76 | embedded_include_directories(PATH "${AN524_DIR}/partition" ABSOLUTE) |
| 77 | embedded_include_directories(PATH "${AN524_DIR}/device/include" ABSOLUTE) |
| 78 | embedded_include_directories(PATH "${AN524_DIR}/device/config" ABSOLUTE) |
| 79 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers/config" ABSOLUTE) |
| 80 | embedded_include_directories(PATH "${AN524_DIR}/native_drivers" ABSOLUTE) |
| 81 | |
Shawn Shan | 61afaa2 | 2020-09-15 16:11:42 +0800 | [diff] [blame] | 82 | add_definitions(-DTFM_SPM_LOG_LEVEL=1) |
| 83 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 84 | #Gather all source files we need. |
| 85 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 86 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 87 | elseif(BUILD_CMSIS_CORE) |
| 88 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/system_core_init.c") |
| 89 | endif() |
| 90 | |
| 91 | if (NOT DEFINED BUILD_RETARGET) |
| 92 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 93 | elseif(BUILD_RETARGET) |
| 94 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/device_definition.c") |
| 95 | endif() |
| 96 | |
| 97 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 98 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 99 | elseif(BUILD_UART_STDOUT) |
| 100 | if (NOT DEFINED SECURE_UART1) |
| 101 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 102 | elseif(SECURE_UART1) |
| 103 | message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!") |
| 104 | endif() |
Shawn Shan | 61afaa2 | 2020-09-15 16:11:42 +0800 | [diff] [blame] | 105 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c" |
| 106 | "${PLATFORM_DIR}/common/tfm_hal_spm_logdev_peripheral.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 107 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 108 | set(BUILD_NATIVE_DRIVERS true) |
| 109 | set(BUILD_CMSIS_DRIVERS true) |
| 110 | endif() |
| 111 | |
| 112 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 113 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 114 | elseif(BUILD_NATIVE_DRIVERS) |
| 115 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/uart_cmsdk_drv.c") |
| 116 | |
| 117 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpc_sie200_drv.c" |
| 118 | "${AN524_DIR}/native_drivers/ppc_sse200_drv.c") |
| 119 | endif() |
| 120 | |
| 121 | if (NOT DEFINED BUILD_TIME) |
| 122 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 123 | elseif(BUILD_TIME) |
| 124 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/timer_cmsdk_drv.c") |
| 125 | endif() |
| 126 | |
| 127 | if (NOT DEFINED BUILD_STARTUP) |
| 128 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 129 | elseif(BUILD_STARTUP) |
| 130 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 131 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_s.s") |
| 132 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_ns.s") |
| 133 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_bl2.s") |
| 134 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 135 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_s.S") |
| 136 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_ns.S") |
| 137 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_bl2.S") |
| 138 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 139 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
TTornblom | c29a77b | 2020-02-04 16:15:08 +0100 | [diff] [blame] | 140 | elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM") |
| 141 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/iar/startup_cmsdk_mps3_an524_s.s") |
| 142 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/iar/startup_cmsdk_mps3_an524_ns.s") |
| 143 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/iar/startup_cmsdk_mps3_an524_bl2.s") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 144 | else() |
| 145 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 146 | endif() |
| 147 | endif() |
| 148 | |
Balint Matyi | 95f58eb | 2020-05-22 08:52:32 +0100 | [diff] [blame] | 149 | #Enable the checks of attestation claims against hard-coded values. |
| 150 | set(ATTEST_CLAIM_VALUE_CHECK ON) |
| 151 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 152 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 153 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 154 | elseif(BUILD_TARGET_CFG) |
| 155 | list(APPEND ALL_SRC_C "${AN524_DIR}/target_cfg.c") |
| 156 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/spm_hal.c") |
David Hu | a6ceeb6 | 2019-12-05 17:48:05 +0800 | [diff] [blame] | 157 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/template/attest_hal.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 158 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpu_armv8m_drv.c") |
| 159 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/services/src/tfm_platform_system.c") |
Chris Brand | c47d710 | 2020-02-20 11:12:18 -0800 | [diff] [blame] | 160 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c") |
| 161 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_ps.c") |
Andrei Narkevitch | 5bba54c | 2019-09-23 14:09:13 -0700 | [diff] [blame] | 162 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 163 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 164 | endif() |
| 165 | |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 166 | if (NOT DEFINED BUILD_PLAT_TEST) |
| 167 | message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!") |
| 168 | elseif(BUILD_PLAT_TEST) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 169 | list(APPEND ALL_SRC_C "${AN524_DIR}/plat_test.c") |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 170 | endif() |
| 171 | |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 172 | if (NOT DEFINED BUILD_BOOT_HAL) |
| 173 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!") |
| 174 | elseif(BUILD_BOOT_HAL) |
Andrei Narkevitch | b0be461 | 2020-01-27 17:26:19 -0800 | [diff] [blame] | 175 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c") |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 176 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps3/an524/boot_hal.c") |
| 177 | endif() |
| 178 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 179 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 180 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 181 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
David Hu | b3d2d62 | 2019-12-06 10:24:44 +0800 | [diff] [blame] | 182 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_initial_attestation_key_material.c") |
David Hu | 086ffe3 | 2019-12-06 10:36:56 +0800 | [diff] [blame] | 183 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c") |
David Hu | 31c574dc | 2019-12-05 18:25:44 +0800 | [diff] [blame] | 184 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 185 | endif() |
| 186 | |
| 187 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 188 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 189 | elseif (BUILD_TARGET_NV_COUNTERS) |
| 190 | # NOTE: This non-volatile counters implementation is a dummy |
| 191 | # implementation. Platform vendors have to implement the |
| 192 | # API ONLY if the target has non-volatile counters. |
David Hu | 2fa0738 | 2019-12-06 10:09:28 +0800 | [diff] [blame] | 193 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 194 | set(TARGET_NV_COUNTERS_ENABLE ON) |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 195 | # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 196 | # rollback protection code as the target supports nv counters. |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 197 | set(PS_ROLLBACK_PROTECTION ON) |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 198 | endif() |
| 199 | |
| 200 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 201 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 202 | elseif(BUILD_CMSIS_DRIVERS) |
| 203 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/cmsis_drivers/Driver_MPC.c" |
| 204 | "${AN524_DIR}/cmsis_drivers/Driver_PPC.c") |
| 205 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_USART.c") |
| 206 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 207 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 208 | endif() |
| 209 | |
| 210 | if (NOT DEFINED BUILD_FLASH) |
| 211 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 212 | elseif(BUILD_FLASH) |
| 213 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_Flash.c") |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 214 | # For AN524 currently BRAM is used for PS The Driver_Flash driver just emulates a flash |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 215 | # interface and behaviour on top of the BRAM memory. |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 216 | # As the PS area is going to be in RAM, it is required to set PS_CREATE_FLASH_LAYOUT |
| 217 | # to be sure the PS service knows that when it starts the PS area does not contain any |
| 218 | # valid PS flash layout and it needs to create one. The same for ITS. |
| 219 | set(PS_CREATE_FLASH_LAYOUT ON) |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 220 | set(ITS_CREATE_FLASH_LAYOUT ON) |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 221 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 222 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 223 | endif() |
| 224 | |
| 225 | if (MCUBOOT_RAM_LOADING) |
| 226 | message (FATAL_ERROR "MCUBOOT_RAM_LOADING is not supported on " ${TARGET_PLATFORM}) |
| 227 | endif() |