1 Commits

Author SHA1 Message Date
lukstep
6417e81cd0 Fix 2025-07-29 14:47:32 +02:00
2 changed files with 69 additions and 58 deletions

View File

@@ -1,4 +1,5 @@
name: Raspberry PI Pico Docker SDK CI
name: Build, test and push Docker image
on: on:
push: push:
@@ -14,39 +15,64 @@ env:
TEST_TAG: pico_test_sdk TEST_TAG: pico_test_sdk
jobs: jobs:
sdk_container: build-and-test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Set up QEMU
- name: Set up QEMU (for ARM builds)
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build SDK
uses: docker/build-push-action@v6 - name: Login to DockerHub
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: Test SDK
run: bash ./test_sdk.sh ${{ env.TEST_TAG }}
- name: Log into Docker Hub
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Extract SDK metadata
id: meta - name: Build Docker image (multi-arch, no push)
uses: docker/metadata-action@v4 uses: docker/build-push-action@v6
id: build
with: with:
images: lukstep/raspberry-pi-pico-sdk context: .
- name: Push SDK image platforms: linux/amd64
if: github.event_name == 'release' && github.event.action == 'published' push: false
load: true # Allows testing the image locally
tags: ${{ env.TEST_TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run Tests (from built image)
run: bash ./test_sdk.sh ${{ env.TEST_TAG }}
push-image:
needs: build-and-test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and Push Docker image (multi-arch)
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true
tags: lukstep/raspberry-pi-pico-sdk:latest
cache-from: type=gha
cache-to: type=gha,mode=max

View File

@@ -1,46 +1,26 @@
FROM ubuntu:24.04 FROM ubuntu:24.10 AS gcc_build
# Build GCC RISC-V
COPY ./install_gcc.sh /home/install_gcc.sh
RUN bash /home/install_gcc.sh
FROM ubuntu:24.10 AS sdk_setup
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get upgrade -y && \ apt-get upgrade -y && \
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
build-essential \ git \
ca-certificates \ ca-certificates \
cmake \ python3 \
gcc-arm-none-eabi \ tar \
git \ build-essential \
libnewlib-arm-none-eabi \ gcc-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \ libnewlib-arm-none-eabi \
python3 \ libstdc++-arm-none-eabi-newlib \
tar \ cmake && \
wget && \
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# RISC-V toolchain
ARG RISCV_VERSION=15.2.0-1
ARG TARGETARCH
RUN if [ "$TARGETARCH" = "arm64" ]; then \
ARCH=linux-arm64; \
elif [ "$TARGETARCH" = "amd64" ]; then \
ARCH=linux-x64; \
else \
echo "Unsupported arch: $TARGETARCH" && exit 1; \
fi && \
wget -q https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases/download/v${RISCV_VERSION}/xpack-riscv-none-elf-gcc-${RISCV_VERSION}-${ARCH}.tar.gz \
-O /tmp/riscv.tar.gz && \
tar -xzf /tmp/riscv.tar.gz -C /opt && \
rm /tmp/riscv.tar.gz
# Add toolchain to PATH
ENV PATH="/opt/xpack-riscv-none-elf-gcc-${RISCV_VERSION}/bin:${PATH}"
RUN TOOLCHAIN=/opt/xpack-riscv-none-elf-gcc-${RISCV_VERSION}/bin && \
for f in $TOOLCHAIN/riscv-none-elf-*; do \
name=$(basename $f | sed 's/riscv-none-elf/riscv32-unknown-elf/'); \
ln -s $f /usr/local/bin/$name; \
done
# Raspberry Pi Pico SDK # Raspberry Pi Pico SDK
ARG SDK_PATH=/usr/local/picosdk ARG SDK_PATH=/usr/local/picosdk
RUN git clone --depth 1 --branch 2.1.1 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \ RUN git clone --depth 1 --branch 2.1.1 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \
@@ -66,3 +46,8 @@ RUN git clone --depth 1 --branch 2.1.1 https://github.com/raspberrypi/picotool.g
make -j$(nproc) && \ make -j$(nproc) && \
cmake --install . && \ cmake --install . && \
rm -rf /home/picotool rm -rf /home/picotool
# Install GCC RISC-V
COPY --from=gcc_build /opt/riscv/gcc14-rp2350-no-zcmp /opt/riscv/gcc14-rp2350-no-zcmp
ENV PATH="$PATH:/opt/riscv/gcc14-rp2350-no-zcmp/bin"