Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [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 musca specific files in the application. |
| 9 | |
| 10 | #MUSCA-A has a Cortex M33 CPU. |
| 11 | include("Common/CpuM33") |
| 12 | |
| 13 | set(PLATFORM_DIR ${CMAKE_CURRENT_LIST_DIR}) |
| 14 | |
| 15 | #Specify the location of platform specific build dependencies. |
Mate Toth-Pal | f64f1eb | 2018-04-26 17:22:37 +0200 | [diff] [blame] | 16 | if(COMPILER STREQUAL "ARMCLANG") |
| 17 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_bl2.sct") |
| 18 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_s.sct") |
| 19 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/musca_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_V8MMN.lib") |
| 23 | endif() |
| 24 | elseif(COMPILER STREQUAL "GNUARM") |
| 25 | set (BL2_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/musca_bl2.ld") |
| 26 | set (S_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/musca_s.ld") |
| 27 | set (NS_SCATTER_FILE_NAME "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/musca_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_V8MMN.a") |
| 31 | endif() |
| 32 | else() |
| 33 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 34 | endif() |
| 35 | set (FLASH_LAYOUT "${PLATFORM_DIR}/target/musca_a/partition/flash_layout.h") |
Gabor Kertesz | d7d7d74 | 2018-07-04 11:50:05 +0200 | [diff] [blame] | 36 | set (PLATFORM_LINK_INCLUDES "${PLATFORM_DIR}/target/musca_a/partition") |
Oliver Swede | 7cbf7ef | 2018-08-31 11:49:12 +0100 | [diff] [blame] | 37 | set (SIGN_BIN_SIZE 0x100000) |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [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/musca_a" ABSOLUTE) |
| 45 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Config" ABSOLUTE) |
| 46 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Config" ABSOLUTE) |
| 47 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Device/Include" ABSOLUTE) |
| 48 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE) |
| 49 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/partition" ABSOLUTE) |
David Vincze | 26e8c8a | 2018-08-28 16:59:41 +0200 | [diff] [blame] | 50 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Libraries" ABSOLUTE) |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 51 | |
| 52 | #Gather all source files we need. |
| 53 | if (NOT DEFINED BUILD_CMSIS_CORE) |
| 54 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_CORE (true|false) is undefined!") |
| 55 | elseif(BUILD_CMSIS_CORE) |
| 56 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/system_cmsdk_musca.c") |
| 57 | endif() |
| 58 | |
| 59 | if (NOT DEFINED BUILD_RETARGET) |
| 60 | message(FATAL_ERROR "Configuration variable BUILD_RETARGET (true|false) is undefined!") |
| 61 | elseif(BUILD_RETARGET) |
| 62 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Device/Source/platform_retarget_dev.c") |
| 63 | endif() |
| 64 | |
| 65 | if (NOT DEFINED BUILD_UART_STDOUT) |
| 66 | message(FATAL_ERROR "Configuration variable BUILD_UART_STDOUT (true|false) is undefined!") |
| 67 | elseif(BUILD_UART_STDOUT) |
Miklos Balint | 6cbeba6 | 2018-04-12 17:31:34 +0200 | [diff] [blame] | 68 | if (NOT DEFINED SECURE_UART1) |
| 69 | message(FATAL_ERROR "Configuration variable SECURE_UART1 (true|false) is undefined!") |
| 70 | elseif(SECURE_UART1) |
| 71 | message(FATAL_ERROR "Configuration SECURE_UART1 TRUE is invalid for this target!") |
| 72 | endif() |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 73 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/common/uart_stdout.c") |
| 74 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
| 75 | set(BUILD_NATIVE_DRIVERS true) |
| 76 | set(BUILD_CMSIS_DRIVERS true) |
| 77 | endif() |
| 78 | |
| 79 | if (NOT DEFINED BUILD_NATIVE_DRIVERS) |
| 80 | message(FATAL_ERROR "Configuration variable BUILD_NATIVE_DRIVERS (true|false) is undefined!") |
| 81 | elseif(BUILD_NATIVE_DRIVERS) |
| 82 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/uart_pl011_drv.c") |
Gabor Kertesz | 5c1756f | 2018-07-18 12:25:12 +0200 | [diff] [blame] | 83 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/musca_a1_scc_drv.c") |
Oliver Swede | 8ee18a9 | 2018-08-24 18:18:26 +0100 | [diff] [blame] | 84 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c") |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 85 | |
| 86 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpc_sie200_drv.c" |
| 87 | "${PLATFORM_DIR}/target/musca_a/Native_Driver/ppc_sse200_drv.c") |
David Vincze | 26e8c8a | 2018-08-28 16:59:41 +0200 | [diff] [blame] | 88 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/qspi_ip6514e_drv.c") |
| 89 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Libraries/mt25ql_flash_lib.c") |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 90 | endif() |
| 91 | |
| 92 | if (NOT DEFINED BUILD_TIME) |
| 93 | message(FATAL_ERROR "Configuration variable BUILD_TIME (true|false) is undefined!") |
| 94 | elseif(BUILD_TIME) |
| 95 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/Native_Driver/timer_cmsdk.c") |
| 96 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/Native_Driver" ABSOLUTE) |
| 97 | endif() |
| 98 | |
| 99 | if (NOT DEFINED BUILD_STARTUP) |
| 100 | message(FATAL_ERROR "Configuration variable BUILD_STARTUP (true|false) is undefined!") |
| 101 | elseif(BUILD_STARTUP) |
| 102 | if(CMAKE_C_COMPILER_ID STREQUAL "ARMCLANG") |
| 103 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_s.s") |
| 104 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_ns.s") |
| 105 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/armclang/startup_cmsdk_musca_bl2.s") |
Mate Toth-Pal | f64f1eb | 2018-04-26 17:22:37 +0200 | [diff] [blame] | 106 | elseif(CMAKE_C_COMPILER_ID STREQUAL "GNUARM") |
| 107 | list(APPEND ALL_SRC_ASM_S "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_s.S") |
| 108 | list(APPEND ALL_SRC_ASM_NS "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_ns.S") |
| 109 | list(APPEND ALL_SRC_ASM_BL2 "${PLATFORM_DIR}/target/musca_a/Device/Source/gcc/startup_cmsdk_musca_bl2.S") |
| 110 | set_property(SOURCE "${ALL_SRC_ASM_S}" "${ALL_SRC_ASM_NS}" "${ALL_SRC_ASM_BL2}" APPEND |
| 111 | PROPERTY COMPILE_DEFINITIONS "__STARTUP_CLEAR_BSS_MULTIPLE" "__STARTUP_COPY_MULTIPLE") |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 112 | else() |
| 113 | message(FATAL_ERROR "No startup file is available for compiler '${CMAKE_C_COMPILER_ID}'.") |
| 114 | endif() |
| 115 | endif() |
| 116 | |
| 117 | if (NOT DEFINED BUILD_TARGET_CFG) |
| 118 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_CFG (true|false) is undefined!") |
| 119 | elseif(BUILD_TARGET_CFG) |
| 120 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/target_cfg.c") |
Mate Toth-Pal | 936c33b | 2018-04-10 14:02:07 +0200 | [diff] [blame] | 121 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/spm_hal.c") |
| 122 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/Native_Driver/mpu_armv8m_drv.c") |
| 123 | embedded_include_directories(PATH "${PLATFORM_DIR}/common" ABSOLUTE) |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 124 | endif() |
| 125 | |
| 126 | if (NOT DEFINED BUILD_TARGET_HARDWARE_KEYS) |
| 127 | message(FATAL_ERROR "Configuration variable BUILD_TARGET_HARDWARE_KEYS (true|false) is undefined!") |
| 128 | elseif(BUILD_TARGET_HARDWARE_KEYS) |
| 129 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/dummy_crypto_keys.c") |
| 130 | endif() |
| 131 | |
| 132 | if (NOT DEFINED BUILD_CMSIS_DRIVERS) |
| 133 | message(FATAL_ERROR "Configuration variable BUILD_CMSIS_DRIVERS (true|false) is undefined!") |
| 134 | elseif(BUILD_CMSIS_DRIVERS) |
| 135 | list(APPEND ALL_SRC_C_S "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_MPC.c" |
| 136 | "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_PPC.c") |
| 137 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_USART.c") |
| 138 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE) |
| 139 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
| 140 | endif() |
| 141 | |
| 142 | if (NOT DEFINED BUILD_FLASH) |
| 143 | message(FATAL_ERROR "Configuration variable BUILD_FLASH (true|false) is undefined!") |
| 144 | elseif(BUILD_FLASH) |
Avinash Mehta | 2e1b9bc | 2018-05-03 12:55:50 +0100 | [diff] [blame] | 145 | list(APPEND ALL_SRC_C "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver/Driver_Flash.c") |
Marc Moreno Berengue | 95d6572 | 2018-07-26 17:24:02 +0100 | [diff] [blame] | 146 | # As the SST area is going to be in RAM, it is required to set SST_CREATE_FLASH_LAYOUT |
| 147 | # to be sure the SST service knows that when it starts the SST area does not contain any |
| 148 | # valid SST flash layout and it needs to create one. |
| 149 | set(SST_CREATE_FLASH_LAYOUT ON) |
Avinash Mehta | 2e1b9bc | 2018-05-03 12:55:50 +0100 | [diff] [blame] | 150 | embedded_include_directories(PATH "${PLATFORM_DIR}/target/musca_a/CMSIS_Driver" ABSOLUTE) |
David Vincze | 26e8c8a | 2018-08-28 16:59:41 +0200 | [diff] [blame] | 151 | embedded_include_directories(PATH "${PLATFORM_DIR}/driver" ABSOLUTE) |
Avinash Mehta | 788036c | 2018-03-15 12:38:43 +0000 | [diff] [blame] | 152 | endif() |
Oliver Swede | f998244 | 2018-08-24 18:37:44 +0100 | [diff] [blame] | 153 | |
| 154 | if (NOT BL2) |
| 155 | message(STATUS "WARNING: BL2 is mandatory on target \"${TARGET_PLATFORM}\" Your choice was override.") |
| 156 | set(BL2 True) |
| 157 | endif() |
| 158 | |
| 159 | if (NOT MCUBOOT_RAM_LOADING) |
| 160 | message(STATUS "WARNING: MCUBOOT_RAM_LOADING is mandatory on target \"${TARGET_PLATFORM}\" Your choice was override.") |
| 161 | set(MCUBOOT_RAM_LOADING True) |
| 162 | endif() |
| 163 | |
| 164 | if (MCUBOOT_NO_SWAP) |
| 165 | message (FATAL_ERROR "MCUBOOT_NO_SWAP configuration is not supported on " ${TARGET_PLATFORM}) |
| 166 | endif() |