From 1ec169b7c9604ff70f873b3393d60cc9cd521678 Mon Sep 17 00:00:00 2001 From: Kshitij Sisodia Date: Wed, 1 Jun 2022 09:06:21 +0100 Subject: MLECO-2968 Create a docker image with all requirements Added a Dockerfile to setup and install requirements for the ml-embedded-evaluation-kit repository. Also included minor change (MLCE-859) for NPU components' source file. Signed-off-by: Matthew Sloyan Change-Id: I621fb2991218a451a0e8c33e14032b9c9e36709e --- Dockerfile | 71 ++++++++++++++++++++++ Readme.md | 1 + docs/sections/building.md | 5 ++ scripts/cmake/cmsis-pack-gen/use-case-api.yml | 2 +- source/hal/source/components/npu/ethosu_npu_init.c | 20 +++--- .../components/npu/include/ethosu_npu_init.h | 6 ++ 6 files changed, 94 insertions(+), 11 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..918f4fa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,71 @@ +# 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. + +FROM ubuntu:20.04 +ENV DEBIAN_FRONTEND noninteractive +ENV EVAL_KIT_DIR "/home/ml-embedded-evaluation-kit" + +RUN apt-get update && \ + apt-get install -y \ + make \ + git \ + python3.8 \ + python3-pip \ + python3.8-dev \ + python3.8-venv \ + unzip \ + curl \ + wget \ + gpg \ + libsndfile1 \ + sudo \ + telnet + +# Download and install gcc 11.2 +RUN curl -L https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi.tar.xz -o gcc-arm-none-eabi.tar.xz && \ + echo "8c5acd5ae567c0100245b0556941c237369f210bceb196edfe5a2e7532c60326 gcc-arm-none-eabi.tar.xz" | sha256sum -c && \ + mkdir /opt/gcc-arm-none-eabi && \ + tar -xf gcc-arm-none-eabi.tar.xz -C /opt/gcc-arm-none-eabi --strip-components 1 && \ + rm gcc-arm-none-eabi.tar.xz + +# Download and install the Corstone_SSE-300 FVP +RUN wget https://developer.arm.com/-/media/Arm%20Developer%20Community/Downloads/OSS/FVP/Corstone-300/FVP_Corstone_SSE-300_11.16_26.tgz 2>/dev/null && \ + echo "e26139be756b5003a30d978c629de638aed1934d597dc24a17043d4708e934d7 FVP_Corstone_SSE-300_11.16_26.tgz" | sha256sum -c && \ + mkdir -p /home/FVP_Corstone_SSE-300/ && \ + tar -xf FVP_Corstone_SSE-300_11.16_26.tgz -C /home/FVP_Corstone_SSE-300/ && \ + bash /home/FVP_Corstone_SSE-300/FVP_Corstone_SSE-300.sh --no-interactive --i-agree-to-the-contained-eula -d /home/FVP_Corstone_SSE-300 && \ + rm FVP_Corstone_SSE-300_11.16_26.tgz + +# Clone the ml-embedded-evaluation-kit repository +RUN git clone "https://review.mlplatform.org/ml/ethos-u/ml-embedded-evaluation-kit" ${EVAL_KIT_DIR} + +# Change working directory +WORKDIR ${EVAL_KIT_DIR} + +# Initialize submodules +RUN git submodule update --init + +# Download and install resources required for ml-embedded-evaluation-kit +RUN python3 ./set_up_default_resources.py + +# Update PATH to make the required version of CMake and GNU embedded toolchain is available: +ENV PATH="${EVAL_KIT_DIR}/resources_downloaded/env/bin:/opt/gcc-arm-none-eabi/bin:${PATH}" + +# FVP binary paths: +ENV FVP_ETHOS_U55="/home/FVP_Corstone_SSE-300/models/Linux64_GCC-6.4/FVP_Corstone_SSE-300_Ethos-U55" +ENV FVP_ETHOS_U65="/home/FVP_Corstone_SSE-300/models/Linux64_GCC-6.4/FVP_Corstone_SSE-300_Ethos-U65" + +# Default FVP arguments for no GUI and telnet pop ups: +ENV FVP_ARGS="-C mps3_board.telnetterminal0.start_telnet=0 -C mps3_board.uart0.out_file='-' -C mps3_board.uart0.shutdown_on_eot=1 -C mps3_board.visualisation.disable-visualisation=1" diff --git a/Readme.md b/Readme.md index 4d6e03c..fd3a67c 100644 --- a/Readme.md +++ b/Readme.md @@ -99,6 +99,7 @@ could be used in all tools/IDEs (for example, To run an ML application on the Cortex-M and Ethos-U NPU, please, follow these steps: 1. Set up your environment by installing [the required prerequisites](./docs/sections/building.md#Build-prerequisites). +> **NOTE**: A Docker image built from the `Dockerfile` provided will have all the required packages installed. 2. Generate an optimized neural network model for Ethos-U with a Vela compiler by following instructions [here](./docs/sections/building.md#Add-custom-model). 3. [Configure the build system](./docs/sections/building.md#Build-process). 4. [Compile the project](./docs/sections/building.md#Building-the-configured-project) with a `make` command. diff --git a/docs/sections/building.md b/docs/sections/building.md index 6c02b10..69ba0e2 100644 --- a/docs/sections/building.md +++ b/docs/sections/building.md @@ -134,6 +134,11 @@ Before proceeding, it is *essential* to ensure that the following prerequisites *Ethos™-U55* NPU driver, and CMSIS. Instructions for downloading these are listed under: [preparing build environment](./building.md#preparing-build-environment). +> **NOTE**: A Docker image built from the `Dockerfile` provided will have all the above packages installed and +> available for use. The GNU Embedded toolchain is available by default and the environment of the image will +> have certain helper variables set for running the FVP within a non-interactive terminal. Run `env` to see the +> list. + ### Third-party build prerequisites - The following software is needed by TensorFlow Lite Micro. diff --git a/scripts/cmake/cmsis-pack-gen/use-case-api.yml b/scripts/cmake/cmsis-pack-gen/use-case-api.yml index fb0cbd9..a6b71b1 100644 --- a/scripts/cmake/cmsis-pack-gen/use-case-api.yml +++ b/scripts/cmake/cmsis-pack-gen/use-case-api.yml @@ -25,7 +25,7 @@ # # ml-embedded-eval-kit $ packgen -s ./ \ # Source dir (run this from repo root) # -v ./scripts/cmake/cmsis-pack-gen/use-case-api.yml \ # This file's path -# -o /ml-embedded-eval-kit-pack \ # Where to generate the ouput +# -o /ml-embedded-eval-kit-pack \ # Where to generate the output # -i /tensorflow.tensorflow-lite-micro.pdsc \ # Tensorflow packs' PDSC file # -i /ARM.CMSIS.pdsc \ # CMSIS packs' PDSC file # diff --git a/source/hal/source/components/npu/ethosu_npu_init.c b/source/hal/source/components/npu/ethosu_npu_init.c index e24ddd9..701b5de 100644 --- a/source/hal/source/components/npu/ethosu_npu_init.c +++ b/source/hal/source/components/npu/ethosu_npu_init.c @@ -45,16 +45,6 @@ static size_t get_cache_arena_size() #endif /* defined (ETHOS_U_CACHE_BUF_SZ) && (ETHOS_U_CACHE_BUF_SZ > 0) */ } -/** - * @brief Defines the Ethos-U interrupt handler: just a wrapper around the default - * implementation. - **/ -static void arm_ethosu_npu_irq_handler(void) -{ - /* Call the default interrupt handler from the NPU driver */ - ethosu_irq_handler(ðosu_drv); -} - /** * @brief Initialises the NPU IRQ **/ @@ -73,6 +63,16 @@ static void arm_ethosu_npu_irq_init(void) ethosu_irqnum, arm_ethosu_npu_irq_handler); } +/** + * @brief Defines the Ethos-U interrupt handler: just a wrapper around the default + * implementation. + **/ +void arm_ethosu_npu_irq_handler(void) +{ + /* Call the default interrupt handler from the NPU driver */ + ethosu_irq_handler(ðosu_drv); +} + int arm_ethosu_npu_init(void) { int err = 0; diff --git a/source/hal/source/components/npu/include/ethosu_npu_init.h b/source/hal/source/components/npu/include/ethosu_npu_init.h index c562f6c..d1c3992 100644 --- a/source/hal/source/components/npu/include/ethosu_npu_init.h +++ b/source/hal/source/components/npu/include/ethosu_npu_init.h @@ -25,6 +25,12 @@ **/ int arm_ethosu_npu_init(void); +/** + * @brief Defines the Arm Ethos-U NPU interrupt handler: just a wrapper + * around the default implementation. + **/ +void arm_ethosu_npu_irq_handler(void); + #endif /* ARM_NPU */ #endif /* ETHOS_U_NPU_INIT_H */ -- cgit v1.2.1