Skip to content

Commit ff092a8

Browse files
committed
add build_docker.sh. support pico-sdk 2.3.0
1 parent 77ac8e9 commit ff092a8

5 files changed

Lines changed: 130 additions & 36 deletions

File tree

.github/actions/build-and-rename/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ runs:
2828
using: 'composite'
2929
steps:
3030
- name: Build
31-
uses: elehobica/build-pico@v1
31+
uses: elehobica/build-pico@2.3.0
3232
with:
3333
path: ${{ inputs.path }}
3434
build: ${{ inputs.build }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
build/
1+
build/
2+
CLAUDE.md
3+
.claude/

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
8+
### Added
9+
* Add build_docker.sh
10+
### Changed
11+
* Support pico-sdk 2.3.0
812

913
## [1.0.2] - 2025-04-28
1014
### Added

README.md

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,19 @@ The frontend analog circuit should be needed.
3838
[pico_level_meter.pdf](doc/pico_level_meter.pdf)
3939

4040
## How to build
41+
* This project targets rp2350 (Raspberry Pi Pico 2) only
4142
* See ["Getting started with Raspberry Pi Pico"](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf)
4243
* Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
4344
* Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
44-
* Confirmed with Pico SDK 2.1.1
45+
* Confirmed with Pico SDK 2.3.0
4546
```
46-
> git clone -b 2.1.1 https://github.com/raspberrypi/pico-sdk.git
47+
> git clone -b 2.3.0 https://github.com/raspberrypi/pico-sdk.git
4748
> cd pico-sdk
4849
> git submodule update -i
4950
> cd ..
50-
> git clone -b sdk-2.1.1 https://github.com/raspberrypi/pico-examples.git
51+
> git clone -b sdk-2.3.0 https://github.com/raspberrypi/pico-examples.git
5152
>
52-
> git clone -b sdk-2.1.1 https://github.com/raspberrypi/pico-extras.git
53+
> git clone -b sdk-2.3.0 https://github.com/raspberrypi/pico-extras.git
5354
>
5455
> git clone -b main https://github.com/elehobica/pico_level_meter.git
5556
> cd pico_level_meter
@@ -61,51 +62,38 @@ The frontend analog circuit should be needed.
6162
* Confirmed with cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
6263
* Lanuch "Developer Command Prompt for VS 2022"
6364
```
65+
> git clone -b main https://github.com/elehobica/pico_level_meter.git
6466
> cd pico_level_meter
6567
> mkdir build && cd build
68+
> git submodule update -i
6669
> cmake -G "NMake Makefiles" ..
6770
> nmake
6871
```
69-
* Put "pico_level_meter.uf2" on RPI-RP2 drive
72+
* Put "pico_level_meter.uf2" on RP2350 drive
7073
### Linux
71-
* Build is confirmed with [pico-sdk-dev-docker:sdk-2.1.1-1.0.0]( https://hub.docker.com/r/elehobica/pico-sdk-dev-docker)
74+
* Build is confirmed with [pico-sdk-dev-docker:sdk-2.3.0](https://hub.docker.com/r/elehobica/pico-sdk-dev-docker)
7275
* Confirmed with cmake-3.22.1 and arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1
7376
```
77+
$ git clone -b main https://github.com/elehobica/pico_level_meter.git
7478
$ cd pico_level_meter
79+
$ git submodule update -i
7580
$ mkdir build && cd build
7681
$ cmake ..
7782
$ make -j4
7883
```
79-
* Download "pico_level_meter.uf2" on RPI-RP2 drive
80-
81-
82-
83-
* See ["Getting started with Raspberry Pi Pico"](https://datasheets.raspberrypi.org/pico/getting-started-with-pico.pdf)
84-
* Put "pico-sdk", "pico-examples" and "pico-extras" on the same level with this project folder.
85-
* Set environmental variables for PICO_SDK_PATH, PICO_EXTRAS_PATH and PICO_EXAMPLES_PATH
86-
* Build is confirmed in Developer Command Prompt for VS 2022 and Visual Studio Code on Windows enviroment
87-
* Confirmed with Pico SDK 1.5.1, cmake-3.27.2-windows-x86_64 and gcc-arm-none-eabi-10.3-2021.10-win32
84+
* Download "pico_level_meter.uf2" on RP2350 drive
85+
### Local build with Docker (build_docker.sh)
86+
* `build_docker.sh` builds this project inside the same SDK image as CI ([pico-sdk-dev-docker:sdk-2.3.0](https://hub.docker.com/r/elehobica/pico-sdk-dev-docker)), so no local Pico SDK installation is required
87+
* Requirements: Docker, and submodules initialized (`git submodule update -i`)
88+
* No need to set PICO_SDK_PATH / PICO_EXTRAS_PATH / PICO_EXAMPLES_PATH (provided by the image)
8889
```
89-
> git clone -b master https://github.com/raspberrypi/pico-sdk.git
90-
> cd pico-sdk
91-
> git submodule update -i
92-
> cd ..
93-
> git clone -b master https://github.com/raspberrypi/pico-examples.git
94-
>
95-
> git clone -b main https://github.com/elehobica/pico_level_meter.git
96-
> cd pico_level_meter
97-
> git submodule update -i
98-
> cd ..
99-
```
100-
* Lanuch "Developer Command Prompt for VS 2022"
101-
```
102-
> cd pico_level_meter
103-
> mkdir build
104-
> cd build
105-
> cmake -G "NMake Makefiles" ..
106-
> nmake
90+
$ git clone -b main https://github.com/elehobica/pico_level_meter.git
91+
$ cd pico_level_meter
92+
$ git submodule update -i
93+
$ ./build_docker.sh # build for Raspberry Pi Pico 2 (rp2350) -> build/
94+
$ ./build_docker.sh -k # incremental build (keep build directory contents)
10795
```
108-
* Put "pico_level_meter.uf2" on RPI-RP2 drive
96+
* Download "pico_level_meter.uf2" from `build/` on RP2350 drive
10997

11098
### Serial interface usage
11199
* type ' ' to display current settings

build_docker.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
#------------------------------------------------------
3+
# Copyright (c) 2026, Elehobica
4+
# Released under the BSD-2-Clause
5+
# refer to https://opensource.org/licenses/BSD-2-Clause
6+
#------------------------------------------------------
7+
#
8+
# Local Docker build script that mirrors .github/workflows/build-binaries.yml.
9+
# Uses the same SDK image as CI (elehobica/pico-sdk-dev-docker:sdk-2.3.0)
10+
# and runs cmake/make inside the container.
11+
#
12+
# This project targets rp2350 (Raspberry Pi Pico 2) only; the platform/board
13+
# are fixed in CMakeLists.txt, so no target selection is needed.
14+
#
15+
# Run it from anywhere; it builds this repository (the folder containing this
16+
# script), e.g.:
17+
# ./build_docker.sh # rp2350 build -> build/
18+
# ./build_docker.sh -k # incremental build (keep build/)
19+
20+
set -e
21+
22+
IMAGE="elehobica/pico-sdk-dev-docker:sdk-2.3.0"
23+
SDK_PATH_IN_IMAGE="/home/rp2dev/pico/pico-sdk" # PICO_SDK_PATH inside the container
24+
PROJECT_ROOT="$(cd "$(dirname "$0")" && pwd)" # repository root (has CMakeLists.txt)
25+
PROJECT_NAME="$(basename "$PROJECT_ROOT")"
26+
27+
# Read the Pico SDK version from pico_sdk_version.cmake inside the container.
28+
sdk_version() {
29+
docker run --rm "$IMAGE" bash -c '
30+
f="'"$SDK_PATH_IN_IMAGE"'/pico_sdk_version.cmake"
31+
maj=$(sed -n "s/^[[:space:]]*set(PICO_SDK_VERSION_MAJOR \([0-9]*\)).*/\1/p" "$f")
32+
min=$(sed -n "s/^[[:space:]]*set(PICO_SDK_VERSION_MINOR \([0-9]*\)).*/\1/p" "$f")
33+
rev=$(sed -n "s/^[[:space:]]*set(PICO_SDK_VERSION_REVISION \([0-9]*\)).*/\1/p" "$f")
34+
if [[ -n "$maj$min$rev" ]]; then echo "${maj}.${min}.${rev}"; else echo "unknown"; fi
35+
'
36+
}
37+
38+
usage() {
39+
cat <<EOF
40+
Usage: ./$(basename "$0") [options]
41+
42+
Builds this repository ($PROJECT_NAME) for rp2350 (Raspberry Pi Pico 2)
43+
inside the SDK Docker container. Output: build/
44+
45+
Options:
46+
-h, --help Show this help
47+
-k, --keep Keep build directory contents (incremental build)
48+
EOF
49+
}
50+
51+
KEEP=0
52+
53+
while [[ $# -gt 0 ]]; do
54+
case "$1" in
55+
-h|--help) usage; exit 0 ;;
56+
-k|--keep) KEEP=1 ;;
57+
*) echo "Unknown option: $1" >&2; usage; exit 1 ;;
58+
esac
59+
shift
60+
done
61+
62+
if [[ ! -f "$PROJECT_ROOT/CMakeLists.txt" ]]; then
63+
echo "error: CMakeLists.txt not found at $PROJECT_ROOT" >&2
64+
exit 1
65+
fi
66+
67+
echo "Project: $PROJECT_NAME"
68+
echo "Pico SDK version: $(sdk_version) (from $SDK_PATH_IN_IMAGE)"
69+
70+
# Run cmake/make inside the SDK container.
71+
# Args: $1=build_dir $2=extra cmake options (may be empty)
72+
run_build() {
73+
local build_dir="$1"
74+
local cmake_extra="$2"
75+
76+
if [[ "$KEEP" -eq 0 ]]; then
77+
rm -rf "$PROJECT_ROOT/$build_dir"
78+
fi
79+
mkdir -p "$PROJECT_ROOT/$build_dir"
80+
81+
docker run --rm \
82+
--user "$(id -u):$(id -g)" \
83+
-e HOME=/tmp \
84+
-e PICO_SDK_PATH="$SDK_PATH_IN_IMAGE" \
85+
-e PICO_EXTRAS_PATH=/home/rp2dev/pico/pico-extras \
86+
-e PICO_EXAMPLES_PATH=/home/rp2dev/pico/pico-examples \
87+
-v "$PROJECT_ROOT":/workspace \
88+
-w "/workspace/$build_dir" \
89+
"$IMAGE" \
90+
bash -c "cmake $cmake_extra /workspace && make -j\$(nproc)"
91+
}
92+
93+
echo "===== Build Pico 2 (rp2350) ====="
94+
run_build build ""
95+
96+
echo ""
97+
echo "===== Output ====="
98+
for uf2 in "$PROJECT_ROOT/build"/*.uf2; do
99+
[[ -f "$uf2" ]] && echo " build/$(basename "$uf2")"
100+
done

0 commit comments

Comments
 (0)