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 | |
| 82 | #Gather all source files we need. |
| 83 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 84 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 85 | elseif(BUILD_CMSIS_CORE) |
| 86 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/system_core_init.c") |
| 87 | endif() |
| 88 | |
| 89 | if (NOT DEFINED BUILD_RETARGET) |
| 90 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 91 | elseif(BUILD_RETARGET) |
| 92 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/device_definition.c") |
| 93 | endif() |
| 94 | |
| 95 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 96 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 97 | elseif(BUILD_UART_STDOUT) |
| 98 | if (NOT DEFINED SECURE_UART1) |
| 99 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 100 | elseif(SECURE_UART1) |
| 101 | message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!") |
| 102 | endif() |
| 103 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 104 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 105 | set(BUILD_NATIVE_DRIVERS true) |
| 106 | set(BUILD_CMSIS_DRIVERS true) |
| 107 | endif() |
| 108 | |
| 109 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 110 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 111 | elseif(BUILD_NATIVE_DRIVERS) |
| 112 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/uart_cmsdk_drv.c") |
| 113 | |
| 114 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpc_sie200_drv.c" |
| 115 | "${AN524_DIR}/native_drivers/ppc_sse200_drv.c") |
| 116 | endif() |
| 117 | |
| 118 | if (NOT DEFINED BUILD_TIME) |
| 119 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 120 | elseif(BUILD_TIME) |
| 121 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/timer_cmsdk_drv.c") |
| 122 | endif() |
| 123 | |
| 124 | if (NOT DEFINED BUILD_STARTUP) |
| 125 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 126 | elseif(BUILD_STARTUP) |
| 127 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 128 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_s.s") |
| 129 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_ns.s") |
| 130 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_bl2.s") |
| 131 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 132 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_s.S") |
| 133 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_ns.S") |
| 134 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_bl2.S") |
| 135 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 136 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
TTornblom | c29a77b | 2020-02-04 16:15:08 +0100 | [diff] [blame] | 137 | elseif(CMAKE_C_COMPILER_ID STREQUAL "IARARM") |
| 138 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/iar/startup_cmsdk_mps3_an524_s.s") |
| 139 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/iar/startup_cmsdk_mps3_an524_ns.s") |
| 140 | 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] | 141 | else() |
| 142 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 143 | endif() |
| 144 | endif() |
| 145 | |
Balint Matyi | 95f58eb | 2020-05-22 08:52:32 +0100 | [diff] [blame] | 146 | #Enable the checks of attestation claims against hard-coded values. |
| 147 | set(ATTEST_CLAIM_VALUE_CHECK ON) |
| 148 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 149 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 150 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 151 | elseif(BUILD_TARGET_CFG) |
| 152 | list(APPEND ALL_SRC_C "${AN524_DIR}/target_cfg.c") |
| 153 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/spm_hal.c") |
David Hu | a6ceeb6 | 2019-12-05 17:48:05 +0800 | [diff] [blame] | 154 | 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] | 155 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpu_armv8m_drv.c") |
| 156 | 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^] | 157 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_hal_its.c") |
| 158 | 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] | 159 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/common/tfm_platform.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 160 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 161 | endif() |
| 162 | |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 163 | if (NOT DEFINED BUILD_PLAT_TEST) |
| 164 | message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!") |
| 165 | elseif(BUILD_PLAT_TEST) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 166 | list(APPEND ALL_SRC_C "${AN524_DIR}/plat_test.c") |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 167 | endif() |
| 168 | |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 169 | if (NOT DEFINED BUILD_BOOT_HAL) |
| 170 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_HAL (true|false) is undefined!") |
| 171 | elseif(BUILD_BOOT_HAL) |
Andrei Narkevitch | b0be461 | 2020-01-27 17:26:19 -0800 | [diff] [blame] | 172 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/boot_hal.c") |
Tamas Ban | d4bf347 | 2019-09-06 12:59:56 +0100 | [diff] [blame] | 173 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps3/an524/boot_hal.c") |
| 174 | endif() |
| 175 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 176 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 177 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 178 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
David Hu | b3d2d62 | 2019-12-06 10:24:44 +0800 | [diff] [blame] | 179 | 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] | 180 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/tfm_rotpk.c") |
David Hu | 31c574dc | 2019-12-05 18:25:44 +0800 | [diff] [blame] | 181 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/crypto_keys.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 182 | endif() |
| 183 | |
| 184 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 185 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 186 | elseif (BUILD_TARGET_NV_COUNTERS) |
| 187 | # NOTE: This non-volatile counters implementation is a dummy |
| 188 | # implementation. Platform vendors have to implement the |
| 189 | # API ONLY if the target has non-volatile counters. |
David Hu | 2fa0738 | 2019-12-06 10:09:28 +0800 | [diff] [blame] | 190 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/template/nv_counters.c") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 191 | set(TARGET_NV_COUNTERS_ENABLE ON) |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 192 | # Sets PS_ROLLBACK_PROTECTION flag to compile in the PS services |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 193 | # rollback protection code as the target supports nv counters. |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 194 | set(PS_ROLLBACK_PROTECTION ON) |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 195 | endif() |
| 196 | |
| 197 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 198 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 199 | elseif(BUILD_CMSIS_DRIVERS) |
| 200 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/cmsis_drivers/Driver_MPC.c" |
| 201 | "${AN524_DIR}/cmsis_drivers/Driver_PPC.c") |
| 202 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_USART.c") |
| 203 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 204 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 205 | endif() |
| 206 | |
| 207 | if (NOT DEFINED BUILD_FLASH) |
| 208 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 209 | elseif(BUILD_FLASH) |
| 210 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_Flash.c") |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 211 | # 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] | 212 | # interface and behaviour on top of the BRAM memory. |
Kevin Peng | c6d7450 | 2020-03-04 16:55:37 +0800 | [diff] [blame] | 213 | # As the PS area is going to be in RAM, it is required to set PS_CREATE_FLASH_LAYOUT |
| 214 | # to be sure the PS service knows that when it starts the PS area does not contain any |
| 215 | # valid PS flash layout and it needs to create one. The same for ITS. |
| 216 | set(PS_CREATE_FLASH_LAYOUT ON) |
TudorCretu | ba8a3fa | 2019-07-22 10:05:12 +0100 | [diff] [blame] | 217 | set(ITS_CREATE_FLASH_LAYOUT ON) |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 218 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 219 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 220 | endif() |
| 221 | |
| 222 | if (MCUBOOT_RAM_LOADING) |
| 223 | message (FATAL_ERROR "MCUBOOT_RAM_LOADING is not supported on " ${TARGET_PLATFORM}) |
| 224 | endif() |