Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | |
| 8 | #This file gathers all MPS2/AN519 specific files in the application. |
| 9 | |
| 10 | #MPS2/AN519 has a Cortex M23 CPU. |
| 11 | include("Common/CpuM23") |
| 12 | |
| 13 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 14 | |
| 15 | #Specify the location of platform specific build dependencies. |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 16 | if(COMPILER STREQUAL "ARMCLANG") |
| 17 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_bl2.sct") |
| 18 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_s.sct") |
| 19 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/armclang/mps2_an519_ns.sct") |
| 20 | if (DEFINED CMSIS_5_DIR) |
| 21 | # not all project defines CMSIS_5_DIR, only the ones that use it. |
| 22 | set (RTX_LIB_PATH "${CMSIS_5_DIR}/CMSIS/RTOS2/RTX/Library/ARM/RTX_V8MBN.lib") |
| 23 | endif() |
| 24 | elseif(COMPILER STREQUAL "GNUARM") |
| 25 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_bl2.ld") |
| 26 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_s.ld") |
| 27 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/mps2/an519/gcc/mps2_an519_ns.ld") |
| 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/GCC/libRTX_V8MBN.a") |
| 31 | endif() |
| 32 | else() |
| 33 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 34 | endif() |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 35 | set (FLASH_LAYOUT "${PLATFORM_DIR}/target/mps2/an519/partition/flash_layout.h") |
| 36 | set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/mps2/an519/partition/") |
| 37 | set (SIGN_BIN_SIZE 0x100000) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 38 | |
| 39 | if (BL2) |
| 40 | set (BL2_LINKER_CONFIG ${BL2_SCATTER_FILE_NAME}) |
| 41 | endif() |
| 42 | |
| 43 | embedded_include_directories(PATH "${PLATFORM_DIR}/cmsis" ABSOLUTE) |
| 44 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2" ABSOLUTE) |
| 45 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519" ABSOLUTE) |
| 46 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_core" ABSOLUTE) |
| 47 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/retarget" ABSOLUTE) |
| 48 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers" ABSOLUTE) |
| 49 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/partition" ABSOLUTE) |
| 50 | |
| 51 | #Gather all source files we need. |
| 52 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 53 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 54 | elseif(BUILD_CMSIS_CORE) |
| 55 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_core/system_cmsdk_mps2_an519.c") |
| 56 | endif() |
| 57 | |
| 58 | if (NOT DEFINED BUILD_RETARGET) |
| 59 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 60 | elseif(BUILD_RETARGET) |
| 61 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/retarget/platform_retarget_dev.c") |
| 62 | endif() |
| 63 | |
| 64 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 65 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 66 | elseif(BUILD_UART_STDOUT) |
Miklos Balint | 6cbeba6 | 2018-04-12 17:31:34 +0200 | [diff] [blame] | 67 | if (NOT DEFINED SECURE_UART1) |
| 68 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 69 | elseif(SECURE_UART1) |
| 70 | add_definitions(-DSECURE_UART1) |
| 71 | endif() |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 72 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 73 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 74 | set(BUILD_NATIVE_DRIVERS true) |
| 75 | set(BUILD_CMSIS_DRIVERS true) |
| 76 | endif() |
| 77 | |
| 78 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 79 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 80 | elseif(BUILD_NATIVE_DRIVERS) |
| 81 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/arm_uart_drv.c") |
| 82 | |
| 83 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpc_sie200_drv.c" |
| 84 | "${PLATFORM_DIR}/target/mps2/an519/native_drivers/ppc_sse200_drv.c" |
| 85 | ) |
| 86 | endif() |
| 87 | |
| 88 | if (NOT DEFINED BUILD_TIME) |
| 89 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 90 | elseif(BUILD_TIME) |
| 91 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk/timer_cmsdk.c") |
| 92 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/native_drivers/timer_cmsdk" ABSOLUTE) |
| 93 | endif() |
| 94 | |
| 95 | if (NOT DEFINED BUILD_STARTUP) |
| 96 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 97 | elseif(BUILD_STARTUP) |
| 98 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 99 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_s.s") |
| 100 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_ns.s") |
| 101 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/armclang/startup_cmsdk_mps2_an519_bl2.s") |
Mate Toth-Pal | 7ed189e | 2018-03-28 17:58:59 +0200 | [diff] [blame] | 102 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 103 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_s.S") |
| 104 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_ns.S") |
| 105 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/mps2/an519/gcc/startup_cmsdk_mps2_an519_bl2.S") |
| 106 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 107 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 108 | else() |
| 109 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 110 | endif() |
| 111 | endif() |
| 112 | |
| 113 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 114 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 115 | elseif(BUILD_TARGET_CFG) |
| 116 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/target_cfg.c") |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 117 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/spm_hal.c") |
| 118 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/native_drivers/mpu_armv8m_drv.c") |
| 119 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 120 | endif() |
| 121 | |
| 122 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 123 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 124 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
| 125 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_crypto_keys.c") |
| 126 | endif() |
| 127 | |
Marc Moreno Berengue | b2c17ae | 2018-08-10 15:47:42 +0100 | [diff] [blame] | 128 | if (NOT DEFINED BUILD_TARGET_NV_COUNTERS) |
| 129 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_NV_COUNTERS (true|false) is undefined!") |
| 130 | elseif(BUILD_TARGET_NV_COUNTERS) |
| 131 | # NOTE: This non-volatile counters implementation is a dummy |
| 132 | # implementation. Platform vendors have to implement the |
| 133 | # API ONLY if the target has non-volatile counters. |
| 134 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/dummy_nv_counters.c") |
| 135 | set(TARGET_NV_COUNTERS_ENABLE ON) |
Marc Moreno Berengue | 184d203 | 2018-08-14 12:51:43 +0100 | [diff] [blame^] | 136 | # Sets SST_ROLLBACK_PROTECTION flag to compile in the SST services |
| 137 | # rollback protection code as the target supports nv counters. |
| 138 | set (SST_ROLLBACK_PROTECTION ON) |
Marc Moreno Berengue | b2c17ae | 2018-08-10 15:47:42 +0100 | [diff] [blame] | 139 | endif() |
| 140 | |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 141 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 142 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 143 | elseif(BUILD_CMSIS_DRIVERS) |
| 144 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_MPC.c" |
| 145 | "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_PPC.c") |
| 146 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_USART.c") |
| 147 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE) |
| 148 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 149 | endif() |
| 150 | |
| 151 | if (NOT DEFINED BUILD_FLASH) |
| 152 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 153 | elseif(BUILD_FLASH) |
Tamas Ban | c382885 | 2018-02-01 12:24:16 +0000 | [diff] [blame] | 154 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers/Driver_Flash.c") |
Marc Moreno Berengue | 792fc68 | 2018-02-20 11:53:30 +0000 | [diff] [blame] | 155 | # There is no real flash memory for code on MPS2 board. Instead a code SRAM is |
| 156 | # used for code storage: ZBT SSRAM1. The Driver_Flash driver just emulates a flash |
| 157 | # interface and behaviour on top of the SRAM memory. |
Marc Moreno Berengue | 95d6572 | 2018-07-26 17:24:02 +0100 | [diff] [blame] | 158 | # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT |
| 159 | # to be sure the SST service knows that when it starts the SST area does not contain any |
| 160 | # valid SST flash layout and it needs to create one. |
| 161 | set(SST_CREATE_FLASH_LAYOUT ON) |
Tamas Ban | c382885 | 2018-02-01 12:24:16 +0000 | [diff] [blame] | 162 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/mps2/an519/cmsis_drivers" ABSOLUTE) |
Mate Toth-Pal | 2e94d13 | 2018-01-26 17:27:52 +0100 | [diff] [blame] | 163 | endif() |
Oliver Swede | f998244 | 2018-08-24 18:37:44 +0100 | [diff] [blame] | 164 | |
| 165 | if (MCUBOOT_RAM_LOADING) |
| 166 | message (FATAL_ERROR "MCUBOOT_RAM_LOADING is not supported on " ${TARGET_PLATFORM}) |
| 167 | endif() |