summaryrefslogtreecommitdiff
path: root/source/hal/platform/simple
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-03-03 16:30:07 +0000
committerIsabella Gottardi <isabella.gottardi@arm.com>2022-03-04 11:09:15 +0000
commitd5679cc8db0a6ab43369eb91089ea5fe015f552f (patch)
tree4477b3f1e5b5a70066d958d98e61ba6e5a183bb5 /source/hal/platform/simple
parentb4123fd715e41070be5bb39600625c740185f562 (diff)
downloadml-embedded-evaluation-kit-d5679cc8db0a6ab43369eb91089ea5fe015f552f.tar.gz
MLECO-2984: Refactor components
* Use UART component from Ethos-U core-platform * Components as cmake project Change-Id: I053f3a59800abc20216e6a4df8555db357e3f21d Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Diffstat (limited to 'source/hal/platform/simple')
-rw-r--r--source/hal/platform/simple/CMakeLists.txt97
-rw-r--r--source/hal/platform/simple/include/ethosu_mem_config.h58
-rw-r--r--source/hal/platform/simple/source/platform_drivers.c8
3 files changed, 21 insertions, 142 deletions
diff --git a/source/hal/platform/simple/CMakeLists.txt b/source/hal/platform/simple/CMakeLists.txt
index 105fc9b..df4df00 100644
--- a/source/hal/platform/simple/CMakeLists.txt
+++ b/source/hal/platform/simple/CMakeLists.txt
@@ -20,7 +20,7 @@
#########################################################
cmake_minimum_required(VERSION 3.15.6)
-set(PLATFORM_DRIVERS_TARGET platform-drivers)
+set(PLATFORM_DRIVERS_TARGET platform_drivers)
project(${PLATFORM_DRIVERS_TARGET}
DESCRIPTION "Platform drivers library for a generic target"
LANGUAGES C CXX ASM)
@@ -52,13 +52,6 @@ configure_file("${MEM_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_memmap.h"
configure_file("${IRQ_PROFILE_TEMPLATE}" "${SOURCE_GEN_DIR}/peripheral_irqs.h")
configure_file("${MEM_REGIONS_TEMPLATE}" "${SOURCE_GEN_DIR}/mem_regions.h")
-## If a TA config file is provided, we generate a settings file
-if (DEFINED TA_CONFIG_FILE)
- include(${TA_CONFIG_FILE})
- set(TA_SETTINGS_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/timing_adapter_settings.template)
- configure_file("${TA_SETTINGS_TEMPLATE}" "${SOURCE_GEN_DIR}/timing_adapter_settings.h")
-endif()
-
# 4. Create static library
add_library(${PLATFORM_DRIVERS_TARGET} STATIC)
@@ -81,101 +74,45 @@ if (NOT DEFINED COMPONENTS_DIR)
endif()
## Platform component: uart
-target_sources(${PLATFORM_DRIVERS_TARGET}
- PRIVATE
- ${COMPONENTS_DIR}/uart_pl011/uart_pl011.c)
-target_include_directories(${PLATFORM_DRIVERS_TARGET}
- PUBLIC
- ${COMPONENTS_DIR}/uart_pl011/include)
+add_subdirectory(${DEPENDENCY_ROOT_DIR}/core-platform/drivers/uart ${CMAKE_BINARY_DIR}/uart)
## Compile defs
target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
PUBLIC
- ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ}
- $<$<BOOL:TA_CONFIG_FILE>:TIMING_ADAPTER_AVAILABLE>)
+ ACTIVATION_BUF_SRAM_SZ=${ACTIVATION_BUF_SRAM_SZ})
# Add dependencies:
target_link_libraries(${PLATFORM_DRIVERS_TARGET} PUBLIC
cmsis_device
- log)
+ log
+ ethosu_uart_pl011)
# If Ethos-U is enabled, we need the driver library too
if (ETHOS_U_NPU_ENABLED)
- ## Platform component: Ethos-U initialization
- target_sources(${PLATFORM_DRIVERS_TARGET}
- PRIVATE
- ${COMPONENTS_DIR}/ethosu_npu_init/ethosu_npu_init.c)
- target_include_directories(${PLATFORM_DRIVERS_TARGET}
- PUBLIC
- ${COMPONENTS_DIR}/ethosu_npu_init/include)
-
- ## Platform component: Ethos-U timing apadpter initialization
- target_sources(${PLATFORM_DRIVERS_TARGET}
- PRIVATE
- ${COMPONENTS_DIR}/ethosu_ta_init/ethosu_ta_init.c)
- target_include_directories(${PLATFORM_DRIVERS_TARGET}
- PUBLIC
- ${COMPONENTS_DIR}/ethosu_ta_init/include)
-
- if (NOT DEFINED ETHOS_U_NPU_DRIVER_SRC_PATH)
- message(FATAL_ERROR "ETHOS_U_NPU_DRIVER_SRC_PATH should"
- " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
- endif()
-
- # Timing adapter
- if (NOT DEFINED ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH)
- message(FATAL_ERROR "ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH should"
- " be defined when ETHOS_U_NPU_ENABLED=${ETHOS_U_NPU_ENABLED}")
- endif()
-
target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
PUBLIC
ARM_NPU)
- # For the driver, we need to provide the CMSIS_PATH variable
- set(CMSIS_PATH ${CMSIS_SRC_PATH} CACHE PATH "Path to CMSIS directory")
- add_subdirectory(${ETHOS_U_NPU_DRIVER_SRC_PATH} ${CMAKE_BINARY_DIR}/ethos-u-driver)
- add_subdirectory(${ETHOS_U_NPU_TIMING_ADAPTER_SRC_PATH} ${CMAKE_BINARY_DIR}/timing-adapter)
+ ## Platform component: Ethos-U initialization
+ add_subdirectory(${COMPONENTS_DIR}/ethosu_npu_init ${CMAKE_BINARY_DIR}/ethosu_npu_init)
target_link_libraries(${PLATFORM_DRIVERS_TARGET}
PUBLIC
- ethosu_core_driver
- timing_adapter)
+ ethosu_npu_init_component)
- if (NOT DEFINED ETHOS_U_NPU_ID)
- set(ETHOS_U_NPU_ID U55)
- endif()
+ if (ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
+ ## Platform component: Ethos-U timing apadpter initialization
+ add_subdirectory(${COMPONENTS_DIR}/ethosu_ta_init ${CMAKE_BINARY_DIR}/ethosu_ta_init)
- if (NOT DEFINED ETHOS_U_NPU_MEMORY_MODE)
- set(ETHOS_U_NPU_MEMORY_MODE Shared_Sram)
+ target_link_libraries(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ethosu_ta_init_component)
+ target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
+ PUBLIC
+ ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
endif()
- if (ETHOS_U_NPU_MEMORY_MODE STREQUAL Sram_Only)
- if (ETHOS_U_NPU_ID STREQUAL U55)
- set(ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEM_MODE_SRAM_ONLY")
- else ()
- message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode and processor ${ETHOS_U_NPU_MEMORY_MODE} - ${ETHOS_U_NPU_ID}. `sram_only` can be used only for Ethos-U55.")
- endif ()
-
- elseif (ETHOS_U_NPU_MEMORY_MODE STREQUAL Shared_Sram)
- # Shared Sram can be used for Ethos-U55 and Ethos-U65
- set(ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM")
-
- elseif (ETHOS_U_NPU_MEMORY_MODE STREQUAL Dedicated_Sram)
- # Dedicated Sram is used only for Ethos-U65
- if (ETHOS_U_NPU_ID STREQUAL U65)
- list(APPEND ETHOS_U_NPU_MEMORY_MODE_FLAG "-DETHOS_U_NPU_MEMORY_MODE=ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM" "-DETHOS_U_NPU_CACHE_SIZE=${ETHOS_U_NPU_CACHE_SIZE}")
- else ()
- message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode and processor ${ETHOS_U_NPU_MEMORY_MODE} - ${ETHOS_U_NPU_ID}. `dedicated_sram` can be used only for Ethos-U65.")
- endif ()
- else ()
- message(FATAL_ERROR "Non compatible Ethos-U NPU memory mode ${ETHOS_U_NPU_MEMORY_MODE}")
- endif ()
-
- target_compile_definitions(${PLATFORM_DRIVERS_TARGET}
- PUBLIC
- ${ETHOS_U_NPU_MEMORY_MODE_FLAG})
endif()
# 5. Display status:
diff --git a/source/hal/platform/simple/include/ethosu_mem_config.h b/source/hal/platform/simple/include/ethosu_mem_config.h
deleted file mode 100644
index aa0cfda..0000000
--- a/source/hal/platform/simple/include/ethosu_mem_config.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2022 Arm Limited. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ETHOS_U_NPU_MEM_CONFIG_H
-#define ETHOS_U_NPU_MEM_CONFIG_H
-
-#define ETHOS_U_NPU_MEMORY_MODE_SRAM_ONLY 0
-#define ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM 1
-#define ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM 2
-
-#define ETHOS_U_MEM_BYTE_ALIGNMENT 16
-
-#ifndef ETHOS_U_NPU_MEMORY_MODE
- #define ETHOS_U_NPU_MEMORY_MODE ETHOS_U_MEMORY_MODE_SHARED_SRAM
-#endif /* ETHOS_U_NPU_MEMORY_MODE */
-
-#if (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM)
- #ifndef ETHOS_U_NPU_CACHE_SIZE
- #define ETHOS_U_CACHE_BUF_SZ (393216U) /* See vela doc for reference */
- #else
- #define ETHOS_U_CACHE_BUF_SZ ETHOS_U_NPU_CACHE_SIZE
- #endif /* ETHOS_U_NPU_CACHE_SIZE */
-#else
- #define ETHOS_U_CACHE_BUF_SZ (0U)
-#endif /* CACHE_BUF_SZ */
-
-/**
- * Activation buffer aka tensor arena section name
- * We have to place the tensor arena in different region based on the memory config.
- **/
-#if (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_SHARED_SRAM)
- #define ACTIVATION_BUF_SECTION section(".bss.NoInit.activation_buf_sram")
- #define ACTIVATION_BUF_SECTION_NAME ("SRAM")
-#elif (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_SRAM_ONLY)
- #define ACTIVATION_BUF_SECTION section(".bss.NoInit.activation_buf_sram")
- #define ACTIVATION_BUF_SECTION_NAME ("SRAM")
-#elif (ETHOS_U_NPU_MEMORY_MODE==ETHOS_U_NPU_MEMORY_MODE_DEDICATED_SRAM)
- #define ACTIVATION_BUF_SECTION section("activation_buf_dram")
- #define CACHE_BUF_SECTION section(".bss.NoInit.ethos_u_cache")
- #define ACTIVATION_BUF_SECTION_NAME ("DDR/DRAM")
- #define CACHE_BUF_ATTRIBUTE __attribute__((aligned(ETHOS_U_MEM_BYTE_ALIGNMENT), CACHE_BUF_SECTION))
-#endif
-
-#endif /* ETHOS_U_NPU_MEM_CONFIG_H */
diff --git a/source/hal/platform/simple/source/platform_drivers.c b/source/hal/platform/simple/source/platform_drivers.c
index 6a89c61..aae867c 100644
--- a/source/hal/platform/simple/source/platform_drivers.c
+++ b/source/hal/platform/simple/source/platform_drivers.c
@@ -23,9 +23,9 @@
#if defined(ARM_NPU)
#include "ethosu_npu_init.h"
-#if defined(TIMING_ADAPTER_AVAILABLE)
+#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
#include "ethosu_ta_init.h"
-#endif /* TIMING_ADAPTER_AVAILABLE */
+#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */
#endif /* ARM_NPU */
@@ -45,13 +45,13 @@ int platform_init(void)
/* If the platform has timing adapter blocks along with Ethos-U core
* block, initialise them here. */
-#if defined(TIMING_ADAPTER_AVAILABLE)
+#if defined(ETHOS_U_NPU_TIMING_ADAPTER_ENABLED)
int err;
if (0 != (err = arm_ethosu_timing_adapter_init())) {
return err;
}
-#endif /* TIMING_ADAPTER_AVAILABLE */
+#endif /* ETHOS_U_NPU_TIMING_ADAPTER_ENABLED */
/* If Arm Ethos-U NPU is to be used, we initialise it here */
if (0 != (state = arm_ethosu_npu_init())) {