diff --git a/.ci/docker/common/install_zephyr.sh b/.ci/docker/common/install_zephyr.sh index 99d5cc40016..c24bb5aa8f1 100644 --- a/.ci/docker/common/install_zephyr.sh +++ b/.ci/docker/common/install_zephyr.sh @@ -8,6 +8,9 @@ set -ex +# shellcheck source=/dev/null +source "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + # Double check if the NDK version is set [ -n "${ZEPHYR_SDK}" ] @@ -77,16 +80,8 @@ install_prerequiresites() { chmod +x kitware-archive.sh && \ ./kitware-archive.sh && \ rm -f kitware-archive.sh - useradd -d /home/zephyruser -m -s /bin/bash zephyruser -} - -install_sdk() { - wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \ - tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \ - rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz && \ - cd zephyr-sdk-0.16.0/ && \ - ./setup.sh -c -t arm-zephyr-eabi + pip_install --no-cache-dir west + pip_install pyelftools } install_prerequiresites -install_sdk diff --git a/.ci/docker/ubuntu/Dockerfile b/.ci/docker/ubuntu/Dockerfile index 324d41d4f23..fddd7e6df36 100644 --- a/.ci/docker/ubuntu/Dockerfile +++ b/.ci/docker/ubuntu/Dockerfile @@ -86,8 +86,9 @@ ARG ARM_SDK ARG ZEPHYR_SDK COPY ./common/install_zephyr.sh install_zephyr.sh +COPY ./common/utils.sh utils.sh RUN if [ -n "${ZEPHYR_SDK}" ]; then bash ./install_zephyr.sh; fi -RUN rm install_zephyr.sh +RUN rm install_zephyr.sh utils.sh ARG QNN_SDK diff --git a/.ci/scripts/zephyr-utils.sh b/.ci/scripts/zephyr-utils.sh new file mode 100644 index 00000000000..2b36c6b0427 --- /dev/null +++ b/.ci/scripts/zephyr-utils.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +download_arm_zephyr_sdk () { + wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.0/zephyr-sdk-0.16.0_linux-x86_64.tar.xz + tar -xf zephyr-sdk-0.16.0_linux-x86_64.tar.xz + rm -f zephyr-sdk-0.16.0_linux-x86_64.tar.xz +} + +setup_zephyr_et_module () { + git clone --branch executorch-module-integration https://github.com/BujSet/zephyr.git + west init -l zephyr + west config manifest.project-filter -- +executorch + west -v update +} diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 90120885efb..e90ede58f40 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -55,6 +55,49 @@ jobs: # Build and test executorch PYTHON_EXECUTABLE=python ${CONDA_RUN} bash .ci/scripts/test_model.sh "${MODEL_NAME}" "${BUILD_TOOL}" "${BACKEND}" + test-models-arm-zephyr: + name: test-models-arm-zephyr + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + strategy: + matrix: + model: [add] + fail-fast: false + with: + runner: linux.2xlarge + docker-image: ci-image:executorch-ubuntu-22.04-zephyr-sdk + submodules: 'recursive' + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + timeout: 120 + script: | + MODEL_NAME=${{ matrix.model }} + CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]") + conda activate "${CONDA_ENV}" + + source .ci/scripts/utils.sh + source .ci/scripts/zephyr-utils.sh + mkdir -p zephyr_scratch/ + cd zephyr_scratch + export ZEPHYR_PROJ_ROOT=$(realpath $(pwd)) + + download_arm_zephyr_sdk + ./zephyr-sdk-0.16.0/setup.sh -c -t arm-zephyr-eabi + + cd $ZEPHYR_PROJ_ROOT + setup_zephyr_et_module + + cd $ZEPHYR_PROJ_ROOT/modules/lib/executorch + install_executorch "--use-pt-pinned-commit" + .ci/scripts/setup-arm-baremetal-tools.sh --target-toolchain zephyr + source examples/arm/ethos-u-scratch/setup_path.sh + source $ZEPHYR_PROJ_ROOT/zephyr/zephyr-env.sh + cd $ZEPHYR_PROJ_ROOT/zephyr/samples/modules/executorch/arm/hello_world + west build -p always -b mps3/corstone300/fvp + FVP_Corstone_SSE-300_Ethos-U55 -a build/zephyr/zephyr.elf -C mps3_board.visualisation.disable-visualisation=1 -C mps3_board.telnetterminal0.start_telnet=0 -C mps3_board.uart0.out_file='sim.out' -C cpu0.CFGITCMSZ=15 -C cpu0.CFGDTCMSZ=15 --simlimit 120 + + grep -qF "Output[0][0]: (float) 2.000000" sim.out + exit_status=$? #store 0 if found (success), 1 if not (failure) + exit $exit_status + test-models-linux-aarch64: name: test-models-linux-aarch64 uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main