blob: c8d495333715e7c62824ad377cb85833b2425e11 [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
33# 2. Set the platform cmake descriptor file
34if (NOT DEFINED PLATFORM_CMAKE_DESCRIPTOR_FILE)
35 set(PLATFORM_CMAKE_DESCRIPTOR_FILE
36 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/subsystem-profiles/simple_platform.cmake)
37endif()
38
39## Include the platform cmake descriptor file
40include(${PLATFORM_CMAKE_DESCRIPTOR_FILE})
41
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000042# Define target specific values here (before adding the components)
43set(UART0_BASE "0x49303000" CACHE STRING "UART base address")
44set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate")
45set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)")
46set(ACTIVATION_BUF_SRAM_SZ "0x200000" CACHE STRING "Maximum SRAM size for activation buffers")
47
alexander31ae9f02022-02-10 16:15:54 +000048# 3. Generate sources:
49if (NOT DEFINED SOURCE_GEN_DIR)
50 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
51endif()
52
53set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
54set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
55set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
56
57configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
58configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
59configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
60
alexander31ae9f02022-02-10 16:15:54 +000061# 4. Create static library
62add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
63
64## Include directories - public
65target_include_directories(${PLATFORM_DRIVERS_TARGET}
66 PUBLIC
67 include
68 ${SOURCE_GEN_DIR})
69
70## Platform sources
71target_sources(${PLATFORM_DRIVERS_TARGET}
72 PRIVATE
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000073 source/timer_simple_platform.c
74 source/platform_drivers.c)
alexander31ae9f02022-02-10 16:15:54 +000075
Isabella Gottardiee4920b2022-02-25 14:29:32 +000076## Directory for additional components required by generic platform:
77if (NOT DEFINED COMPONENTS_DIR)
78 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
79endif()
80
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +000081
82## Platform component: cmsis_device (provides generic Cortex-M start up library)
83add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device)
84
85## Platform component: stdout
86set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART")
87add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout)
88
89## Platform component: lcd
90add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd)
alexander31ae9f02022-02-10 16:15:54 +000091
92## Compile defs
93target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
94 PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000095 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ})
alexander31ae9f02022-02-10 16:15:54 +000096
Isabella Gottardiee4920b2022-02-25 14:29:32 +000097# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +000098target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
99 cmsis_device
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000100 log
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000101 lcd_stubs
102 $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_pl011,stdout>)
alexander31ae9f02022-02-10 16:15:54 +0000103
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000104# If Ethos-U is enabled, we need the driver library too
105if (ETHOS_U_NPU_ENABLED)
106
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000107 ## Platform component: Ethos-U initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000108 add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000109
110 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
111 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000112 ethos_u_npu)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000113
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000114 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
115 ## Platform component: Ethos-U timing apadpter initialization
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000116 add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta)
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000117
118 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
119 PUBLIC
Kshitij Sisodiac22e80e2022-03-14 09:26:48 +0000120 ethos_u_ta)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000121 endif()
122
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000123endif()
124
125# 5. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000126message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
127message(STATUS "*******************************************************")
128message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
129message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
130message(STATUS "*******************************************************")