Skip to content

Commit 7887dc6

Browse files
authored
Merge pull request #6 from dihm/dockerize_build
Dockerize the build
2 parents 74c30f0 + b6b94ef commit 7887dc6

File tree

11 files changed

+868
-806
lines changed

11 files changed

+868
-806
lines changed

CMakeLists.txt

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
11
cmake_minimum_required(VERSION 3.13)
22

3-
set(PICO_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../pico-sdk)
4-
53
include(pico_sdk_import.cmake)
64

7-
project(prawn_do_project C CXX ASM)
5+
project(prawn_do C CXX ASM)
86
set(CMAKE_C_STANDARD 11)
97
set(CMAKE_CXX_STANDARD 17)
108
pico_sdk_init()
119

12-
add_executable(prawn_do_project
13-
prawn_do.c
14-
fast_serial.c
15-
)
16-
17-
pico_generate_pio_header(prawn_do_project
18-
${CMAKE_CURRENT_LIST_DIR}/prawn_do.pio
19-
)
20-
21-
target_include_directories(prawn_do_project PUBLIC ${CMAKE_CURRENT_LIST_DIR})
22-
23-
target_link_libraries(prawn_do_project
24-
pico_multicore
25-
pico_stdlib
26-
pico_unique_id
27-
hardware_dma
28-
hardware_pio
29-
tinyusb_device
30-
tinyusb_board
31-
)
32-
33-
pico_add_extra_outputs(prawn_do_project)
10+
# add project directory
11+
add_subdirectory(prawn_do)

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,22 @@ end\n
106106

107107
<img width="470" alt="documentation" src="https://github.com/pmiller2022/prawn_digital_output/assets/75953337/932b784f-346f-4598-8679-b857578e0291">
108108

109+
## Compiling the firmware
110+
111+
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.
112+
113+
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)
114+
2. Clone this repository
115+
3. Open a terminal with the current working directory set to the repository root (the `docker-compose.yaml`` file should be there)
116+
4. Run `docker compose build --pull` to build the docker container
117+
5. Run `docker compose up` to build the PrawnBlaster firmware.
118+
119+
Step 4 will take a while as it has to build the docker container.
120+
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/"`.
121+
122+
If you want to change which version of the pico SDK it builds against, this is set in the `build/docker/Dockerfile` file.
123+
Just change the git tag of the pico SDK that gets cloned out by git, then rebuild the docker container (see step 4).
124+
125+
Note once the docker container is built, you can run step 5 as many times as you like.
126+
You do not need to rebuild the container, even if you make changes to the source code.
127+
You only need to rebuild the docker container if you modify the `build/docker/Dockerfile` file.

build/prawn_do_project.uf2

-127 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: prawn_do
2+
3+
services:
4+
buildfirmware:
5+
build:
6+
dockerfile: docker/Dockerfile
7+
command: /bin/bash -c 'cmake .. && make'
8+
volumes:
9+
- .:/prawn_digital_output
10+
working_dir: /prawn_digital_output/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/

prawn_do/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
add_executable(prawn_do
2+
prawn_do.c
3+
fast_serial.c
4+
)
5+
6+
pico_generate_pio_header(prawn_do
7+
${CMAKE_CURRENT_LIST_DIR}/prawn_do.pio
8+
)
9+
10+
# add local includes for fast_serial
11+
target_include_directories(prawn_do PRIVATE ${CMAKE_CURRENT_LIST_DIR})
12+
13+
# pull in pico stdlib
14+
target_link_libraries(prawn_do
15+
pico_multicore
16+
pico_stdlib
17+
pico_unique_id
18+
hardware_dma
19+
hardware_pio
20+
tinyusb_device
21+
tinyusb_board
22+
)
23+
24+
# create map/bin/hex/uf2 files
25+
pico_add_extra_outputs(prawn_do)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)