From 41672f6336d6a53a4f5d9d28b4758649229c0de4 Mon Sep 17 00:00:00 2001 From: Bruno Verachten Date: Thu, 12 Mar 2026 11:26:39 +0100 Subject: [PATCH] feat(riscv64): add RISC-V build support to devcontainers and CI Make WASI-SDK installation conditional in both linux and zephyr Dockerfiles since pre-built binaries are only available for x86_64 and arm64. Add riscv64-zephyr-elf toolchain to the Zephyr SDK install and qemu_riscv64 to the Zephyr CI build matrix. Tested on Banana Pi F3 (SpacemiT K1, rv64gc, 16 GB RAM, Debian Trixie): all three sample apps (mini, demo, supervisor) build successfully. Co-Authored-By: Claude Opus 4.6 Signed-off-by: Bruno Verachten --- .devcontainer/linux/Dockerfile | 15 +++++++++++---- .devcontainer/zephyr/Dockerfile | 18 +++++++++++++----- .github/workflows/zephyr.yml | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.devcontainer/linux/Dockerfile b/.devcontainer/linux/Dockerfile index 3301d47d..b03333cc 100644 --- a/.devcontainer/linux/Dockerfile +++ b/.devcontainer/linux/Dockerfile @@ -40,10 +40,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean -y\ && update-alternatives --install /usr/bin/python python /usr/bin/python3 50 -# Install wasi-sdk -RUN mkdir /opt/wasi-sdk && \ - curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-$(uname -m | sed s/aarch64/arm64/)-linux.tar.gz | \ - tar zxvf - --strip-components=1 -C /opt/wasi-sdk +# Install wasi-sdk (pre-built binaries available for x86_64 and arm64 only) +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "aarch64" ]; then ARCH=arm64; fi; \ + if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "arm64" ]; then \ + mkdir /opt/wasi-sdk && \ + curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-${ARCH}-linux.tar.gz | \ + tar zxvf - --strip-components=1 -C /opt/wasi-sdk; \ + else \ + mkdir -p /opt/wasi-sdk; \ + echo "WASI-SDK not available for $(uname -m), skipping (use -DOCRE_BUILD_DEMO_CONTAINERS=OFF)"; \ + fi FROM ocre-ci AS ocre-dev diff --git a/.devcontainer/zephyr/Dockerfile b/.devcontainer/zephyr/Dockerfile index 57c48bb7..0fb4930a 100644 --- a/.devcontainer/zephyr/Dockerfile +++ b/.devcontainer/zephyr/Dockerfile @@ -51,10 +51,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && apt-get clean -y\ && update-alternatives --install /usr/bin/python python /usr/bin/python3 50 -# Install wasi-sdk -RUN mkdir /opt/wasi-sdk && \ - curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-$(uname -m | sed s/aarch64/arm64/)-linux.tar.gz | \ - tar zxvf - --strip-components=1 -C /opt/wasi-sdk +# Install wasi-sdk (pre-built binaries available for x86_64 and arm64 only) +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "aarch64" ]; then ARCH=arm64; fi; \ + if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "arm64" ]; then \ + mkdir /opt/wasi-sdk && \ + curl -sSL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$WASI_SDK_VERSION/wasi-sdk-$WASI_SDK_VERSION.0-${ARCH}-linux.tar.gz | \ + tar zxvf - --strip-components=1 -C /opt/wasi-sdk; \ + else \ + mkdir -p /opt/wasi-sdk; \ + echo "WASI-SDK not available for $(uname -m), skipping (use -DOCRE_BUILD_DEMO_CONTAINERS=OFF)"; \ + fi RUN python -m venv /opt/zephyr-venv && \ . /opt/zephyr-venv/bin/activate && \ @@ -78,7 +85,8 @@ RUN . /opt/zephyr-venv/bin/activate && \ west sdk install --install-base /opt -t \ x86_64-zephyr-elf \ aarch64-zephyr-elf \ - arm-zephyr-eabi + arm-zephyr-eabi \ + riscv64-zephyr-elf FROM base AS ocre-ci diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml index 1e89ff68..3a2f7cfb 100644 --- a/.github/workflows/zephyr.yml +++ b/.github/workflows/zephyr.yml @@ -27,6 +27,7 @@ jobs: - pico_plus2/rp2350b/m33 - native_sim/native/64 - b_u585i_iot02a + - qemu_riscv64 app: - mini - demo