Skip to content

Add Zephyr setup action and CI on Zephyr #4336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/scripts/run_qemu_arc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

# THIS SCRIPT IS USED TO RUN QEMU ARC EMULATOR DIRECTLY ON CI ONLY.
# USUALLY, you SHOULD NOT RUN IT ON YOUR LOCAL MACHINE.
# INSTEAD, YOU SHOULD USE `west build -t run` COMMAND.

# Two arguments. first is the path to the zephyr-sdk, second is the path to the zephyr elf.
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <path_to_zephyr_sdk> <path_to_zephyr_elf>"
exit 1
fi

ZEPHYR_SDK_PATH=$1
ZEPHYR_ELF_PATH=$2

if [ ! -d "$ZEPHYR_SDK_PATH" ]; then
echo "Error: Zephyr SDK path does not exist: $ZEPHYR_SDK_PATH"
exit 1
fi
if [ ! -f "$ZEPHYR_ELF_PATH" ]; then
echo "Error: Zephyr ELF file does not exist: $ZEPHYR_ELF_PATH"
exit 1
fi

# this command is copied from the content of build.ninja which is generated by west build.
# please do not modify it unless synchronizing with the build.ninja file.
$ZEPHYR_SDK_PATH/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-arc \
-cpu arcem -m 8M \
-nographic -no-reboot -monitor none \
-global cpu.firq=false \
-global cpu.num-irqlevels=15 \
-global cpu.num-irq=25 \
-global cpu.ext-irq=20 \
-global cpu.freq_hz=10000000 \
-global cpu.timer0=true \
-global cpu.timer1=true \
-global cpu.has-mpu=true \
-global cpu.mpu-numreg=16 \
-net none \
-pidfile qemu.pid \
-chardev stdio,id=con,mux=on \
-serial chardev:con \
-mon chardev=con,mode=readline \
-icount shift=6,align=off,sleep=off \
-rtc clock=vm \
-kernel $ZEPHYR_ELF_PATH
152 changes: 152 additions & 0 deletions .github/workflows/compilation_on_zephyr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

name: compilation on zephyr

on:
# will be triggered on PR events
pull_request:
types:
- opened
- synchronize
paths:
- ".github/**"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/platforms/common/**"
- "product-mini/platforms/zephyr/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# will be triggered on push events
push:
branches:
- main
- "dev/**"
paths:
- ".github/**"
- "build-scripts/**"
- "core/**"
- "!core/deps/**"
- "product-mini/platforms/common/**"
- "product-mini/platforms/zephyr/**"
- "samples/**"
- "!samples/workload/**"
- "tests/wamr-test-suites/**"
- "wamr-compiler/**"
# allow to be triggered manually
workflow_dispatch:

# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# FOR SETUP
ZEPHYR_SDK_VERSION: "0.16.9"
ZEPHYR_VERSION: "v3.7.0"
# FOR BUILD

permissions:
contents: read

jobs:
smoke_test:
runs-on: zephyr-runner

container:
# For Zephyr 3.7 LTS, use the v0.26-branch or the latest v0.26.x release Docker image.
image: ghcr.io/zephyrproject-rtos/ci:v0.26-branch
options: --user root

steps:
# https://docs.zephyrproject.org/latest/develop/application/index.html#zephyr-workspace-application
# zephyrproject/
# ├─── .west/
# │ └─── config
# ├─── zephyr/
# ├─── bootloader/
# ├─── modules/
# ├─── tools/
# ├─── <vendor/private-repositories>/
# └─── applications/ <- wasm-micro-runtime HERE
# └── app/
- name: Checkout code
uses: actions/checkout@v3
with:
path: application

- name: Setup Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1
with:
app-path: application
sdk-version: ${{ env.ZEPHYR_SDK_VERSION }}

- name: DBG#1
shell: bash
run: |
pwd
ls -l .
tree -d .

# - name: Generate a minimum Zephyr project
# shell: bash
# run: |
# mkdir -p ./zephyrproject/modules/zephyr
# mkdir -p ./zephyrproject/smoke-test
# cp product-mini/platforms/zephyr/simple/west_lite.yml ./zephyrproject/smoke-test/west.yml

# - name: Initialize west
# shell: bash
# run: |
# west init -l .
# working-directory: ./zephyrproject/smoke-test

# - name: Update west to fetch the Zephyr project
# shell: bash
# run: west update --stats
# working-directory: ./zephyrproject

# - name: Export Zephyr environment
# shell: bash
# run: |
# west zephyr-export
# pip3 install -r ./scripts/requirements.txt
# working-directory: ./zephyrproject/modules/zephyr

# - name: Set Environment Variables
# shell: bash
# run: |
# echo "ZEPHYR_BASE=$(realpath ./zephyrproject/modules/zephyr)" >> $GITHUB_ENV

# - name: Build a sample application(simple)
# run: |
# pushd product-mini/platforms/zephyr/simple
# west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
# popd

# # west build -t run will fork several processes, which will cause the job to hang.
# # run in the background and kill it after 5 seconds
# .github/scripts/run_qemu_arc.sh \
# /opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }} \
# product-mini/platforms/zephyr/simple/build/zephyr/zephyr.elf &
# sleep 5
# pkill qemu-system-arc

# - name: Build a sample application(user-mode)
# run: |
# pushd product-mini/platforms/zephyr/user-mode
# west build . -b qemu_arc/qemu_arc_hs -p always -- -DWAMR_BUILD_TARGET=ARC
# popd

# # west build -t run will fork several processes, which will cause the job to hang.
# # run in the background and kill it after 5 seconds
# .github/scripts/run_qemu_arc.sh \
# /opt/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }} \
# product-mini/platforms/zephyr/user-mode/build/zephyr/zephyr.elf &
# sleep 5
# pkill qemu-system-arc
3 changes: 3 additions & 0 deletions product-mini/platforms/zephyr/simple/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

# Refer to https://docs.zephyrproject.org/3.7.0/develop/getting_started/index.html
# for more information on how to set up the Zephyr development environment.

# If you modify this file, you may need to sync the modifications to the
# .github/actions/setup-zephyr/action.yml
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
Expand Down
Loading