This is an automated email from the ASF dual-hosted git repository.

areusch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 58a85b80ed [docker][RVM][microtvm] Refactor CMSIS installation to add 
to RVM (#11148)
58a85b80ed is described below

commit 58a85b80ed0387c1964e6a76e7db3f79d1d11034
Author: Mehrdad Hessar <[email protected]>
AuthorDate: Tue May 3 11:00:24 2022 -0700

    [docker][RVM][microtvm] Refactor CMSIS installation to add to RVM (#11148)
    
    * Refactor CMSIS installation for RVM
    
    * Fix `ethosu_dir` existing directory
    
    * Address Andrew comment
---
 apps/microtvm/reference-vm/base-box-tool.py        |  1 +
 .../zephyr/base-box/base_box_provision.sh          |  6 +++-
 .../reference-vm/zephyr/provision_setup.sh         |  1 +
 docker/Dockerfile.ci_cpu                           |  5 +++
 docker/Dockerfile.ci_qemu                          |  5 +++
 .../install/ubuntu_install_cmsis.sh                | 40 +++++++++++++++-------
 .../install/ubuntu_install_ethosu_driver_stack.sh  | 11 ++----
 7 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/apps/microtvm/reference-vm/base-box-tool.py 
b/apps/microtvm/reference-vm/base-box-tool.py
index 839a513a5e..a4777c3ff8 100755
--- a/apps/microtvm/reference-vm/base-box-tool.py
+++ b/apps/microtvm/reference-vm/base-box-tool.py
@@ -57,6 +57,7 @@ EXTRA_SCRIPTS = {
     "zephyr": (
         "docker/install/ubuntu_init_zephyr_project.sh",
         "docker/install/ubuntu_install_zephyr_sdk.sh",
+        "docker/install/ubuntu_install_cmsis.sh",
     ),
 }
 
diff --git a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh 
b/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
index 7d54663114..2c55312f36 100644
--- a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
+++ b/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
@@ -29,5 +29,9 @@ source ~/.profile
 cd ~
 ~/ubuntu_init_zephyr_project.sh ~/zephyr
 
+# Install CMSIS
+cd ~
+~/ubuntu_install_cmsis.sh ~/cmsis
+
 # Cleanup
-rm -f ubuntu_init_zephyr_project.sh
+rm -f ubuntu_init_zephyr_project.sh ubuntu_install_cmsis.sh
diff --git a/apps/microtvm/reference-vm/zephyr/provision_setup.sh 
b/apps/microtvm/reference-vm/zephyr/provision_setup.sh
index e1f3bef755..6771460dc9 100644
--- a/apps/microtvm/reference-vm/zephyr/provision_setup.sh
+++ b/apps/microtvm/reference-vm/zephyr/provision_setup.sh
@@ -49,3 +49,4 @@ echo "export 
TVM_LIBRARY_PATH=\"$TVM_HOME\"/build-microtvm-${platform}" >>~/.pro
 echo "VENV_PATH=\$((cd \"$TVM_HOME\"/apps/microtvm/reference-vm/zephyr && 
poetry env list --full-path) | sed -E 
's/^(.*)[[:space:]]\(Activated\)\$/\1/g')" >>~/.profile
 echo "source \$VENV_PATH/bin/activate" >>~/.profile
 echo "export 
PATH=\"\${PATH}:\${HOME}/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin\"" 
>>~/.profile
+echo "export CMSIS_PATH=\"\${HOME}/cmsis\"" >>~/.profile
diff --git a/docker/Dockerfile.ci_cpu b/docker/Dockerfile.ci_cpu
index 92bf949ef6..4c194600a1 100644
--- a/docker/Dockerfile.ci_cpu
+++ b/docker/Dockerfile.ci_cpu
@@ -122,6 +122,11 @@ RUN bash /install/ubuntu_install_androidsdk.sh
 ENV ANDROID_HOME=/opt/android-sdk-linux/
 ENV ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/21.3.6528147/
 
+# Install CMSIS_NN
+COPY install/ubuntu_install_cmsis.sh /install/ubuntu_install_cmsis.sh
+RUN bash /install/ubuntu_install_cmsis.sh /opt/arm/ethosu/cmsis
+ENV CMSIS_PATH=/opt/arm/ethosu/cmsis/
+
 # Arm(R) Ethos(TM)-U NPU driver
 COPY install/ubuntu_install_ethosu_driver_stack.sh 
/install/ubuntu_install_ethosu_driver_stack.sh
 RUN bash /install/ubuntu_install_ethosu_driver_stack.sh
diff --git a/docker/Dockerfile.ci_qemu b/docker/Dockerfile.ci_qemu
index ff2805fe50..8173003190 100644
--- a/docker/Dockerfile.ci_qemu
+++ b/docker/Dockerfile.ci_qemu
@@ -94,6 +94,11 @@ RUN bash /install/ubuntu_install_arduino.sh
 COPY install/ubuntu_install_onnx.sh /install/ubuntu_install_onnx.sh
 RUN bash /install/ubuntu_install_onnx.sh
 
