Skip to content

Commit 6c9d75a

Browse files
committed
Add Zephyr setup action and CI on Zephyr
1 parent 602e86a commit 6c9d75a

File tree

5 files changed

+286
-15
lines changed

5 files changed

+286
-15
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# Setup Zephyr SDK and Zephyr environment
5+
# Refer to product-mini/platforms/zephyr/simple/Dockerfile
6+
# Please sync this file with the Dockerfile if you make changes
7+
name: "Setup Zephyr"
8+
description: "Set up the Zephyr environment and SDK required for building WAMR Zephyr applications"
9+
10+
inputs:
11+
zephyr-version:
12+
description: "Version of Zephyr to set up"
13+
required: false
14+
default: "v3.7.0"
15+
zephyr-sdk-version:
16+
description: "Version of Zephyr SDK to install"
17+
required: false
18+
default: "0.16.9"
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- name: Install dependencies for Zephyr
24+
shell: bash
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
28+
ccache dfu-util device-tree-compiler wget \
29+
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
30+
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
31+
sudo apt-get clean -y
32+
33+
- name: Install Zephyr SDK
34+
shell: bash
35+
run: |
36+
export SDK_VERSION="${{ inputs.zephyr-sdk-version }}"
37+
cd /opt
38+
sudo wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${SDK_VERSION}/zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
39+
sudo wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${SDK_VERSION}/sha256.sum | shasum --check --ignore-missing
40+
sudo tar xvf zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
41+
sudo rm zephyr-sdk-${SDK_VERSION}_linux-x86_64.tar.xz
42+
cd /opt/zephyr-sdk-${SDK_VERSION}
43+
echo "yes" | sudo ./setup.sh
44+
45+
- name: Setup Zephyr
46+
shell: bash
47+
run: |
48+
pip3 install west
49+
50+
- name: Generate a minimum Zephyr project
51+
shell: bash
52+
run: |
53+
mkdir -p ${HOME}/zephyrproject
54+
cd ${HOME}/zephyrproject
55+
mkdir -p wamr
56+
echo "
57+
manifest:
58+
projects:
59+
- name: zephyr
60+
url: https://github.com/zephyrproject-rtos/zephyr
61+
revision: v3.7.0
62+
path: zephyr
63+
clone-depth: 1
64+
west-commands: scripts/west-commands.yml
65+
66+
self:
67+
path: zephyrproject
68+
- name: zephyr
69+
" > ${HOME}/zephyrproject/wamr/west.yml
70+
71+
- name: Initialize west
72+
shell: bash
73+
run: |
74+
cat west.yml
75+
west init -l .
76+
working-directory: ${HOME}/zephyrproject/wamr
77+
78+
- name: Update west to fetch the Zephyr project
79+
shell: bash
80+
run: west update
81+
working-directory: ${HOME}/zephyrproject
82+
83+
- name: Export Zephyr environment
84+
shell: bash
85+
run: |
86+
west zephyr-export
87+
pip3 install -r ${HOME}/zephyrproject/zephyr/scripts/requirements.txt
88+
working-directory: ${HOME}/zephyrproject
89+
90+
- name: Set Environment Variables
91+
shell: bash
92+
run: |
93+
echo "ZEPHYR_BASE=${HOME}/zephyrproject/zephyr" >> $GITHUB_ENV
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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: Setup Zephyr
65+
# uses: ./.github/actions/setup-zephyr
66+
# with:
67+
# zephyr-version: ${{ env.ZEPHYR_VERSION }}
68+
# zephyr-sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}
69+
70+
- name: Install dependencies for Zephyr
71+
shell: bash
72+
run: |
73+
sudo apt-get update
74+
sudo apt-get install -y --no-install-recommends git cmake ninja-build gperf \
75+
ccache dfu-util device-tree-compiler wget \
76+
python3-dev python3-pip python3-setuptools python3-tk python3-wheel xz-utils file \
77+
make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1
78+
sudo apt-get clean -y
79+
80+
- name: Download Zephyr SDK
81+
shell: bash
82+
run: |
83+
cd /opt
84+
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
85+
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
86+
sudo tar xf zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}_linux-x86_64.tar.xz
87+
working-directory: /opt
88+
89+
- name: Install Zephyr SDK. host tools and Zephyr SDK CMake package
90+
shell: bash
91+
run: |
92+
sudo ./setup.sh -h -c
93+
working-directory: /opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
94+
95+
- name: Setup Zephyr
96+
shell: bash
97+
run: |
98+
pip3 install west
99+
100+
- name: Generate a minimum Zephyr project
101+
shell: bash
102+
run: |
103+
mkdir -p ./zephyrproject/modules/zephyr
104+
mkdir -p ./zephyrproject/smoke-test
105+
cp product-mini/platforms/zephyr/simple/west_lite.yml ./zephyrproject/smoke-test/west.yml
106+
107+
- name: Initialize west
108+
shell: bash
109+
run: |
110+
west init -l .
111+
working-directory: ./zephyrproject/smoke-test
112+
113+
- name: Update west to fetch the Zephyr project
114+
shell: bash
115+
run: west update --stats
116+
working-directory: ./zephyrproject
117+
118+
- name: Export Zephyr environment
119+
shell: bash
120+
run: |
121+
west zephyr-export
122+
pip3 install -r ./scripts/requirements.txt
123+
working-directory: ./zephyrproject/modules/zephyr
124+
125+
- name: Set Environment Variables
126+
shell: bash
127+
run: |
128+
echo "ZEPHYR_BASE=$(realpath ./zephyrproject/modules/zephyr)" >> $GITHUB_ENV
129+
130+
- name: Build a sample application(simple)
131+
run: |
132+
west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC
133+
# TODO: enable the following line when we learned how to exit automatically
134+
# west build -t run
135+
working-directory: product-mini/platforms/zephyr/simple
136+
137+
- name: Build a sample application(user-mode)
138+
run: |
139+
west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC
140+
# TODO: enable the following line when we learned how to exit automatically
141+
# west build -t run
142+
working-directory: product-mini/platforms/zephyr/user-mode
Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# Copyright (C) 2019 Intel Corporation. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html
5+
# 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
39
FROM ubuntu:22.04
410

