alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 2 | # SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its |
| 3 | # affiliates <open-source-office@arm.com> |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | #---------------------------------------------------------------------------- |
| 18 | |
| 19 | ######################################################### |
| 20 | # MPS3 platform support library # |
| 21 | ######################################################### |
| 22 | |
Kshitij Sisodia | 9c6f9f8 | 2022-05-20 14:30:02 +0100 | [diff] [blame] | 23 | cmake_minimum_required(VERSION 3.21.0) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 24 | set(PLATFORM_DRIVERS_TARGET platform_drivers) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 25 | project(${PLATFORM_DRIVERS_TARGET} |
| 26 | DESCRIPTION "Platform drivers library for MPS3 FPGA/FVP targets" |
| 27 | LANGUAGES C CXX ASM) |
| 28 | |
Liam Barry | 213a543 | 2022-05-09 17:06:19 +0100 | [diff] [blame] | 29 | # 1. We should be cross-compiling (MPS3 target only runs Cortex-M targets) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 30 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 31 | message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.") |
| 32 | endif() |
| 33 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 34 | # Define target specific base addresses here (before adding the components) |
| 35 | if (TARGET_SUBSYSTEM STREQUAL sse-300) |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 36 | set(UART0_BASE "0x49303000" CACHE STRING "UART base address") |
| 37 | set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate") |
| 38 | set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)") |
| 39 | set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address") |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 40 | set(ETHOS_U_IRQN "56" CACHE STRING "Ethos-U55 Interrupt") |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 41 | set(ETHOS_U_SEC_ENABLED "1" CACHE STRING "Ethos-U NPU Security enable") |
| 42 | set(ETHOS_U_PRIV_ENABLED "1" CACHE STRING "Ethos-U NPU Privilege enable") |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 43 | |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 44 | if (ETHOS_U_SEC_ENABLED) |
| 45 | set(ETHOS_U_BASE_ADDR "0x58102000" CACHE STRING "Ethos-U NPU base address") |
| 46 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 47 | set(TA0_BASE "0x58103000" CACHE STRING "Ethos-U NPU timing adapter 0") |
| 48 | set(TA1_BASE "0x58103200" CACHE STRING "Ethos-U NPU timing adapter 1") |
| 49 | endif() |
| 50 | else () |
| 51 | set(ETHOS_U_BASE_ADDR "0x48102000" CACHE STRING "Ethos-U NPU base address") |
| 52 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 53 | set(TA0_BASE "0x48103000" CACHE STRING "Ethos-U NPU timing adapter 0") |
| 54 | set(TA1_BASE "0x48103200" CACHE STRING "Ethos-U NPU timing adapter 1") |
| 55 | endif() |
| 56 | endif () |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 57 | endif() |
| 58 | |
| 59 | # Define target specific base addresses here (before adding the components) |
| 60 | if (TARGET_SUBSYSTEM STREQUAL sse-310) |
| 61 | set(UART0_BASE "0x49303000" CACHE STRING "UART base address") |
| 62 | set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate") |
| 63 | set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)") |
| 64 | set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address") |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 65 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 66 | set(ETHOS_U_IRQN "16" CACHE STRING "Ethos-U55 Interrupt") |
| 67 | set(ETHOS_U_SEC_ENABLED "1" CACHE STRING "Ethos-U NPU Security enable") |
| 68 | set(ETHOS_U_PRIV_ENABLED "1" CACHE STRING "Ethos-U NPU Privilege enable") |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 69 | |
Kshitij Sisodia | 5385a64 | 2024-01-17 13:29:43 +0000 | [diff] [blame] | 70 | if (ETHOS_U_SEC_ENABLED) |
| 71 | set(ETHOS_U_BASE_ADDR "0x50004000" CACHE STRING "Ethos-U NPU base address") |
| 72 | else () |
| 73 | set(ETHOS_U_BASE_ADDR "0x40004000" CACHE STRING "Ethos-U NPU base address") |
| 74 | endif () |
| 75 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 76 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
Kshitij Sisodia | 01334f9 | 2022-08-12 11:53:45 +0100 | [diff] [blame] | 77 | message(FATAL_ERROR "Timing adapter support should be disabled for ${TARGET_SUBSYSTEM}") |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 78 | endif() |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 79 | endif() |
| 80 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 81 | set(DYNAMIC_MODEL_BASE "0x90000000" CACHE STRING "Region to be used for dynamic load of model into memory") |
| 82 | set(DYNAMIC_MODEL_SIZE "0x02000000" CACHE STRING "Size of the space reserved for the model") |
| 83 | |
Kshitij Sisodia | aa4bcb1 | 2022-05-06 09:13:03 +0100 | [diff] [blame] | 84 | math(EXPR IFM_BASE "${DYNAMIC_MODEL_BASE} + ${DYNAMIC_MODEL_SIZE}" OUTPUT_FORMAT HEXADECIMAL) |
| 85 | set(DYNAMIC_IFM_BASE "${IFM_BASE}" CACHE STRING "Base address for IFMs to be loaded") |
| 86 | set(DYNAMIC_IFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the IFM") |
| 87 | math(EXPR OFM_BASE "${DYNAMIC_IFM_BASE} + ${DYNAMIC_IFM_SIZE}" OUTPUT_FORMAT HEXADECIMAL) |
| 88 | set(DYNAMIC_OFM_BASE "${OFM_BASE}" CACHE STRING "Base address for OFMs to be dumped to") |
| 89 | set(DYNAMIC_OFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the OFM") |
| 90 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame] | 91 | |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 92 | # 2. Create static library |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 93 | add_library(${PLATFORM_DRIVERS_TARGET} STATIC) |
| 94 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 95 | ## Include directories - private |
| 96 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 97 | PRIVATE |
| 98 | source) |
| 99 | |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 100 | ## Include directories - public |
| 101 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 102 | PUBLIC |
| 103 | include |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 104 | include/${TARGET_SUBSYSTEM}) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 105 | |
| 106 | ## Platform sources |
| 107 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 108 | PRIVATE |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 109 | source/timer_mps3.c |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 110 | source/platform_drivers.c) |
| 111 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 112 | ## Directory for additional components required by MPS3: |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 113 | if (NOT DEFINED COMPONENTS_DIR) |
| 114 | set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) |
| 115 | endif() |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 116 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 117 | ## Platform component: cmsis_device (provides generic Cortex-M start up library) |
| 118 | add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 119 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 120 | ## Platform component: stdout |
| 121 | set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART") |
| 122 | add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) |
| 123 | |
| 124 | ## Platform component: lcd |
| 125 | add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 126 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 127 | ## Platform component: PMU |
| 128 | add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) |
| 129 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 130 | ## Logging utilities: |
| 131 | if (NOT TARGET log) |
| 132 | if (NOT DEFINED LOG_PROJECT_DIR) |
| 133 | message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") |
| 134 | endif() |
| 135 | add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log) |
| 136 | endif() |
| 137 | |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 138 | # Add dependencies: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 139 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 140 | log |
| 141 | cmsis_device |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 142 | platform_pmu |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 143 | lcd_mps3 |
| 144 | $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_cmsdk,stdout>) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 145 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 146 | # Set the CPU profiling definition |
| 147 | if (CPU_PROFILE_ENABLED) |
| 148 | target_compile_definitions(${PLATFORM_DRIVERS_TARGET} PUBLIC CPU_PROFILE_ENABLED) |
| 149 | endif() |
| 150 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 151 | # If Ethos-U is enabled, we need the driver library too |
| 152 | if (ETHOS_U_NPU_ENABLED) |
| 153 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 154 | ## Platform component: Ethos-U initialization |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 155 | add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 156 | |
| 157 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} |
| 158 | PUBLIC |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 159 | ethos_u_npu) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 160 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 161 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 162 | ## Platform component: Ethos-U timing adapter initialization |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 163 | add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 164 | |
| 165 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} |
| 166 | PUBLIC |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 167 | ethos_u_ta) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 168 | endif() |
| 169 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 170 | endif() |
| 171 | |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 172 | # 3. Display status: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 173 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 174 | message(STATUS "*******************************************************") |
| 175 | message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET}) |
| 176 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 177 | message(STATUS "*******************************************************") |