Skip to content

Commit

Permalink
Added devcontainer setup and CI workflow for generating builds (#116)
Browse files Browse the repository at this point in the history
* Add CI build workflow

* Added devcontainer setup

* Download gekkoboot step

* Use devcontainer on CI

* Fix gekkoboot copy location

* Test dir

* Test directory list

* More debug info

* Debug info

* Debug file structure

* Correct gekkoboot release name

* Copy payload to correct path

* Debug info

* Checkout to workspace root

* Upload uf2 artifacts

* Split artifacts

* Add commit hash to artifact name

* Clean up 10_build.yml

* Fixed artifact names

* Remove unused steps

* Remove ref name from artifact label

* Use single artifact as non-zip artifacts are not possible

* Rename, reformat, use short SHA for artifact name

* Set ouputs step after checkout

* Added cacheFrom key to devcontainers/ci step

* Test webhdx/iplboot

* Change build type

* Add missing trailing lines
  • Loading branch information
webhdx authored Aug 10, 2024
1 parent f83119c commit a7ba643
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ARG VARIANT="ubuntu-22.04"
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}

RUN apt-get update && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -y install --no-install-recommends \
gcc-arm-none-eabi \
libstdc++-arm-none-eabi-newlib \
cmake \
build-essential \
wget \
ca-certificates \
gdb-multiarch \
binutils-multiarch \
automake \
autoconf \
libtool \
libftdi-dev \
libusb-1.0-0-dev \
libhidapi-dev \
pkg-config \
clang-format \
python3 \
python3-tk

WORKDIR /apps

RUN cd /apps && \
git clone -b master https://github.com/raspberrypi/pico-sdk.git --depth=1 && \
cd pico-sdk && \
git submodule update --init

ENV PICO_SDK_PATH=/apps/pico-sdk

RUN cd /apps && \
git clone -b master https://github.com/raspberrypi/pico-extras.git --depth=1 \
&& cd pico-extras && \
git submodule update --init

ENV PICO_EXTRAS_PATH=/apps/pico-extras

RUN git clone https://github.com/raspberrypi/openocd.git --depth=1 && \
cd openocd && ./bootstrap && ./configure --enable-ftdi --enable-sysfsgpio --enable-picoprobe && make -j 8 install
RUN cd /apps && git clone https://github.com/raspberrypi/picotool.git --depth=1 && \
cd picotool && mkdir build && cd build && cmake ../ && make -j 8 && cp picotool /usr/local/bin
RUN cd /apps && git clone https://github.com/wtarreau/bootterm.git --depth=1 && \
cd bootterm && make -j 8 install

RUN cd /usr/bin && ln -s /usr/bin/objdump objdump-multiarch && ln -s /usr/bin/nm nm-multiarch

RUN usermod -aG plugdev vscode
51 changes: 51 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/mwinters-stuff/vscode-devcontainer-raspberrypi-pico
{
"name": "C++ Raspberry Pi Pico",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"-v", "/dev/bus/usb:/dev/bus/usb",
"--device=/dev/bus/usb",
"--device=/dev/ttyACM0"
],

// Set *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/usr/bin/bash"
}
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"marus25.cortex-debug",
"ms-vscode.cmake-tools",
"twxs.cmake",
"eamodio.gitlens",
"xaver.clang-format",
"chris-hock.pioasm",
"ms-vscode.cpptools-extension-pack"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
75 changes: 75 additions & 0 deletions .github/workflows/10-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main

env:
# Customize the CMake build
BUILD_TYPE: RelWithDebInfo # Release, Debug, RelWithDebInfo

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout PicoBoot code
uses: actions/checkout@v4

- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- uses: robinraju/release-downloader@v1
id: gekkoboot-download
with:
repository: 'webhdx/iplboot'
latest: true
fileName: '*.zip'
out-file-path: gekkoboot
extract: true

- name: Copy gekkoboot uf2 payload
run: |
cd gekkoboot
if [ -f "gekkoboot_pico.uf2" ]; then
cp gekkoboot_pico.uf2 ${{ github.workspace }}/payload.uf2
elif [ -f "iplboot_pico.uf2" ]; then
cp iplboot_pico.uf2 ${{ github.workspace }}/payload.uf2
else
echo "Neither gekkoboot_pico.uf2 nor iplboot_pico.uf2 found."
exit 1
fi
- name: Build and run Dev Container task
uses: devcontainers/ci@v0.3
with:
imageName: ghcr.io/webhdx/picoboot
cacheFrom: ghcr.io/webhdx/picoboot
runCmd: |
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE .
make
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: picoboot-${{ steps.vars.outputs.sha_short }}
path: |
picoboot_full.uf2
picoboot.uf2
payload.uf2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _deps
.DS_Store

# Build environment
build/
CMakeFiles/
elf2uf2/
generated/
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ function(merge_uf2 NAME BASE_TARGET INPUTS)
COMMAND_EXPAND_LISTS)
endfunction()

merge_uf2(picoboot_full picoboot "${CMAKE_CURRENT_LIST_DIR}/iplboot_pico.uf2")
merge_uf2(picoboot_full picoboot "${CMAKE_CURRENT_LIST_DIR}/payload.uf2")

0 comments on commit a7ba643

Please sign in to comment.