Skip to content

Commit a2fb893

Browse files
Use docker to build locally and in CI (#26)
This adds docker configuration files so that PrawnBlaster firmware can be built within a docker container on personal devices and in GitHub actions. ## Changes - Updates the pico-sdk to v1.5.1 - Remove uf2 files from the repository - Add docker file to build a container designed to build rp2040 firmware using the pico-sdk - Pin pico-sdk version via the docker file - Update license to 3-clause BSD license (from 2-clause BSD license) and add missing license file to the repository - Added GitHub action script that builds artefacts (containing the uf2 files) for pull requests and releases when commits are tagged.
1 parent 3896b1a commit a2fb893

File tree

9 files changed

+130
-6
lines changed

9 files changed

+130
-6
lines changed

.github/workflows/build.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build firmware
2+
3+
on:
4+
create:
5+
tags:
6+
- '[0-9]+\.[0-9]+\.[0-9]+*'
7+
pull_request:
8+
types: [opened, reopened, synchronize, ready_for_review]
9+
10+
jobs:
11+
build-firmware:
12+
runs-on: ubuntu-latest
13+
name: Build firmware
14+
steps:
15+
- name: Check out this repository
16+
uses: actions/checkout@v3
17+
18+
- name: Build Docker image
19+
run: docker compose build --pull --build-arg APT_MIRROR="http://azure.archive.ubuntu.com/ubuntu/"
20+
21+
- name: Run docker container
22+
run: docker compose up
23+
24+
- name: Upload firmware as artifact
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: prawnblaster-firmware-${{ github.sha }}
28+
path: build/prawnblaster/*.uf2
29+
30+
- name: Create release
31+
if: ${{ github.event.ref_type == 'tag' }}
32+
uses: "marvinpinto/action-automatic-releases@latest"
33+
with:
34+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
35+
prerelease: false
36+
files: |
37+
LICENSE.txt
38+
build/prawnblaster/prawnblaster.uf2
39+
build/prawnblaster/prawnblasteroverclock.uf2

LICENSE.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2021, Philip Starkey
2+
3+
Redistribution and use in source and binary forms, with or without modification, are
4+
permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of
7+
conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list
10+
of conditions and the following disclaimer in the documentation and/or other materials
11+
provided with the distribution.
12+
13+
3. Neither the name of the copyright holder nor the names of its contributors may be
14+
used to endorse or promote products derived from this software without specific prior
15+
written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY
18+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20+
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22+
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-198 KB
Binary file not shown.
-197 KB
Binary file not shown.

docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: prawnblaster
2+
3+
services:
4+
buildfirmware:
5+
build:
6+
dockerfile: docker/Dockerfile
7+
command: /bin/bash -c 'cmake .. && make'
8+
volumes:
9+
- .:/prawnblaster
10+
working_dir: /prawnblaster/build
11+
init: true

docker/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Fetch ubuntu image
2+
FROM ubuntu:latest AS base
3+
# Attempt to auto-detect the best mirror (desn't always work well though)
4+
ARG APT_MIRROR="mirror://mirrors.ubuntu.com/mirrors.txt"
5+
# Use this one if you are in Australia
6+
# ARG APT_MIRROR="http://mirror.aarnet.edu.au/pub/ubuntu/archive/"
7+
8+
# Configure mirror. Pass --build-arg APT_MIRROR=<mirror URL> to set a mirror if this is slow
9+
RUN sed -i "s#htt[p|ps]://archive.ubuntu.com/ubuntu/#$APT_MIRROR#g" /etc/apt/sources.list
10+
11+
# Install packages
12+
RUN \
13+
apt update && \
14+
apt install -y git python3 && \
15+
apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
16+
17+
# Install Pico SDK into a new stage
18+
FROM base as buildtools
19+
20+
RUN \
21+
mkdir -p /pico/ && \
22+
cd /pico/ && \
23+
git clone https://github.com/raspberrypi/pico-sdk.git --branch 1.5.1 && \
24+
cd pico-sdk/ && \
25+
git submodule update --init && \
26+
cd /
27+
28+
# Set the Pico SDK environment variable
29+
ENV PICO_SDK_PATH=/pico/pico-sdk/

prawnblaster/prawnblaster.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# This file is used to flash a Raspberry Pi Pico microcontroller #
1313
# prototyping board to create a PrawnBlaster (see readme.txt and #
1414
# http://hardware.labscriptsuite.org). #
15-
# This file is licensed under the Simplified BSD License. #
15+
# This file is licensed under the 3-clause BSD License. #
1616
# See the license.txt file for the full license. #
1717
# #
1818
#######################################################################
@@ -33,9 +33,9 @@
3333
#include "pseudoclock.pio.h"
3434

3535
#ifndef PRAWNBLASTER_OVERCLOCK
36-
const char VERSION[16] = "1.0.0";
36+
const char VERSION[16] = "1.0.1";
3737
#else
38-
const char VERSION[16] = "1.0.0-overclock";
38+
const char VERSION[16] = "1.0.1-overclock";
3939
#endif //PRAWNBLASTER_OVERCLOCK
4040

4141
int DEBUG;

prawnblaster/pseudoclock.pio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
;# This file is used to flash a Raspberry Pi Pico microcontroller #
1010
;# prototyping board to create a PrawnBlaster (see readme.txt and #
1111
;# http://hardware.labscriptsuite.org). #
12-
;# This file is licensed under the Simplified BSD License. #
12+
;# This file is licensed under the 3-clause BSD License. #
1313
;# See the license.txt file for the full license. #
1414
;# #
1515
;#######################################################################

readme.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Note 2: The internal clock can be configured to run at up to 133 MHz. We set it
2828
You can increase the clock frequency at runtime (via a serial command) which scales the timing specifications accordingly.
2929

3030
## How to flash the firmware
31-
Download the latest [prawnblaster.uf2 file](https://github.com/labscript-suite/PrawnBlaster/blob/master/build/prawnblaster/prawnblaster.uf2).
31+
Download the latest [prawnblaster.uf2 file](https://github.com/labscript-suite/PrawnBlaster/releases/latest/download/prawnblaster.uf2).
3232
On your Raspberry Pi Pico, hold down the "bootsel" button while plugging the Pico into USB port on a PC (that must already be turned on).
3333
The Pico should mount as a mass storage device (if it doesn't, try again or consult the Pico documentation).
3434
Drag and drop the `.uf2` file into the mounted mass storage device.
@@ -120,6 +120,26 @@ An external clock of 100MHz means a minimum half-period of `5/100MHz=50ns`.
120120
Note: Officially, the documentation for the Pico says external clock sources can only be up to 50MHz. We have successfully tested up to 125MHz (see [#6](https://github.com/labscript-suite/PrawnBlaster/issues/6)).
121121
We recommend you personally verify the output of the PrawnBlaster is as expected if running from an external reference above 50MHz.
122122

123+
## Compiling the firmware
124+
125+
If you want to make changes to the firmware, or want to compile it yourself (because you don't trust binary blobs from the internet), we provide a docker configuration to help you do that.
126+
127+
1. Install docker desktop and make sure it is running (if you are on Windows, you may have to mess around a bit to get virtualisation working at an operating system level)
128+
2. Clone this repository
129+
3. Open a terminal with the current working directory set to the repository root (the `docker-compose.yaml`` file should be there)
130+
4. Run `docker compose build --pull` to build the docker container
131+
5. Run `docker compose up` to build the PrawnBlaster firmware.
132+
133+
Step 4 will take a while as it has to build the docker container.
134+
If it is slow to download packages from the Ubuntu package repositories, consider providing an explicit apt mirror that is fast for you: `docker compose build --pull --build-arg APT_MIRROR="http://azure.archive.ubuntu.com/ubuntu/"`.
135+
136+
If you want to change which version of the pico SDK it builds against, this is set in the `build/docker/Dockerfile` file.
137+
Just change the git tag of the pico SDK that gets cloned out by git, then rebuild the docker container (see step 4).
138+
139+
Note once the docker container is built, you can run step 5 as many times as you like.
140+
You do not need to rebuild the container, even if you make changes to the PrawnBlaster source code.
141+
You only need to rebuild the docker container if you modify the `build/docker/Dockerfile` file.
142+
123143
## FAQ:
124144

125145
### Why is it called a "PrawnBlaster"?
@@ -150,7 +170,7 @@ If you want to find out what pins, you should
150170

151171
### Can I overclock the Pico board?
152172
Yes, some people have reported being able to significantly overclock their Raspberry Pi Pico boards.
153-
While we do not recommend you do so (nor will we be liable for any damage to your Pico or attached devices should you overclock it), we have provided a version of the PrawnBlaster firmware with no upper limit to the clock frequency [here](https://github.com/labscript-suite/PrawnBlaster/blob/master/build/prawnblaster/prawnblasteroverclock.uf2).
173+
While we do not recommend you do so (nor will we be liable for any damage to your Pico or attached devices should you overclock it), we have provided a version of the PrawnBlaster firmware with no upper limit to the clock frequency [here](https://github.com/labscript-suite/PrawnBlaster/releases/latest/download/prawnblasteroverclock.uf2).
154174
Use at your own risk!
155175
We provide no support for the overclockable firmware.
156176
If you need to tweak any other operating parameters of the Pico in order to achieve a stable overclock, you will need to manually modify the firmware source code and recompile it with those changes.

0 commit comments

Comments
 (0)