511
ARG DEBIAN_FRONTEND=noninteractive
612
ENV TZ=Asian/Shanghai
13+
ARG ZEPHYR_SDK_VERSION=0.16.9
14+
# In west_lite.yml, the Zephyr version is set to v3.7.0
15+
#ARG ZEPHYR_VERSION=3.7.0
716

817
# Install dependencies for Zephyr
918
# hadolint ignore=DL3008
@@ -16,28 +25,34 @@ RUN apt-get update && apt-get install -y --no-install-recommends git cmake ninja
1625
# Install the Zephyr Software Development Kit (SDK)
1726
WORKDIR /opt
1827
# hadolint ignore=DL4006
19-
RUN wget --progress=dot:giga https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/zephyr-sdk-0.16.3_linux-x86_64.tar.xz \
20-
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.16.3/sha256.sum | shasum --check --ignore-missing \
21-
&& tar xvf zephyr-sdk-0.16.3_linux-x86_64.tar.xz && rm zephyr-sdk-0.16.3_linux-x86_64.tar.xz
28+
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 \
29+
&& wget --progress=dot:giga -O - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/sha256.sum | shasum --check --ignore-missing \
30+
&& tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz && rm zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64.tar.xz
2231

23-
WORKDIR /opt/zephyr-sdk-0.16.3
32+
WORKDIR /opt/zephyr-sdk-${ZEPHYR_SDK_VERSION}
2433
# hadolint ignore=DL4006
25-
RUN yes | ./setup.sh
34+
# Install host tools and Register Zephyr SDK CMake package
35+
RUN ./setup.sh -h -c
2636

2737
# Get Zephyr
38+
WORKDIR /root/zephyrproject/smoke-test
39+
2840
# hadolint ignore=DL3013
29-
RUN pip3 install --no-cache-dir west && west init -m https://github.com/zephyrproject-rtos/zephyr --mr v3.5.0 /root/zephyrproject
41+
RUN pip3 install --no-cache-dir west
42+
COPY ./west_lite.yml ./west.yml
3043

31-
WORKDIR /root/zephyrproject
32-
RUN west update
44+
# init the west workspace with a minimal manifest
45+
RUN west init -l
3346

34-
WORKDIR /root/zephyrproject/zephyr
35-
RUN west zephyr-export && pip install --no-cache-dir -r ~/zephyrproject/zephyr/scripts/requirements.txt
47+
WORKDIR /root/zephyrproject
48+
RUN west update --stats
3649

37-
# Git clone wamr
38-
WORKDIR /root
39-
RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git
50+
WORKDIR /root/zephyrproject/modules/zephyr
51+
RUN west zephyr-export && pip install --no-cache-dir -r ./scripts/requirements.txt
4052

41-
WORKDIR /root/wasm-micro-runtime/product-mini/platforms/zephyr/simple
53+
ENV ZEPHYR_BASE="/root/zephyrproject/modules/zephyr"
4254

43-
ENV ZEPHYR_BASE="/root/zephyrproject/zephyr"
55+
# Git clone wamr
56+
WORKDIR /root/zephyrproject/modules/
57+
RUN git clone https://github.com/bytecodealliance/wasm-micro-runtime.git wasm-micro-runtime
58+
WORKDIR /root/zephyrproject/modules/wasm-micro-runtime/product-mini/platforms/zephyr

product-mini/platforms/zephyr/simple/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ is a 64-bit ARM target for emulating the Cortex-A53 platform.
8787
west build . -b qemu_cortex_a53 -p always -- -DWAMR_BUILD_TARGET=AARCH64
8888
```
8989

90+
[ARC QEMU](https://docs.zephyrproject.org/latest/boards/qemu/arc/doc/index.html)
91+
is a 32-bit ARC target for emulating the ARC platform.
92+
93+
```shell
94+
west build . -b qemu_arc/qemu_arc_em -p always -- -DWAMR_BUILD_TARGET=ARC
95+
```
9096

9197
## Flashing or Running Image
9298

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The west manifest file for WAMR on Zephyr smoke test.
2+
#
3+
manifest:
4+
#
5+
# Please add items below based on alphabetical order
6+
projects:
7+
- name: zephyr
8+
url: https://github.com/zephyrproject-rtos/zephyr
9+
revision: v3.7.0
10+
clone-depth: 1
11+
path: modules/zephyr
12+
west-commands: scripts/west-commands.yml
13+
14+
self:
15+
path: smoke-test

0 commit comments

Comments
 (0)