blob: 4f77bdd8dfda9b38d9b3a51c57e79b41257b96c2 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
Kshitij Sisodia5385a642024-01-17 13:29:43 +00002# SPDX-FileCopyrightText: Copyright 2022, 2024 Arm Limited and/or its
3# affiliates <open-source-office@arm.com>
alexander31ae9f02022-02-10 16:15:54 +00004# 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 Sisodia9c6f9f82022-05-20 14:30:02 +010023cmake_minimum_required(VERSION 3.21.0)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000024set(PLATFORM_DRIVERS_TARGET platform_drivers)
alexander31ae9f02022-02-10 16:15:54 +000025project(${PLATFORM_DRIVERS_TARGET}
26 DESCRIPTION "Platform drivers library for MPS3 FPGA/FVP targets"
27 LANGUAGES C CXX ASM)
28
Liam Barry213a5432022-05-09 17:06:19 +010029# 1. We should be cross-compiling (MPS3 target only runs Cortex-M targets)
alexander31ae9f02022-02-10 16:15:54 +000030if (NOT ${CMAKE_CROSSCOMPILING})
31 message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.")
32endif()
33
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000034# Define target specific base addresses here (before adding the components)
35if (TARGET_SUBSYSTEM STREQUAL sse-300)
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010036 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 Sisodiada2ec062022-04-01 14:43:53 +010040 set(ETHOS_U_IRQN "56" CACHE STRING "Ethos-U55 Interrupt")
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000041 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 Sisodiada2ec062022-04-01 14:43:53 +010043
Kshitij Sisodia5385a642024-01-17 13:29:43 +000044 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 Sisodia8c61c0a2022-05-17 11:16:22 +010057endif()
58
59# Define target specific base addresses here (before adding the components)
60if (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 Sisodia5385a642024-01-17 13:29:43 +000065
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010066 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 Sisodiaaa4bcb12022-05-06 09:13:03 +010069
Kshitij Sisodia5385a642024-01-17 13:29:43 +000070 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 Sisodiada2ec062022-04-01 14:43:53 +010076 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Kshitij Sisodia01334f92022-08-12 11:53:45 +010077 message(FATAL_ERROR "Timing adapter support should be disabled for ${TARGET_SUBSYSTEM}")
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010078 endif()
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000079endif()
80
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010081set(DYNAMIC_MODEL_BASE "0x90000000" CACHE STRING "Region to be used for dynamic load of model into memory")
82set(DYNAMIC_MODEL_SIZE "0x02000000" CACHE STRING "Size of the space reserved for the model")
83
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +010084math(EXPR IFM_BASE "${DYNAMIC_MODEL_BASE} + ${DYNAMIC_MODEL_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
85set(DYNAMIC_IFM_BASE "${IFM_BASE}" CACHE STRING "Base address for IFMs to be loaded")
86set(DYNAMIC_IFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the IFM")
87math(EXPR OFM_BASE "${DYNAMIC_IFM_BASE} + ${DYNAMIC_IFM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
88set(DYNAMIC_OFM_BASE "${OFM_BASE}" CACHE STRING "Base address for OFMs to be dumped to")
89set(DYNAMIC_OFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the OFM")
90
Kshitij Sisodia8c61c0a2022-05-17 11:16:22 +010091
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000092# 2. Create static library
alexander31ae9f02022-02-10 16:15:54 +000093add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
94
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000095## Include directories - private
96target_include_directories(${PLATFORM_DRIVERS_TARGET}
97 PRIVATE
98 source)
99
alexander31ae9f02022-02-10 16:15:54 +0000100## Include directories - public
101target_include_directories(${PLATFORM_DRIVERS_TARGET}
102 PUBLIC
103 include
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +0000104 include/${TARGET_SUBSYSTEM})
alexander31ae9f02022-02-10 16:15:54 +0000105
106## Platform sources
107target_sources(${PLATFORM_DRIVERS_TARGET}
108 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000109 source/timer_mps3.c
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000110 source/platform_drivers.c)
111
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000112## Directory for additional components required by MPS3:
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000113if (NOT DEFINED COMPONENTS_DIR)
114 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
115endif()
alexander31ae9f02022-02-10 16:15:54 +0000116
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000117## Platform component: cmsis_device (provides generic Cortex-M start up library)
118add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000119
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000120## Platform component: stdout
121set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART")
122add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout)
123
124## Platform component: lcd
125add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd)
alexander31ae9f02022-02-10 16:15:54 +0000126
Kshitij Sisodiada2ec062022-04-01 14:43:53 +0100127## Platform component: PMU
128add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu)
129
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +0100130## Logging utilities:
131if (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)
136endif()
137
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000138# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +0000139target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000140 log
141 cmsis_device
Kshitij Sisodiada2ec062022-04-01 14:43:53 +0100142 platform_pmu
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000143 lcd_mps3
144 $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_cmsdk,stdout>)
alexander31ae9f02022-02-10 16:15:54 +0000145
Kshitij Sisodiada2ec062022-04-01 14:43:53 +0100146# Set the CPU profiling definition
147if (CPU_PROFILE_ENABLED)
148 target_compile_definitions(${PLATFORM_DRIVERS_TARGET} PUBLIC CPU_PROFILE_ENABLED)
149endif()
150
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000151# If Ethos-U is enabled, we need the driver library too
152if (ETHOS_U_NPU_ENABLED)
153
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000154 ## Platform component: Ethos-U initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000155 add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000156
157 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
158 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000159 ethos_u_npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000160
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000161 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
162 ## Platform component: Ethos-U timing adapter initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000163 add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000164
165 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
166 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000167 ethos_u_ta)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000168 endif()
169
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000170endif()
171
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +0000172# 3. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000173message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
174message(STATUS "*******************************************************")
175message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
176message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
alexander31ae9f02022-02-10 16:15:54 +0000177message(STATUS "*******************************************************")