Skip to content

Commit 952b35d

Browse files
authored
Add CI on Zephyr (#4336)
to run product-mini/platforms/zephyr/simple and product-mini/platforms/zephyr/user-mode Construct a T2 (star topology) for the current smoke test. This is not the final topology, and we may modify it once we determine the optimal configuration.
1 parent e4d2673 commit 952b35d

File tree

4 files changed

+203
-26
lines changed

4 files changed

+203
-26
lines changed

.github/scripts/run_qemu_arc.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
# THIS SCRIPT IS USED TO RUN QEMU ARC EMULATOR DIRECTLY ON CI ONLY.
4+
# USUALLY, you SHOULD NOT RUN IT ON YOUR LOCAL MACHINE.
5+
# INSTEAD, YOU SHOULD USE `west build -t run` COMMAND.
6+
7+
# Two arguments. first is the path to the zephyr-sdk, second is the path to the zephyr elf.
8+
if [ "$#" -ne 2 ]; then
9+
echo "Usage: $0 <path_to_zephyr_sdk> <path_to_zephyr_elf>"
10+
exit 1
11+
fi
12+
13+
ZEPHYR_SDK_PATH=$1
14+
ZEPHYR_ELF_PATH=$2
15+
16+
if [ ! -d "$ZEPHYR_SDK_PATH" ]; then
17+
echo "Error: Zephyr SDK path does not exist: $ZEPHYR_SDK_PATH"
18+
exit 1
19+
fi
20+
if [ ! -f "$ZEPHYR_ELF_PATH" ]; then
21+
echo "Error: Zephyr ELF file does not exist: $ZEPHYR_ELF_PATH"
22+
exit 1
23+
fi
24+
25+
# this command is copied from the content of build.ninja which is generated by west build.
26+
# please do not modify it unless synchronizing with the build.ninja file.
27+
$ZEPHYR_SDK_PATH/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-arc \
28+
-cpu arcem -m 8M \
29+
-nographic -no-reboot -monitor none \
30+
-global cpu.firq=false \
31+
-global cpu.num-irqlevels=15 \
32+
-global cpu.num-irq=25 \
33+
-global cpu.ext-irq=20 \
34+
-global cpu.freq_hz=10000000 \
35+
-global cpu.timer0=true \
36+
-global cpu.timer1=true \
37+
-global cpu.has-mpu=true \
38+
-global cpu.mpu-numreg=16 \
39+
-net none \
40+
-pidfile qemu.pid \
41+
-chardev stdio,id=con,mux=on \
42+
-serial chardev:con \
43+
-mon chardev=con,mode=readline \
44+
-icount shift=6,align=off,sleep=off \
45+
-rtc clock=vm \
46+
-kernel $ZEPHYR_ELF_PATH
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
name: compilation on zephyr
5+
6+
on:
7+
# will be triggered on PR events
8+
pull_request:
9+
types:
10+
- opened
11+
- synchronize
12+
paths:
13+
- ".github/**"
14+
- "build-scripts/**"
15+
- "core/**"
16+
- "!core/deps/**"
17+
- "product-mini/platforms/common/**"
18+
- "product-mini/platforms/zephyr/**"
19+
- "samples/**"
20+
- "!samples/workload/**"
21+
- "tests/wamr-test-suites/**"
22+
- "wamr-compiler/**"
23+
# will be triggered on push events
24+
push:
25+
branches:
26+
- main
27+
- "dev/**"
28+
paths:
29+
- ".github/**"
30+
- "build-scripts/**"
31+
- "core/**"
32+
- "!core/deps/**"
33+
- "product-mini/platforms/common/**"
34+
- "product-mini/platforms/zephyr/**"
35+
- "samples/**"
36+
- "!samples/workload/**"
37+
- "tests/wamr-test-suites/**"
38+
- "wamr-compiler/**"
39+
# allow to be triggered manually
40+
workflow_dispatch:
41+
42+
# Cancel any in-flight jobs for the same PR/branch so there's only one active
43+
# at a time
44+
concurrency:
45+
group: ${{ github.workflow }}-${{ github.ref }}
46+
cancel-in-progress: true
47+
48+
env:
49+
# FOR SETUP
50+
ZEPHYR_SDK_VERSION: "0.16.9"
51+
ZEPHYR_VERSION: "v3.7.0"
52+
# FOR BUILD
53+
54+
permissions:
55+
contents: read
56+
57+
jobs:
58+
smoke_test:
59+
runs-on: ubuntu-22.04
60+
container:
61+
# For Zephyr 3.7 LTS, use the v0.26-branch or the latest v0.26.x release Docker image.
62+
# ci require a larger runner to avoid "no space left on device"
63+
image: ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
64+
options: --user root
65+
66+
steps:
67+
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
68+
# zephyrproject/ --> CI ROOT
69+
# ├─── .west/
70+
# │ └─── config
71+
# ├─── bootloader/
72+
# ├─── zephyr/ --> Zephyr source code
73+
# ├─── zephyr-sdk/
74+
# ├─── modules/
75+
# │ |─── wasm-micro-runtime --> WAMR source code
76+
# ├─── tools/
77+
# ├─── vendor/
78+
# └─── application/ --> DUMMY. keep west_lite.yml here
79+
80+
- name: Checkout code
81+
uses: actions/checkout@v3
82+
with:
83+
path: modules/wasm-micro-runtime
84+
85+
- name: Prepare Zephyr environment
86+
shell: bash
87+
run: |
88+
mkdir -p application
89+
cp modules/wasm-micro-runtime/product-mini/platforms/zephyr/simple/west_lite.yml application/west_lite.yml
90+
91+
- name: Setup Zephyr project
92+
uses: zephyrproject-rtos/action-zephyr-setup@v1
93+
with:
94+
app-path: application
95+
manifest-file-name: west_lite.yml
96+
sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
97+
toolchains: arc-zephyr-elf:arc64-zephyr-elf
98+
99+
- name: Build a sample application(simple)
100+
shell: bash
101+
run: |
102+
pushd product-mini/platforms/zephyr/simple
103+
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
104+
popd
105+
106+
# west build -t run will fork several processes, which will cause the job to hang.
107+
# run in the background and kill it after 5 seconds
108+
.github/scripts/run_qemu_arc.sh \
109+
../../zephyr-sdk \
110+
product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
111+
sleep 5
112+
pkill qemu-system-arc
113+
working-directory: modules/wasm-micro-runtime
114+
115+
- name: Build a sample application(user-mode)
116+
shell: bash
117+
run: |
118+
pushd product-mini/platforms/zephyr/user-mode
119+
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
120+
popd
121+
122+
# west build -t run will fork several processes, which will cause the job to hang.
123+
# run in the background and kill it after 5 seconds
124+
.github/scripts/run_qemu_arc.sh \
125+
../../zephyr-sdk \
126+
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
127+
sleep 5
128+
pkill qemu-system-arc
129+
working-directory: modules/wasm-micro-runtime

product-mini/platforms/zephyr/simple/Dockerfile

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,54 @@
33

44
# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html
55
# for more information on how to set up the Zephyr development environment.
6-
FROM ubuntu:22.04
6+
7+
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
8+
# zephyrproject/ --> CI ROOT
9+
# ├─── .west/
10+
# │ └─── config
11+
# ├─── bootloader/
12+
# ├─── zephyr/ --> Zephyr source code
13+
# ├─── zephyr-sdk/
14+
# ├─── modules/
15+
# │ |─── wasm-micro-runtime --> WAMR source code
16+
# ├─── tools/
17+
# ├─── vendor/
18+
# └─── application/ --> DUMMY. keep west_lite.yml here
19+
20+
# If you modify this file, you may need to sync the modifications to the
21+
# .github/actions/setup-zephyr/action.yml
22+
FROM ghcr.io/zephyrproject-rtos/ci-base:v0.26-branch
723

824
ARG DEBIAN_FRONTEND=noninteractive
925
ENV TZ=Asian/Shanghai
1026
ARG ZEPHYR_SDK_VERSION=0.16.9
1127
# In west_lite.yml, the Zephyr version is set to v3.7.0
1228
#ARG ZEPHYR_VERSION=3.7.0
1329

14-
# Install dependencies for Zephyr
15-
# hadolint ignore=DL3008
16-
RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja-build gperf \
17-
ccache dfu-util device-tree-compiler wget \
18-
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
19-
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1 \
20-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
21-
2230
# Install the Zephyr Software Development Kit (SDK)
23-
WORKDIR /opt
31+
WORKDIR /root/zephyrproject/zephyr-sdk
2432
# hadolint ignore=DL4006
2533
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz \
2634
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \
27-
&& tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz
28-
29-
WORKDIR /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
35+
&& tar --strip-components=1 -xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz
3036
# hadolint ignore=DL4006
3137
# Install host tools and Register Zephyr SDK CMake package
3238
RUN ./setup.sh -h -c
3339

34-
# Get Zephyr
35-
WORKDIR /root/zephyrproject/smoke-test
36-
37-
# hadolint ignore=DL3013
40+
# Install west
41+
# hadolint ignore=DL3013,DL3059
3842
RUN pip3 install --no-cache-dir west
39-
COPY ./west_lite.yml ./west.yml
43+
44+
# Setup a T2(Star topology) workspace
45+
WORKDIR /root/zephyrproject/application
46+
COPY ./west_lite.yml ./west_lite.yml
4047

4148
# init the west workspace with a minimal manifest
42-
RUN west init -l
49+
RUN west init -l --mf west_lite.yml .
4350

4451
WORKDIR /root/zephyrproject
4552
RUN west update --stats
4653

47-
WORKDIR /root/zephyrproject/modules/zephyr
48-
RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt
49-
50-
ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr"
51-
5254
# Git clone wamr
5355
WORKDIR /root/zephyrproject/modules/
5456
RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime

product-mini/platforms/zephyr/simple/west_lite.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ manifest:
88
url: https://github.com/zephyrproject-rtos/zephyr
99
revision: v3.7.0
1010
clone-depth: 1
11-
path: modules/zephyr
11+
path: zephyr
1212
west-commands: scripts/west-commands.yml
1313

1414
self:
15-
path: smoke-test
15+
path: application

0 commit comments

Comments
 (0)