aboutsummaryrefslogtreecommitdiff
path: root/targets
diff options
context:
space:
mode:
authorYulia Garbovich <yulia.garbovich@arm.com>2021-11-23 20:00:04 +0200
committerYulia Garbovich <yulia.garbovich@arm.com>2021-12-14 11:43:57 +0200
commite9cdc6374dc730dc61d2a8a81beabe563ad7fe88 (patch)
treee56813c3fb447cf0bb9200157f802971d6f40be8 /targets
parent29467e04fbc15f53001c0c95227db34160b776e7 (diff)
downloadethos-u-core-platform-e9cdc6374dc730dc61d2a8a81beabe563ad7fe88.tar.gz
Add mpu driver and remove interface library
from drivers Add mpu driver for upstreaming After removing of interface library,targets and applications will list explicitly which libraries to link Change-Id: Icfa449a2981093161f283e45b4d52ca6199371b8
Diffstat (limited to 'targets')
-rw-r--r--targets/common/CMakeLists.txt2
-rw-r--r--targets/corstone-300/CMakeLists.txt10
-rw-r--r--targets/corstone-300/mpu.cpp79
-rw-r--r--targets/corstone-300/mpu.hpp42
-rw-r--r--targets/corstone-300/retarget.c8
-rw-r--r--targets/corstone-300/target.cpp4
-rw-r--r--targets/corstone-300/uart.c145
-rw-r--r--targets/corstone-300/uart.h35
-rw-r--r--targets/corstone-300/uart_config.h23
9 files changed, 14 insertions, 334 deletions
diff --git a/targets/common/CMakeLists.txt b/targets/common/CMakeLists.txt
index 64e1334..d3b3f46 100644
--- a/targets/common/CMakeLists.txt
+++ b/targets/common/CMakeLists.txt
@@ -27,6 +27,8 @@ set(TFLU_BUILD_TYPE "release_with_logs" CACHE STRING "Tensorflow Lite Micro buil
add_subdirectory(${ETHOSU_CORE_SOFTWARE_PATH} core_software)
+add_subdirectory(../../drivers drivers)
+
###############################################################################
# Target
#
diff --git a/targets/corstone-300/CMakeLists.txt b/targets/corstone-300/CMakeLists.txt
index d2e3322..5dc3804 100644
--- a/targets/corstone-300/CMakeLists.txt
+++ b/targets/corstone-300/CMakeLists.txt
@@ -121,12 +121,14 @@ ethosu_target_link_options(ethosu_target_link INTERFACE
# Add drivers
target_sources(ethosu_target_startup INTERFACE
retarget.c
- uart.c
- target.cpp
- mpu.cpp)
+ target.cpp)
target_link_libraries(ethosu_target_startup INTERFACE
- $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver;timing_adapter>)
+ $<$<TARGET_EXISTS:ethosu_core_driver>:ethosu_core_driver>
+ mpu
+ timing_adapter
+ ethosu_mhu_dummy
+ ethosu_uart_cmsdk_apb)
if (TARGET ethosu_core_driver)
target_compile_definitions(ethosu_core_driver PUBLIC
diff --git a/targets/corstone-300/mpu.cpp b/targets/corstone-300/mpu.cpp
deleted file mode 100644
index 1d30ce0..0000000
--- a/targets/corstone-300/mpu.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2020-2021 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
- *
- * 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.
- */
-
-/****************************************************************************
- * Includes
- ****************************************************************************/
-
-#include "mpu.hpp"
-
-#include <cachel1_armv7.h>
-#include <inttypes.h>
-#include <stdio.h>
-
-using namespace std;
-
-/****************************************************************************
- * Functions
- ****************************************************************************/
-
-namespace EthosU {
-namespace Mpu {
-
-void dump() {
-#ifdef ARM_MPU_ARMV8_H
- uint32_t mpuRegions = (MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos;
-
- printf("MPU available with %" PRIu32 " regions.\n", mpuRegions);
-
- printf(" PRIVDEFENA : %lx\n", (MPU->CTRL & MPU_CTRL_PRIVDEFENA_Msk) >> MPU_CTRL_PRIVDEFENA_Pos);
- printf(" HFNMIENA : %lx\n", (MPU->CTRL & MPU_CTRL_HFNMIENA_Msk) >> MPU_CTRL_HFNMIENA_Pos);
- printf(" ENABLE : %lx\n", (MPU->CTRL & MPU_CTRL_ENABLE_Msk) >> MPU_CTRL_ENABLE_Pos);
-
- for (size_t region = 0; region < mpuRegions; region++) {
- MPU->RNR = region;
- printf("-- Region %2d - RBAR:%08" PRIx32 " RLAR:%08" PRIx32 "\n", region, MPU->RBAR, MPU->RLAR);
- }
-#endif
-}
-
-static void initializeAttributes() {
-#ifdef ARM_MPU_ARMV8_H
- /* Initialize attributes corresponding to the enums defined in mpu.hpp */
- const uint8_t WTRA =
- ARM_MPU_ATTR_MEMORY_(1, 0, 1, 0); // Non-transient, Write-Through, Read-allocate, Not Write-allocate
- const uint8_t WBWARA = ARM_MPU_ATTR_MEMORY_(1, 1, 1, 1); // Non-transient, Write-Back, Read-allocate, Write-allocate
-
- ARM_MPU_SetMemAttr(WTRA_index, ARM_MPU_ATTR(WTRA, WTRA));
- ARM_MPU_SetMemAttr(WBWARA_index, ARM_MPU_ATTR(WBWARA, WBWARA));
-#endif
-}
-
-void loadAndEnableConfig(ARM_MPU_Region_t const *table, uint32_t cnt) {
-#ifdef ARM_MPU_ARMV8_H
- initializeAttributes();
-
- ARM_MPU_Load(0, table, cnt);
-
- // Enable MPU with default priv access to all other regions
- ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk);
-#endif
-}
-
-}; // namespace Mpu
-}; // namespace EthosU
diff --git a/targets/corstone-300/mpu.hpp b/targets/corstone-300/mpu.hpp
deleted file mode 100644
index dff73b6..0000000
--- a/targets/corstone-300/mpu.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2020-2021 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
- *
- * 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.
- */
-
-/****************************************************************************
- * Includes
- ****************************************************************************/
-
-#include <cstdint>
-
-/****************************************************************************
- * Types and functions
- ****************************************************************************/
-
-namespace EthosU {
-namespace Mpu {
-
-enum { WTRA_index, WBWARA_index };
-
-/**
- * Dump the MPU tables.
- */
-void dump();
-
-void loadAndEnableConfig(ARM_MPU_Region_t const *table, uint32_t cnt);
-
-}; // namespace Mpu
-}; // namespace EthosU
diff --git a/targets/corstone-300/retarget.c b/targets/corstone-300/retarget.c
index 4bde44d..2549e42 100644
--- a/targets/corstone-300/retarget.c
+++ b/targets/corstone-300/retarget.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <time.h>
-#include "uart.h"
+#include "uart_stdout.h"
// armclang retargeting
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
@@ -206,7 +206,7 @@ void RETARGET(_exit)(int return_code) {
return_code);
while (*p != '\0') {
- uart_putc(*p++);
+ UartPutc(*p++);
}
while (1) {}
@@ -259,12 +259,12 @@ int rename(const char *oldn, const char *newn) {
int fputc(int ch, FILE *f) {
(void)(f);
- return uart_putc(ch);
+ return UartPutc(ch);
}
int fgetc(FILE *f) {
(void)f;
- return uart_putc(uart_getc());
+ return UartPutc(UartGetc());
}
#ifndef ferror
diff --git a/targets/corstone-300/target.cpp b/targets/corstone-300/target.cpp
index 88f98be..87ba0c4 100644
--- a/targets/corstone-300/target.cpp
+++ b/targets/corstone-300/target.cpp
@@ -29,7 +29,7 @@
#include "mpu.hpp"
#include <timing_adapter.h>
-#include "uart.h"
+#include "uart_stdout.h"
#include <inttypes.h>
#include <stdio.h>
@@ -281,7 +281,7 @@ namespace EthosU {
void targetSetup() {
// Initialize UART driver
- uart_init();
+ UartStdOutInit();
// Initialize timing adapter(s)
for (int i = 0; i < ETHOSU_NPU_COUNT; i++) {
diff --git a/targets/corstone-300/uart.c b/targets/corstone-300/uart.c
deleted file mode 100644
index bd7dddf..0000000
--- a/targets/corstone-300/uart.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2019-2021 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
- *
- * 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.
- */
-
-#include "uart.h"
-#include "uart_config.h"
-#include <stdint.h>
-#include <stdio.h>
-
-#define CNTLQ 0x11
-#define CNTLS 0x13
-#define DEL 0x7F
-#define BACKSPACE 0x08
-#define CR 0x0D
-#define LF 0x0A
-#define ESC 0x1B
-
-/*------------- Universal Asynchronous Receiver Transmitter (UART) -----------*/
-
-#define __IO volatile
-#define __I volatile const
-#define __O volatile
-
-typedef struct {
- __IO uint32_t DATA; /* Offset: 0x000 (R/W) Data Register */
- __IO uint32_t STATE; /* Offset: 0x004 (R/W) Status Register */
- __IO uint32_t CTRL; /* Offset: 0x008 (R/W) Control Register */
- union {
- __I uint32_t INTSTATUS; /* Offset: 0x00C (R/ ) Interrupt Status Register */
- __O uint32_t INTCLEAR; /* Offset: 0x00C ( /W) Interrupt Clear Register */
- };
- __IO uint32_t BAUDDIV; /* Offset: 0x010 (R/W) Baudrate Divider Register */
-} CMSDK_UART_TypeDef;
-
-#define CMSDK_UART0_BASE UART0_BASE
-#define CMSDK_UART0 ((CMSDK_UART_TypeDef *)CMSDK_UART0_BASE)
-#define CMSDK_UART0_BAUDRATE UART0_BAUDRATE
-
-void uart_init(void) {
- // SystemCoreClock / 9600
- CMSDK_UART0->BAUDDIV = SYSTEM_CORE_CLOCK / CMSDK_UART0_BAUDRATE;
-
- CMSDK_UART0->CTRL = ((1ul << 0) | /* TX enable */
- (1ul << 1)); /* RX enable */
-}
-
-// Output a character
-unsigned char uart_putc(unsigned char my_ch) {
- while ((CMSDK_UART0->STATE & 1))
- ; // Wait if Transmit Holding register is full
-
- if (my_ch == '\n') {
- CMSDK_UART0->DATA = '\r';
- while ((CMSDK_UART0->STATE & 1))
- ; // Wait if Transmit Holding register is full
- }
-
- CMSDK_UART0->DATA = my_ch; // write to transmit holding register
-
- return (my_ch);
-}
-
-// Get a character
-unsigned char uart_getc(void) {
- unsigned char my_ch;
- // unsigned int cnt;
-
- while ((CMSDK_UART0->STATE & 2) == 0) // Wait if Receive Holding register is empty
- {
-#if 0
- cnt = MPS3_FPGAIO->CLK100HZ / 50;
- if (cnt & 0x8)
- MPS3_FPGAIO->LED = 0x01 << (cnt & 0x7);
- else
- MPS3_FPGAIO->LED = 0x80 >> (cnt & 0x7);
-#endif
- }
-
- my_ch = CMSDK_UART0->DATA;
-
- // Convert CR to LF
- if (my_ch == '\r')
- my_ch = '\n';
-
- return (my_ch);
-}
-
-// Get line from terminal
-unsigned int uart_getline(char *lp, unsigned int len) {
- unsigned int cnt = 0;
- char c;
-
- do {
- c = uart_getc();
- switch (c) {
- case CNTLQ: /* ignore Control S/Q */
- case CNTLS:
- break;
- case BACKSPACE:
- case DEL:
- if (cnt == 0) {
- break;
- }
- cnt--; /* decrement count */
- lp--; /* and line pointer */
- uart_putc(0x08); /* echo backspace */
- uart_putc(' ');
- uart_putc(0x08);
- fflush(stdout);
- break;
- case ESC:
- case 0:
- *lp = 0; /* ESC - stop editing line */
- return 0;
- case CR: /* CR - done, stop editing line */
- *lp = c;
- lp++; /* increment line pointer */
- cnt++; /* and count */
- c = LF;
- __attribute__((fallthrough)); /* intentional fallthrough */
- default:
- uart_putc(*lp = c); /* echo and store character */
- fflush(stdout);
- lp++; /* increment line pointer */
- cnt++; /* and count */
- break;
- }
- } while (cnt < len - 2 && c != LF); /* check limit and CR */
- *lp = 0; /* mark end of string */
- return 1;
-}
diff --git a/targets/corstone-300/uart.h b/targets/corstone-300/uart.h
deleted file mode 100644
index a430e9e..0000000
--- a/targets/corstone-300/uart.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2019-2020 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
- *
- * 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 _UART_STDOUT_H_
-#define _UART_STDOUT_H_
-
-#if __cplusplus
-extern "C" {
-#endif
-
-void uart_init(void);
-unsigned char uart_putc(unsigned char my_ch);
-unsigned char uart_getc(void);
-unsigned int uart_getline(char *lp, unsigned int len);
-
-#if __cplusplus
-}
-#endif
-
-#endif
diff --git a/targets/corstone-300/uart_config.h b/targets/corstone-300/uart_config.h
deleted file mode 100644
index 3df76ab..0000000
--- a/targets/corstone-300/uart_config.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2019-2020 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
- *
- * 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.
- */
-
-#pragma once
-
-#define UART0_BASE 0x49303000
-#define UART0_BAUDRATE 115200
-#define SYSTEM_CORE_CLOCK 25000000