+# Install CMSIS_NN
+COPY install/ubuntu_install_cmsis.sh /install/ubuntu_install_cmsis.sh
+RUN bash /install/ubuntu_install_cmsis.sh /opt/arm/ethosu/cmsis
+ENV CMSIS_PATH=/opt/arm/ethosu/cmsis/
+
 # Arm(R) Ethos(TM)-U NPU driver
 COPY install/ubuntu_install_ethosu_driver_stack.sh 
/install/ubuntu_install_ethosu_driver_stack.sh
 RUN bash /install/ubuntu_install_ethosu_driver_stack.sh
diff --git a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh 
b/docker/install/ubuntu_install_cmsis.sh
old mode 100644
new mode 100755
similarity index 54%
copy from apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
copy to docker/install/ubuntu_install_cmsis.sh
index 7d54663114..152e3ff327
--- a/apps/microtvm/reference-vm/zephyr/base-box/base_box_provision.sh
+++ b/docker/install/ubuntu_install_cmsis.sh
@@ -1,4 +1,4 @@
-#!/bin/bash -e
+#!/bin/bash
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
 # distributed with this work for additional information
@@ -15,19 +15,35 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
-#   Using this script we can reuse docker/install scripts to configure the 
reference 
-#   virtual machine similar to CI QEMU setup.
-#
 
 set -e
-set -x
+set -u
+set -o pipefail
+
+function show_usage() {
+    cat <<EOF
+Usage: docker/install/ubuntu_install_cmsis.sh <INSTALLATION_PATH>
+INSTALLATION_PATH is the installation path for the CMSIS.
+EOF
+}
+
+if [ "$#" -lt 1 -o "$1" == "--help" -o "$1" == "-h" ]; then
+    show_usage
+    exit -1
+fi
+
+INSTALLATION_PATH=$1
+shift
+
+CMSIS_VER="5.8.0"
 
-source ~/.profile
+# Create installation path directory
+mkdir -p "${INSTALLATION_PATH}"
 
-# Init Zephyr
-cd ~
-~/ubuntu_init_zephyr_project.sh ~/zephyr
+# Download and extract CMSIS
+cd "${HOME}"
+wget --quiet 
"https://github.com/ARM-software/CMSIS_5/archive/${CMSIS_VER}.tar.gz";
+tar -xf "${CMSIS_VER}.tar.gz" -C "${INSTALLATION_PATH}" --strip-components=1
 
-# Cleanup
-rm -f ubuntu_init_zephyr_project.sh
+# Remove tar file
+rm -f "${CMSIS_VER}.tar.gz"
diff --git a/docker/install/ubuntu_install_ethosu_driver_stack.sh 
b/docker/install/ubuntu_install_ethosu_driver_stack.sh
index 265b8cc6d6..cbb55c9c0d 100755
--- a/docker/install/ubuntu_install_ethosu_driver_stack.sh
+++ b/docker/install/ubuntu_install_ethosu_driver_stack.sh
@@ -24,7 +24,6 @@ fvp_dir="/opt/arm/FVP_Corstone_SSE-300"
 cmake_dir="/opt/arm/cmake"
 ethosu_dir="/opt/arm/ethosu"
 ethosu_driver_ver="21.11"
-cmsis_ver="5.8.0"
 
 mkdir -p /opt/arm
 
@@ -76,7 +75,7 @@ curl --retry 64 -sSL ${gcc_arm_url} | tar -C 
/opt/arm/gcc-arm-none-eabi --strip-
 export PATH="/opt/arm/gcc-arm-none-eabi/bin:${PATH}"
 
 # Clone Arm(R) Ethos(TM)-U NPU driver stack
-mkdir "${ethosu_dir}"
+mkdir -p "${ethosu_dir}"
 cd "${ethosu_dir}"
 git clone "https://review.mlplatform.org/ml/ethos-u/ethos-u-core-driver"; 
core_driver
 cd core_driver
@@ -87,18 +86,12 @@ git clone 
"https://review.mlplatform.org/ml/ethos-u/ethos-u-core-platform"; core_
 cd core_platform
 git checkout tags/${ethosu_driver_ver}
 
-# Clone CMSIS
-cd "${ethosu_dir}"
-git clone "https://github.com/ARM-software/CMSIS_5.git"; cmsis
-cd cmsis
-git checkout -f tags/${cmsis_ver}
-
 # Build Driver
 mkdir ${ethosu_dir}/core_driver/build && cd ${ethosu_dir}/core_driver/build
 cmake 
-DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake
 -DETHOSU_LOG_SEVERITY=debug -DTARGET_CPU=cortex-m55 ..
 make
 
 # Build NN Library
-mkdir ${ethosu_dir}/cmsis/CMSIS/NN/build/ && cd 
${ethosu_dir}/cmsis/CMSIS/NN/build/
+mkdir ${CMSIS_PATH}/CMSIS/NN/build/ && cd ${CMSIS_PATH}/CMSIS/NN/build/
 cmake .. 
-DCMAKE_TOOLCHAIN_FILE=${ethosu_dir}/core_platform/cmake/toolchain/arm-none-eabi-gcc.cmake
 -DTARGET_CPU=cortex-m55 -DBUILD_CMSIS_NN_FUNCTIONS=YES
 make

Reply via email to