Skip to content

Commit 9271ec3

Browse files
committed
Add a new CI on Zephyr
to run product-mini/platforms/zephyr/simple and product-mini/platforms/zephyr/user-mode
1 parent 38fe056 commit 9271ec3

File tree

3 files changed

+199
-0
lines changed

3 files changed

+199
-0
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: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v3
63+
64+
- name: Install dependencies for Zephyr
65+
shell: bash
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
69+
ccache dfu-util device-tree-compiler wget \
70+
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
71+
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
72+
sudo apt-get clean -y
73+
74+
- name: Download Zephyr SDK
75+
shell: bash
76+
run: |
77+
cd /opt
78+
sudo wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{ env.ZEPHYR_SDK_VERSION }}/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}_linux-x86_64.tar.xz
79+
sudo wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${{ env.ZEPHYR_SDK_VERSION }}/sha256.sum | shasum --check --ignore-missing
80+
sudo tar xf zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}_linux-x86_64.tar.xz
81+
working-directory: /opt
82+
83+
- name: Install Zephyr SDK. host tools and Zephyr SDK CMake package
84+
shell: bash
85+
run: |
86+
sudo ./setup.sh -h -c
87+
working-directory: /opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
88+
89+
- name: Setup Zephyr
90+
shell: bash
91+
run: |
92+
pip3 install west
93+
94+
- name: Generate a minimum Zephyr project
95+
shell: bash
96+
run: |
97+
mkdir -p ./zephyrproject/modules/zephyr
98+
mkdir -p ./zephyrproject/smoke-test
99+
cp product-mini/platforms/zephyr/simple/west_lite.yml ./zephyrproject/smoke-test/west.yml
100+
101+
- name: Initialize west
102+
shell: bash
103+
run: |
104+
west init -l .
105+
working-directory: ./zephyrproject/smoke-test
106+
107+
- name: Update west to fetch the Zephyr project
108+
shell: bash
109+
run: west update --stats
110+
working-directory: ./zephyrproject
111+
112+
- name: Export Zephyr environment
113+
shell: bash
114+
run: |
115+
west zephyr-export
116+
pip3 install -r ./scripts/requirements.txt
117+
working-directory: ./zephyrproject/modules/zephyr
118+
119+
- name: Set Environment Variables
120+
shell: bash
121+
run: |
122+
echo "ZEPHYR_BASE=$(realpath ./zephyrproject/modules/zephyr)" >> $GITHUB_ENV
123+
124+
- name: Build a sample application(simple)
125+
run: |
126+
pushd product-mini/platforms/zephyr/simple
127+
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
128+
popd
129+
130+
# west build -t run will fork several processes, which will cause the job to hang.
131+
# run in the background and kill it after 5 seconds
132+
.github/scripts/run_qemu_arc.sh \
133+
/opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }} \
134+
product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
135+
sleep 5
136+
pkill qemu-system-arc
137+
138+
- name: Build a sample application(user-mode)
139+
run: |
140+
pushd product-mini/platforms/zephyr/user-mode
141+
west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
142+
popd
143+
144+
# west build -t run will fork several processes, which will cause the job to hang.
145+
# run in the background and kill it after 5 seconds
146+
.github/scripts/run_qemu_arc.sh \
147+
/opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }} \
148+
product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
149+
sleep 5
150+
pkill qemu-system-arc

product-mini/platforms/zephyr/simple/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
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+
7+
# If you modify this file, you may need to sync the modifications to the
8+
# .github/actions/setup-zephyr/action.yml
69
FROM ubuntu:22.04
710

811
ARG DEBIAN_FRONTEND=noninteractive

0 commit comments

Comments
 (0)