blob: 46da2fa9254c98a2824defb909605c43ffa21490 [file] [log] [blame]
alexander31ae9f02022-02-10 16:15:54 +00001#----------------------------------------------------------------------------
2# Copyright (c) 2022 Arm Limited. All rights reserved.
3# SPDX-License-Identifier: Apache-2.0
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#----------------------------------------------------------------------------
17
18#########################################################
19# MPS3 platform support library #
20#########################################################
21
22cmake_minimum_required(VERSION 3.15.6)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000023set(PLATFORM_DRIVERS_TARGET platform_drivers)
alexander31ae9f02022-02-10 16:15:54 +000024project(${PLATFORM_DRIVERS_TARGET}
25 DESCRIPTION "Platform drivers library for MPS3 FPGA/FVP targets"
26 LANGUAGES C CXX ASM)
27
28# 1. We should be cross-compiling (MPS3 taregt only runs Cortex-M targets)
29if (NOT ${CMAKE_CROSSCOMPILING})
30 message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.")
31endif()
32
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000033# Define target specific base addresses here (before adding the components)
34if (TARGET_SUBSYSTEM STREQUAL sse-300)
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010035 set(UART0_BASE "0x49303000" CACHE STRING "UART base address")
36 set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate")
37 set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)")
38 set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address")
39 set(ETHOS_U_BASE_ADDR "0x58102000" CACHE STRING "Ethos-U NPU base address")
40 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 Sisodiaaa4bcb12022-05-06 09:13:03 +010044 set(DYNAMIC_MODEL_BASE "0x90000000" CACHE STRING "Region to be used for dynamic load of model into memory")
45 set(DYNAMIC_MODEL_SIZE "0x02000000" CACHE STRING "Size of the space reserved for the model")
46
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010047 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
48 set(TA0_BASE "0x58103000" CACHE STRING "Ethos-U NPU timing adapter 0")
49 set(TA1_BASE "0x58103200" CACHE STRING "Ethos-U NPU timing adapter 1")
50 endif()
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000051endif()
52
Kshitij Sisodiaaa4bcb12022-05-06 09:13:03 +010053math(EXPR IFM_BASE "${DYNAMIC_MODEL_BASE} + ${DYNAMIC_MODEL_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
54set(DYNAMIC_IFM_BASE "${IFM_BASE}" CACHE STRING "Base address for IFMs to be loaded")
55set(DYNAMIC_IFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the IFM")
56math(EXPR OFM_BASE "${DYNAMIC_IFM_BASE} + ${DYNAMIC_IFM_SIZE}" OUTPUT_FORMAT HEXADECIMAL)
57set(DYNAMIC_OFM_BASE "${OFM_BASE}" CACHE STRING "Base address for OFMs to be dumped to")
58set(DYNAMIC_OFM_SIZE "0x01000000" CACHE STRING "Size of the space reserved for the OFM")
59
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000060# 2. Create static library
alexander31ae9f02022-02-10 16:15:54 +000061add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
62
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000063## Include directories - private
64target_include_directories(${PLATFORM_DRIVERS_TARGET}
65 PRIVATE
66 source)
67
alexander31ae9f02022-02-10 16:15:54 +000068## Include directories - public
69target_include_directories(${PLATFORM_DRIVERS_TARGET}
70 PUBLIC
71 include
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000072 include/${TARGET_SUBSYSTEM})
alexander31ae9f02022-02-10 16:15:54 +000073
74## Platform sources
75target_sources(${PLATFORM_DRIVERS_TARGET}
76 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000077 source/timer_mps3.c
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000078 source/platform_drivers.c)
79
Isabella Gottardiee4920b2022-02-25 14:29:32 +000080## Directory for additional components required by MPS3:
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000081if (NOT DEFINED COMPONENTS_DIR)
82 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
83endif()
alexander31ae9f02022-02-10 16:15:54 +000084
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000085## Platform component: cmsis_device (provides generic Cortex-M start up library)
86add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000087
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000088## Platform component: stdout
89set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART")
90add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout)
91
92## Platform component: lcd
93add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd)
alexander31ae9f02022-02-10 16:15:54 +000094
Kshitij Sisodiada2ec062022-04-01 14:43:53 +010095## Platform component: PMU
96add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu)
97
Kshitij Sisodiaea8ce562022-04-12 11:10:11 +010098## Logging utilities:
99if (NOT TARGET log)
100 if (NOT DEFINED LOG_PROJECT_DIR)
101 message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.")
102 endif()
103 add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log)
104endif()
105
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000106# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +0000107target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000108 log
109 cmsis_device
Kshitij Sisodiada2ec062022-04-01 14:43:53 +0100110 platform_pmu
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000111 lcd_mps3
112 $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_cmsdk,stdout>)
alexander31ae9f02022-02-10 16:15:54 +0000113
Kshitij Sisodiada2ec062022-04-01 14:43:53 +0100114# Set the CPU profiling definition
115if (CPU_PROFILE_ENABLED)
116 target_compile_definitions(${PLATFORM_DRIVERS_TARGET} PUBLIC CPU_PROFILE_ENABLED)
117endif()
118
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000119# If Ethos-U is enabled, we need the driver library too
120if (ETHOS_U_NPU_ENABLED)
121
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000122 ## Platform component: Ethos-U initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000123 add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000124
125 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
126 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000127 ethos_u_npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000128
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000129 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
130 ## Platform component: Ethos-U timing adapter initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000131 add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000132
133 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
134 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000135 ethos_u_ta)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000136 endif()
137
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000138endif()
139
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +0000140# 3. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000141message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
142message(STATUS "*******************************************************")
143message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
144message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
145message(STATUS "*******************************************************")