alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 1 | #---------------------------------------------------------------------------- |
| 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 | |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame^] | 22 | cmake_minimum_required(VERSION 3.16.3) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 23 | set(PLATFORM_DRIVERS_TARGET platform_drivers) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 24 | project(${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) |
| 29 | if (NOT ${CMAKE_CROSSCOMPILING}) |
| 30 | message(FATAL_ERROR "No ${PLATFORM_DRIVERS_TARGET} support for this target.") |
| 31 | endif() |
| 32 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 33 | # Define target specific values here (before adding the components) |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 34 | set(UART0_BASE "0x49303000" CACHE STRING "UART base address") |
| 35 | set(UART0_BAUDRATE "115200" CACHE STRING "UART baudrate") |
| 36 | set(SYSTEM_CORE_CLOCK "25000000" CACHE STRING "System peripheral clock (Hz)") |
| 37 | set(ETHOS_U_BASE_ADDR "0x58102000" CACHE STRING "Ethos-U NPU base address") |
| 38 | set(ETHOS_U_IRQN "56" CACHE STRING "Ethos-U55 Interrupt") |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 39 | set(ETHOS_U_SEC_ENABLED "1" CACHE STRING "Ethos-U NPU Security enable") |
| 40 | set(ETHOS_U_PRIV_ENABLED "1" CACHE STRING "Ethos-U NPU Privilege enable") |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 41 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 42 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 43 | set(TA0_BASE "0x58103000" CACHE STRING "Ethos-U NPU timing adapter 0") |
| 44 | set(TA1_BASE "0x58103200" CACHE STRING "Ethos-U NPU timing adapter 1") |
| 45 | endif() |
| 46 | |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 47 | # 2. Create static library |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 48 | add_library(${PLATFORM_DRIVERS_TARGET} STATIC) |
| 49 | |
| 50 | ## Include directories - public |
| 51 | target_include_directories(${PLATFORM_DRIVERS_TARGET} |
| 52 | PUBLIC |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 53 | include) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 54 | |
| 55 | ## Platform sources |
| 56 | target_sources(${PLATFORM_DRIVERS_TARGET} |
| 57 | PRIVATE |
Kshitij Sisodia | a1256e3 | 2022-02-23 14:40:45 +0000 | [diff] [blame] | 58 | source/timer_simple_platform.c |
| 59 | source/platform_drivers.c) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 60 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 61 | ## Directory for additional components required by generic platform: |
| 62 | if (NOT DEFINED COMPONENTS_DIR) |
| 63 | set(COMPONENTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../components) |
| 64 | endif() |
| 65 | |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 66 | |
| 67 | ## Platform component: cmsis_device (provides generic Cortex-M start up library) |
| 68 | add_subdirectory(${COMPONENTS_DIR}/cmsis_device ${CMAKE_BINARY_DIR}/cmsis_device) |
| 69 | |
| 70 | ## Platform component: stdout |
| 71 | set(STDOUT_RETARGET ON CACHE BOOL "Retarget stdout/err to UART") |
| 72 | add_subdirectory(${COMPONENTS_DIR}/stdout ${CMAKE_BINARY_DIR}/stdout) |
| 73 | |
| 74 | ## Platform component: lcd |
| 75 | add_subdirectory(${COMPONENTS_DIR}/lcd ${CMAKE_BINARY_DIR}/lcd) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 76 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 77 | ## Platform component: PMU |
| 78 | add_subdirectory(${COMPONENTS_DIR}/platform_pmu ${CMAKE_BINARY_DIR}/platform_pmu) |
| 79 | |
Kshitij Sisodia | ea8ce56 | 2022-04-12 11:10:11 +0100 | [diff] [blame] | 80 | ## Logging utilities: |
| 81 | if (NOT TARGET log) |
| 82 | if (NOT DEFINED LOG_PROJECT_DIR) |
| 83 | message(FATAL_ERROR "LOG_PROJECT_DIR needs to be defined.") |
| 84 | endif() |
| 85 | add_subdirectory(${LOG_PROJECT_DIR} ${CMAKE_BINARY_DIR}/log) |
| 86 | endif() |
| 87 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 88 | # Add dependencies: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 89 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC |
| 90 | cmsis_device |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 91 | log |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 92 | platform_pmu |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 93 | lcd_stubs |
| 94 | $<IF:$<BOOL:STDOUT_RETARGET>,stdout_retarget_pl011,stdout>) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 95 | |
Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame] | 96 | # Set the CPU profiling definition |
| 97 | if (CPU_PROFILE_ENABLED) |
| 98 | target_compile_definitions(${PLATFORM_DRIVERS_TARGET} PUBLIC CPU_PROFILE_ENABLED) |
| 99 | endif() |
| 100 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 101 | # If Ethos-U is enabled, we need the driver library too |
| 102 | if (ETHOS_U_NPU_ENABLED) |
| 103 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 104 | ## Platform component: Ethos-U initialization |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 105 | add_subdirectory(${COMPONENTS_DIR}/npu ${CMAKE_BINARY_DIR}/npu) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 106 | |
| 107 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} |
| 108 | PUBLIC |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 109 | ethos_u_npu) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 110 | |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 111 | if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED) |
| 112 | ## Platform component: Ethos-U timing apadpter initialization |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 113 | add_subdirectory(${COMPONENTS_DIR}/npu_ta ${CMAKE_BINARY_DIR}/npu_ta) |
Kshitij Sisodia | d5679cc | 2022-03-03 16:30:07 +0000 | [diff] [blame] | 114 | |
| 115 | target_link_libraries(${PLATFORM_DRIVERS_TARGET} |
| 116 | PUBLIC |
Kshitij Sisodia | c22e80e | 2022-03-14 09:26:48 +0000 | [diff] [blame] | 117 | ethos_u_ta) |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 118 | endif() |
| 119 | |
Isabella Gottardi | ee4920b | 2022-02-25 14:29:32 +0000 | [diff] [blame] | 120 | endif() |
| 121 | |
Kshitij Sisodia | 8bc863d | 2022-03-24 17:53:34 +0000 | [diff] [blame] | 122 | # 3. Display status: |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 123 | message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR}) |
| 124 | message(STATUS "*******************************************************") |
| 125 | message(STATUS "Library : " ${PLATFORM_DRIVERS_TARGET}) |
| 126 | message(STATUS "CMAKE_SYSTEM_PROCESSOR : " ${CMAKE_SYSTEM_PROCESSOR}) |
Kshitij Sisodia | 8c61c0a | 2022-05-17 11:16:22 +0100 | [diff] [blame^] | 127 | message(STATUS "CMAKE_SYSTEM_ARCH : " ${CMAKE_SYSTEM_ARCH}) |
alexander | 31ae9f0 | 2022-02-10 16:15:54 +0000 | [diff] [blame] | 128 | message(STATUS "*******************************************************") |