blob: 8bd51dc6893828d523267fbb8242f1f1c1589574 [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
33# 2. Set the platform cmake descriptor file
34if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE)
35 set(PLATFORM_CMAKE_DESCRIPTOR_FILE
alexandercb8a9872022-02-11 13:23:22 +000036 cmake/subsystem-profiles/${TARGET_SUBSYSTEM}.cmake
alexander31ae9f02022-02-10 16:15:54 +000037 CACHE PATH
38 "Platform's CMake descriptor file path")
39endif()
40
41## Include the platform cmake descriptor file
42include(${PLATFORM_CMAKE_DESCRIPTOR_FILE})
43
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000044# Define target specific base addresses here (before adding the components)
45if (TARGET_SUBSYSTEM STREQUAL sse-300)
46 set(UART0_BASE "0x49303000" CACHE STRING "UART base address")
47 set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate")
48 set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)")
49 set(CLCD_CONFIG_BASE "0x4930A000" CACHE STRING "LCD configuration base address")
50endif()
51
alexander31ae9f02022-02-10 16:15:54 +000052# 3. Generate sources:
53if (NOT DEFINED SOURCE_GEN_DIR)
54 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
55endif()
56
57set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
58set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
59set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
60
61configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
62configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
63configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
64
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000065# Create static library
alexander31ae9f02022-02-10 16:15:54 +000066add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
67
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000068## Include directories - private
69target_include_directories(${PLATFORM_DRIVERS_TARGET}
70 PRIVATE
71 source)
72
alexander31ae9f02022-02-10 16:15:54 +000073## Include directories - public
74target_include_directories(${PLATFORM_DRIVERS_TARGET}
75 PUBLIC
76 include
77 ${SOURCE_GEN_DIR})
78
79## Platform sources
80target_sources(${PLATFORM_DRIVERS_TARGET}
81 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000082 source/timer_mps3.c
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000083 source/platform_drivers.c)
84
85## Compile definitions
86target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
87 PUBLIC
88 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ})
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000089
Isabella Gottardiee4920b2022-02-25 14:29:32 +000090## Directory for additional components required by MPS3:
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000091if (NOT DEFINED COMPONENTS_DIR)
92 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
93endif()
alexander31ae9f02022-02-10 16:15:54 +000094
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000095## Platform component: cmsis_device (provides generic Cortex-M start up library)
96add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000097
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000098## Platform component: stdout
99set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART")
100add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout)
101
102## Platform component: lcd
103add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd)
alexander31ae9f02022-02-10 16:15:54 +0000104
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +0000105# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +0000106target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000107 log
108 cmsis_device
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000109 lcd_mps3
110 $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_cmsdk,stdout>)
alexander31ae9f02022-02-10 16:15:54 +0000111
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000112# If Ethos-U is enabled, we need the driver library too
113if (ETHOS_U_NPU_ENABLED)
114
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000115 ## Platform component: Ethos-U initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000116 add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000117
118 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
119 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000120 ethos_u_npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000121
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000122 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
123 ## Platform component: Ethos-U timing adapter initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000124 add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000125
126 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
127 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000128 ethos_u_ta)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000129 endif()
130
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000131endif()
132
133# 5. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000134message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
135message(STATUS "*******************************************************")
136message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
137message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
138message(STATUS "*******************************************************")