From f376edccb192cb90fccbc0b4e0ef0e0049e7126a Mon Sep 17 00:00:00 2001 From: Matthias Hertel Date: Mon, 13 Nov 2023 15:30:04 +0100 Subject: [PATCH] Build updated base image - OSS mode and new FVP models 11.22.39 --- .gitignore | 1 + docker_base/armgcc_install.sh | 2 +- docker_base/armllvm_install.sh | 2 +- docker_base/avh-fvp_install.sh | 8 +++--- docker_base/cmsistoolbox_install.sh | 8 +++--- docker_licensed/Dockerfile | 8 ++++-- local_build/README.md | 2 +- local_build/build.sh | 43 +++++++++++++++++++++++++++++ local_build/test.sh | 8 ++++++ 9 files changed, 69 insertions(+), 13 deletions(-) create mode 100755 local_build/build.sh create mode 100755 local_build/test.sh diff --git a/.gitignore b/.gitignore index 9bea433..944e0c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store +*.o diff --git a/docker_base/armgcc_install.sh b/docker_base/armgcc_install.sh index 2387e63..b27faa1 100644 --- a/docker_base/armgcc_install.sh +++ b/docker_base/armgcc_install.sh @@ -1,3 +1,3 @@ wget https://artifacts.keil.arm.com/arm-none-eabi-gcc/12.3.1/arm-gnu-toolchain-x86_64-arm-none-eabi.tar.bz2 -nv tar -xf arm-gnu-toolchain-x86_64-arm-none-eabi.tar.bz2 -C /home/arm_mlops_docker -chown -R arm_mlops_docker /home/arm_mlops_docker/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/ \ No newline at end of file +chown -R arm_mlops_docker `/home/arm_mlops_docker/arm-gnu-toolchain-12.3.rel1-x86_64-arm-none-eabi/` \ No newline at end of file diff --git a/docker_base/armllvm_install.sh b/docker_base/armllvm_install.sh index 497bb31..03d9a02 100644 --- a/docker_base/armllvm_install.sh +++ b/docker_base/armllvm_install.sh @@ -1,5 +1,5 @@ wget https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases/download/release-16.0.0/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz -nv tar -xf LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64.tar.gz -C /home/arm_mlops_docker apt install -y libtinfo5 -echo 'export PATH="$PATH:/home/arm_mlops_docker/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin"' >> /home/arm_mlops_docker/.bashrc +#echo 'export "/home/arm_mlops_docker/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64/bin:$PATH"' >> /home/arm_mlops_docker/.bashrc chown -R arm_mlops_docker /home/arm_mlops_docker/LLVMEmbeddedToolchainForArm-16.0.0-Linux-x86_64 \ No newline at end of file diff --git a/docker_base/avh-fvp_install.sh b/docker_base/avh-fvp_install.sh index 0f78551..a444057 100644 --- a/docker_base/avh-fvp_install.sh +++ b/docker_base/avh-fvp_install.sh @@ -1,4 +1,4 @@ -wget https://artifacts.keil.arm.com/avh/11.21.15/avh-fvp-cortex-m-linux-amd64.tar.bz2 -nv -mkdir /home/arm_mlops_docker/avh-fvp-11.21.15 -tar -xvf avh-fvp-cortex-m-linux-amd64.tar.bz2 -C /home/arm_mlops_docker/avh-fvp-11.21.15 -chmod 0755 /home/arm_mlops_docker/avh-fvp-11.21.15 -R +wget https://artifacts.keil.arm.com/avh/11.22.39/avh-fvp-linux-amd64.tar.gz -nv +mkdir /home/arm_mlops_docker/avh-fvp-11.22.39 +tar -xvf avh-fvp-linux-amd64.tar.gz -C /home/arm_mlops_docker/avh-fvp-11.22.39 +chmod 0755 /home/arm_mlops_docker/avh-fvp-11.22.39 -R diff --git a/docker_base/cmsistoolbox_install.sh b/docker_base/cmsistoolbox_install.sh index 76a14b5..1b82ac5 100644 --- a/docker_base/cmsistoolbox_install.sh +++ b/docker_base/cmsistoolbox_install.sh @@ -13,10 +13,10 @@ echo 'export CMSIS_PACK_ROOT=/home/arm_mlops_docker/packs' >> /home/arm_mlops_do echo 'export CMSIS_COMPILER_ROOT=/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/etc' >> /home/arm_mlops_docker/.bashrc echo 'export PATH=/home/arm_mlops_docker/cmake/bin:$PATH' >> /home/arm_mlops_docker/.bashrc echo 'export PATH=/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin:$PATH' >> /home/arm_mlops_docker/.bashrc -echo 'export AC6_TOOLCHAIN_6_20_1=/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin' >> /etc/environment -echo 'export CMSIS_PACK_ROOT=/home/arm_mlops_docker/packs' >> /etc/environment -echo 'export CMSIS_COMPILER_ROOT=/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/etc' >> /etc/environment -echo 'export PATH=/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin:/home/arm_mlops_docker/cmake/bin:/home/arm_mlops_docker/ninja:/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin:$PATH' >> /etc/environment +echo 'AC6_TOOLCHAIN_6_20_1="/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin"' >> /etc/environment +echo 'CMSIS_PACK_ROOT="/home/arm_mlops_docker/packs"' >> /etc/environment +echo 'CMSIS_COMPILER_ROOT="/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/etc"' >> /etc/environment +echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin//home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin:/home/arm_mlops_docker/cmake/bin:/home/arm_mlops_docker/ninja:/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin"' >> /etc/environment export AC6_TOOLCHAIN_6_20_1=/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin export CMSIS_PACK_ROOT=/home/arm_mlops_docker/packs export CMSIS_COMPILER_ROOT=/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/etc diff --git a/docker_licensed/Dockerfile b/docker_licensed/Dockerfile index 2ada5ed..2681404 100644 --- a/docker_licensed/Dockerfile +++ b/docker_licensed/Dockerfile @@ -1,7 +1,11 @@ ARG BASE_IMAGE FROM ${BASE_IMAGE} as base -ADD arm_mlops_docker_license /arm_mlops_docker_license -RUN su -l arm_mlops_docker -c "/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armlm import --file /arm_mlops_docker_license" +ADD arm_mlops_docker_license* /arm_mlops_docker_license* +RUN if [ -f /arm_mlops_docker_license ]; then \ + su -l arm_mlops_docker -c "/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armlm import --file /arm_mlops_docker_license"; \ + else \ + su -l arm_mlops_docker -c "/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armlm activate -product KEMDK-COM0 -server https://mdk-preview.keil.arm.com"; \ + fi FROM base diff --git a/local_build/README.md b/local_build/README.md index 758b6de..4b1745f 100644 --- a/local_build/README.md +++ b/local_build/README.md @@ -19,6 +19,6 @@ To locally build the container onto a desktop machine: - Build an image based on the base image, adding the license. This needs to be rebuild whenever the license expires: \ ``` docker build -t arm-mlops-docker-licensed:latest -f ./docker_licensed/Dockerfile ./docker_licensed --build-arg BASE_IMAGE=arm-mlops-docker-base --platform=linux/amd64 ``` - Run an instance of the image: \ -``` docker run -d --name local_arm_mlops_container -u root -v .:/workspace --platform=linux/amd64 arm-mlops-docker-licensed:latest ``` +``` docker run -d --name local_arm_mlops_container -u root -v .:/workspace --platform=linux/amd64 arm-mlops-docker-licensed:latest sleep infinity ``` - Test if the Arm Compiler can be executed and displays your license: \ ```docker exec local_arm_mlops_container su -l arm_mlops_docker -c "/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armclang --version"``` diff --git a/local_build/build.sh b/local_build/build.sh new file mode 100755 index 0000000..897ae9f --- /dev/null +++ b/local_build/build.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Check if the license code is provided as an argument +LICENSE_CODE=${1:-} + +# Make sure Docker engine is installed +if ! command -v docker &> /dev/null +then + echo "Docker is not installed. Please install Docker and try again." + exit 1 +fi + +# Check if Docker daemon is running +DOCKER_INFO=$(docker info 2>&1) +if [[ $DOCKER_INFO == *"Cannot connect to the Docker daemon"* ]]; then + echo "Docker is not running. Please start Docker and try again." + exit 1 +fi + +# Build the base image +docker build -t arm-mlops-docker-base:latest -f ../docker_base/Dockerfile ../docker_base --platform=linux/amd64 + +# Run an instance of the image in a container +docker run -d --name build_container -u root -v ../:/workspace --platform=linux/amd64 arm-mlops-docker-base:latest sleep infinity + +# If the license code is provided, export it and copy to build folder +if [[ -n "$LICENSE_CODE" ]]; then + docker exec build_container /home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armlm activate --code $LICENSE_CODE --as-user arm_mlops_docker --to-file /workspace/arm_mlops_docker_license + cp ../arm_mlops_docker_license ../docker_licensed/arm_mlops_docker_license +fi + +# Build an image based on the base image, adding the license. This needs to be rebuild whenever the license expires +docker build -t arm-mlops-docker-licensed:latest -f ../docker_licensed/Dockerfile ../docker_licensed --build-arg BASE_IMAGE=arm-mlops-docker-base --platform=linux/amd64 + +# Run an instance of the image +docker run -d --name local_arm_mlops_container -u root -v $(readlink -f ../):/workspace --platform=linux/amd64 arm-mlops-docker-licensed:latest sleep infinity + +# Test if the Arm Compiler can be executed and displays your license +docker exec local_arm_mlops_container su -l arm_mlops_docker -c "/home/arm_mlops_docker/ArmCompilerforEmbedded6.20/bin/armclang --version" + +# Test if a Arm Virtual Hardware FVP can be executed +docker exec local_arm_mlops_container su -l arm_mlops_docker -c "/home/arm_mlops_docker/avh-fvp-11.22.39/avh-linux-x86/bin/FVP_MPS2_Cortex-M33 --version" + diff --git a/local_build/test.sh b/local_build/test.sh new file mode 100755 index 0000000..23ed5d0 --- /dev/null +++ b/local_build/test.sh @@ -0,0 +1,8 @@ +# Test if a project can be compiled and executed +docker exec local_arm_mlops_container wget -P /home/arm_mlops_docker https://github.com/ARM-software/CMSIS_6/releases/download/dev%2Fv6.0.0-dev35/ARM.CMSIS.6.0.0-dev35+geb1d42a.pack -nv +docker exec local_arm_mlops_container su -l arm_mlops_docker -c "/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin/cpackget add ARM.CMSIS.6.0.0-dev35+geb1d42a.pack --agree-embedded-license" +docker exec local_arm_mlops_container wget -P /home/arm_mlops_docker https://github.com/ARM-software/Cortex_DFP/releases/download/dev%2Fv1.0.0-dev15/ARM.Cortex_DFP.1.0.0-dev15+gf6802e4.pack -nv +docker exec local_arm_mlops_container su -l arm_mlops_docker -c "/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin/cpackget add ARM.Cortex_DFP.1.0.0-dev15+gf6802e4.pack --agree-embedded-license" + +docker exec local_arm_mlops_container su - arm_mlops_docker -c "/home/arm_mlops_docker/cmsis-toolbox-linux-amd64/bin/cbuild /workspace/mlek-kws/MLOps.csolution.yml --packs --context +CM4 --toolchain AC6" +docker exec local_arm_mlops_container su - arm_mlops_docker -c "LD_LIBRARY_PATH=/home/arm_mlops_docker/avh-fvp-11.21.15/avh-fvp-cortex-m-linux-amd64/bin/ /home/arm_mlops_docker/avh-fvp-11.22.39/avh-linux-x86/bin/FVP_MPS2_Cortex-M4 -f /workspace/TFLmicrospeech/Target/CM4/fvp_config.txt /workspace/mlek-kws/out/ML_Test/CM4/size/ML_Test.axf --simlimit 12"