blob: df4df00bb9a286ba55986201bb4815dd2af5f307 [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
42# 3. Generate sources:
43if (NOT DEFINED SOURCE_GEN_DIR)
44 set(SOURCE_GEN_DIR ${CMAKE_BINARY_DIR}/generated/bsp)
45endif()
46
47set(MEM_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_memmap.h.template)
48set(IRQ_PROFILE_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/peripheral_irqs.h.template)
49set(MEM_REGIONS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/mem_regions.h.template)
50
51configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h")
52configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
53configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
54
alexander31ae9f02022-02-10 16:15:54 +000055# 4. Create static library
56add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
57
58## Include directories - public
59target_include_directories(${PLATFORM_DRIVERS_TARGET}
60 PUBLIC
61 include
62 ${SOURCE_GEN_DIR})
63
64## Platform sources
65target_sources(${PLATFORM_DRIVERS_TARGET}
66 PRIVATE
67 source/stubs_glcd.c
Kshitij Sisodiaa1256e32022-02-23 14:40:45 +000068 source/timer_simple_platform.c
69 source/platform_drivers.c)
alexander31ae9f02022-02-10 16:15:54 +000070
Isabella Gottardiee4920b2022-02-25 14:29:32 +000071## Directory for additional components required by generic platform:
72if (NOT DEFINED COMPONENTS_DIR)
73 set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components)
74endif()
75
alexander31ae9f02022-02-10 16:15:54 +000076## Platform component: uart
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000077add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart)
alexander31ae9f02022-02-10 16:15:54 +000078
79## Compile defs
80target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
81 PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000082 ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ})
alexander31ae9f02022-02-10 16:15:54 +000083
Isabella Gottardiee4920b2022-02-25 14:29:32 +000084# Add dependencies:
alexander31ae9f02022-02-10 16:15:54 +000085target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
86 cmsis_device
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000087 log
88 ethosu_uart_pl011)
alexander31ae9f02022-02-10 16:15:54 +000089
Isabella Gottardiee4920b2022-02-25 14:29:32 +000090# If Ethos-U is enabled, we need the driver library too
91if (ETHOS_U_NPU_ENABLED)
92
Isabella Gottardiee4920b2022-02-25 14:29:32 +000093 target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
94 PUBLIC
95 ARM_NPU)
96
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +000097 ## Platform component: Ethos-U initialization
98 add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init)
Isabella Gottardiee4920b2022-02-25 14:29:32 +000099
100 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
101 PUBLIC
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000102 ethosu_npu_init_component)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000103
Kshitij Sisodiad5679cc2022-03-03 16:30:07 +0000104 if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
105 ## Platform component: Ethos-U timing apadpter initialization
106 add_subdirectory(${COMPONENTS_DIR}/ethosu_ta_init ${CMAKE_BINARY_DIR}/ethosu_ta_init)
107
108 target_link_libraries(${PLATFORM_DRIVERS_TARGET}
109 PUBLIC
110 ethosu_ta_init_component)
111 target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
112 PUBLIC
113 ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000114 endif()
115
Isabella Gottardiee4920b2022-02-25 14:29:32 +0000116endif()
117
118# 5. Display status:
alexander31ae9f02022-02-10 16:15:54 +0000119message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
120message(STATUS "*******************************************************")
121message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET})
122message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR})
123message(STATUS "*******************************************************")