Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2019, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #This file gathers all MPS3/AN524 specific files in the application. |
| 9 | |
| 10 | #MPS3/AN524 has a Cortex-M33 CPU. |
| 11 | include("Common/CpuM33") |
| 12 | |
| 13 | #Remap option for MPS3, default is BRAM |
| 14 | set(REMAP_QSPI True) |
| 15 | if (REMAP_QSPI) |
| 16 | add_definitions(-DREMAP_QSPI) |
| 17 | endif() |
| 18 | |
| 19 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 20 | |
| 21 | set(AN524_DIR ${PLATFORM_DIR}/target/mps3/an524) |
| 22 | |
| 23 | #Specify the location of platform specific build dependencies. |
| 24 | if(COMPILER STREQUAL "ARMCLANG") |
| 25 | set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_bl2.sct") |
| 26 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/armclang/tfm_common_s.sct") |
| 27 | set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/armclang/mps3_an524_ns.sct") |
| 28 | if (DEFINED CMSIS_5_DIR) |
| 29 | # not all project defines CMSIS_5_DIR, only the ones that use it. |
| 30 | set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MMN.lib") |
| 31 | endif() |
| 32 | elseif(COMPILER STREQUAL "GNUARM") |
| 33 | set (BL2_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_bl2.ld") |
| 34 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/common/gcc/tfm_common_s.ld") |
| 35 | set (NS_SCATTER_FILE_NAME "${AN524_DIR}/device/source/gcc/mps3_an524_ns.ld") |
| 36 | if (DEFINED CMSIS_5_DIR) |
| 37 | # Not all projects define CMSIS_5_DIR, only the ones that use it. |
| 38 | set(RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/GCC/libRTX_V8MMN.a") |
| 39 | endif() |
| 40 | else() |
| 41 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 42 | endif() |
| 43 | set (FLASH_LAYOUT "${AN524_DIR}/partition/flash_layout.h") |
| 44 | set (PLATFORM_LINK_INCLUDES "${AN524_DIR}/partition/") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 45 | |
| 46 | if (BL2) |
| 47 | set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME}) |
| 48 | if (NOT ${MCUBOOT_UPGRADE_STRATEGY} STREQUAL "NO_SWAP") |
| 49 | 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^] | 50 | mcuboot_override_upgrade_strategy("NO_SWAP") |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 51 | endif() |
| 52 | endif() |
| 53 | |
| 54 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 55 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps3/common" ABSOLUTE) |
| 56 | embedded_include_directories(PATH "${PLATFORM_DIR}/../include" ABSOLUTE) |
| 57 | embedded_include_directories(PATH "${AN524_DIR}" ABSOLUTE) |
| 58 | embedded_include_directories(PATH "${AN524_DIR}/partition" ABSOLUTE) |
| 59 | embedded_include_directories(PATH "${AN524_DIR}/device/include" ABSOLUTE) |
| 60 | embedded_include_directories(PATH "${AN524_DIR}/device/config" ABSOLUTE) |
| 61 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers/config" ABSOLUTE) |
| 62 | embedded_include_directories(PATH "${AN524_DIR}/native_drivers" ABSOLUTE) |
| 63 | |
| 64 | #Gather all source files we need. |
| 65 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 66 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 67 | elseif(BUILD_CMSIS_CORE) |
| 68 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/system_core_init.c") |
| 69 | endif() |
| 70 | |
| 71 | if (NOT DEFINED BUILD_RETARGET) |
| 72 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 73 | elseif(BUILD_RETARGET) |
| 74 | list(APPEND ALL_SRC_C "${AN524_DIR}/device/source/device_definition.c") |
| 75 | endif() |
| 76 | |
| 77 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 78 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 79 | elseif(BUILD_UART_STDOUT) |
| 80 | if (NOT DEFINED SECURE_UART1) |
| 81 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 82 | elseif(SECURE_UART1) |
| 83 | message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!") |
| 84 | endif() |
| 85 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 86 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 87 | set(BUILD_NATIVE_DRIVERS true) |
| 88 | set(BUILD_CMSIS_DRIVERS true) |
| 89 | endif() |
| 90 | |
| 91 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 92 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 93 | elseif(BUILD_NATIVE_DRIVERS) |
| 94 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/uart_cmsdk_drv.c") |
| 95 | |
| 96 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpc_sie200_drv.c" |
| 97 | "${AN524_DIR}/native_drivers/ppc_sse200_drv.c") |
| 98 | endif() |
| 99 | |
| 100 | if (NOT DEFINED BUILD_TIME) |
| 101 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 102 | elseif(BUILD_TIME) |
| 103 | list(APPEND ALL_SRC_C "${AN524_DIR}/native_drivers/timer_cmsdk_drv.c") |
| 104 | endif() |
| 105 | |
| 106 | if (NOT DEFINED BUILD_STARTUP) |
| 107 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 108 | elseif(BUILD_STARTUP) |
| 109 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 110 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_s.s") |
| 111 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_ns.s") |
| 112 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/armclang/startup_cmsdk_mps3_an524_bl2.s") |
| 113 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 114 | list(APPEND ALL_SRC_ASM_S "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_s.S") |
| 115 | list(APPEND ALL_SRC_ASM_NS "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_ns.S") |
| 116 | list(APPEND ALL_SRC_ASM_BL2 "${AN524_DIR}/device/source/gcc/startup_cmsdk_mps3_an524_bl2.S") |
| 117 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 118 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
| 119 | else() |
| 120 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 121 | endif() |
| 122 | endif() |
| 123 | |
| 124 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 125 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 126 | elseif(BUILD_TARGET_CFG) |
| 127 | list(APPEND ALL_SRC_C "${AN524_DIR}/target_cfg.c") |
| 128 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/spm_hal.c") |
| 129 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/attest_hal.c") |
| 130 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/native_drivers/mpu_armv8m_drv.c") |
| 131 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/services/src/tfm_platform_system.c") |
| 132 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 133 | endif() |
| 134 | |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 135 | if (NOT DEFINED BUILD_PLAT_TEST) |
| 136 | message(FATAL_ERROR "Configuration variable BUILD_PLAT_TEST (true|false) is undefined!") |
| 137 | elseif(BUILD_PLAT_TEST) |
Mate Toth-Pal | a9f8e9e | 2019-03-05 16:11:14 +0100 | [diff] [blame] | 138 | list(APPEND ALL_SRC_C "${AN524_DIR}/plat_test.c") |
Mate Toth-Pal | d3c7766 | 2019-02-20 16:23:00 +0100 | [diff] [blame] | 139 | endif() |
| 140 | |
Kevin Peng | 0a14211 | 2018-09-21 10:42:22 +0800 | [diff] [blame] | 141 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 142 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 143 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
| 144 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/tfm_initial_attestation_key_material.c") |
| 145 | list(APPEND ALL_SRC_C "${AN524_DIR}/dummy_crypto_keys.c") |
| 146 | endif() |
| 147 | |
| 148 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 149 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 150 | elseif (BUILD_TARGET_NV_COUNTERS) |
| 151 | # NOTE: This non-volatile counters implementation is a dummy |
| 152 | # implementation. Platform vendors have to implement the |
| 153 | # API ONLY if the target has non-volatile counters. |
| 154 | list(APPEND ALL_SRC_C "${AN524_DIR}/dummy_nv_counters.c") |
| 155 | set(TARGET_NV_COUNTERS_ENABLE ON) |
| 156 | # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services |
| 157 | # rollback protection code as the target supports nv counters. |
| 158 | set(SST_ROLLBACK_PROTECTION ON) |
| 159 | endif() |
| 160 | |
| 161 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 162 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 163 | elseif(BUILD_CMSIS_DRIVERS) |
| 164 | list(APPEND ALL_SRC_C_S "${AN524_DIR}/cmsis_drivers/Driver_MPC.c" |
| 165 | "${AN524_DIR}/cmsis_drivers/Driver_PPC.c") |
| 166 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_USART.c") |
| 167 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 168 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 169 | endif() |
| 170 | |
| 171 | if (NOT DEFINED BUILD_FLASH) |
| 172 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 173 | elseif(BUILD_FLASH) |
| 174 | list(APPEND ALL_SRC_C "${AN524_DIR}/cmsis_drivers/Driver_Flash.c") |
| 175 | # For AN524 currently BRAM is used for SST The Driver_Flash driver just emulates a flash |
| 176 | # interface and behaviour on top of the BRAM memory. |
| 177 | # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT |
| 178 | # to be sure the SST service knows that when it starts the SST area does not contain any |
| 179 | # valid SST flash layout and it needs to create one. |
| 180 | set(SST_CREATE_FLASH_LAYOUT ON) |
| 181 | set(SST_RAM_FS OFF) |
| 182 | embedded_include_directories(PATH "${AN524_DIR}/cmsis_drivers" ABSOLUTE) |
| 183 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 184 | endif() |
| 185 | |
| 186 | if (MCUBOOT_RAM_LOADING) |
| 187 | message (FATAL_ERROR "MCUBOOT_RAM_LOADING is not supported on " ${TARGET_PLATFORM}) |
| 188 | endif() |
| 189 | |
| 190 | if (NOT DEFINED BUILD_BOOT_SEED) |
| 191 | message(FATAL_ERROR "Configuration variable BUILD_BOOT_SEED (true|false) is undefined!") |
| 192 | elseif(BUILD_BOOT_SEED) |
| 193 | list(APPEND ALL_SRC_C "${AN524_DIR}/dummy_boot_seed.c") |
| 194 | endif() |
| 195 | |
| 196 | if (NOT DEFINED BUILD_DEVICE_ID) |
| 197 | message(FATAL_ERROR "Configuration variable BUILD_DEVICE_ID (true|false) is undefined!") |
| 198 | elseif(BUILD_DEVICE_ID) |
| 199 | list(APPEND ALL_SRC_C "${AN524_DIR}/dummy_device_id.c") |
| 200 | endif() |