blob: e11d9a9c64a5ec93607441f77584dee0328adfb7 [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# A generic (simple) 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 a generic target"
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 values here (before adding the components)
34set(UART0_BASE "0x49303000" CACHE STRING "UART base address")
35set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate")
36set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)")
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000037set(ETHOS_U_BASE_ADDR "0x58102000" CACHE STRING "Ethos-U NPU base address")
38set(ETHOS_U_IRQN "56" CACHE STRING "Ethos-U55 Interrupt")
39set(ETHOS_U_SEC_ENABLED "1" CACHE STRING "Ethos-U NPU Security enable")
40set(ETHOS_U_PRIV_ENABLED "1" CACHE STRING "Ethos-U NPU Privilege enable")
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000041
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000042# 2. Create static library
alexander31ae9f02022-02-10 16:15:54 +000043add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
44
45## Include directories - public
46target_include_directories(${PLATFORM_DRIVERS_TARGET}
47 PUBLIC
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +000048 include)
alexander31ae9f02022-02-10 16:15:54 +000049
50## Platform sources
51target_sources(${PLATFORM_DRIVERS_TARGET}
52 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000053 source/timer_simple_platform.c
54 source/platform_drivers.c)
alexander31ae9f02022-02-10 16:15:54 +000055
Isabella Gottardiee4920b2022-02-25 14:29:32 +000056## Directory for additional components required by generic platform:
57if (NOT DEFINED COMPONENTS_DIR)
58 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
59endif()
60
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000061
62## Platform component: cmsis_device (provides generic Cortex-M start up library)
63add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device)
64
65## Platform component: stdout
66set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART")
67add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout)
68
69## Platform component: lcd
70add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd)
alexander31ae9f02022-02-10 16:15:54 +000071
Isabella Gottardiee4920b2022-02-25 14:29:32 +000072# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +000073target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
74 cmsis_device
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000075 log
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000076 lcd_stubs
77 $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_pl011,stdout>)
alexander31ae9f02022-02-10 16:15:54 +000078
Isabella Gottardiee4920b2022-02-25 14:29:32 +000079# If Ethos-U is enabled, we need the driver library too
80if (ETHOS_U_NPU_ENABLED)
81
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000082 ## Platform component: Ethos-U initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000083 add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000084
85 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
86 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000087 ethos_u_npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000088
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000089 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
90 ## Platform component: Ethos-U timing apadpter initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000091 add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000092
93 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
94 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000095 ethos_u_ta)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000096 endif()
97
Isabella Gottardiee4920b2022-02-25 14:29:32 +000098endif()
99
Kshitij Sisodia8bc863d2022-03-24 17:53:34 +0000100# 3. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000101message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
102message(STATUS "*******************************************************")
103message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
104message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
105message(STATUS "*******************************************************")