Skip to content

Commit 32949d5

Browse files
committed
Raspberry Pi Pico 2 support
1 parent 0a2bba1 commit 32949d5

File tree

5 files changed

+137
-34
lines changed

5 files changed

+137
-34
lines changed

Dockerfile

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
1-
FROM alpine:3.17.0
2-
3-
# Install toolchain
4-
RUN apk update && \
5-
apk upgrade && \
6-
apk add git \
7-
python3 \
8-
py3-pip \
9-
cmake \
10-
build-base \
11-
libusb-dev \
12-
bsd-compat-headers \
13-
newlib-arm-none-eabi \
14-
gcc-arm-none-eabi
1+
FROM ubuntu:24.10 AS gcc_build
2+
3+
# Build GCC RISC-V
4+
COPY ./install_gcc.sh /home/install_gcc.sh
5+
RUN bash /home/install_gcc.sh
6+
7+
FROM ubuntu:24.10 as sdk_setup
8+
9+
RUN apt-get update -y && \
10+
apt-get upgrade -y && \
11+
apt-get install --no-install-recommends -y \
12+
git \
13+
ca-certificates \
14+
python3 \
15+
tar \
16+
build-essential \
17+
gcc-arm-none-eabi \
18+
libnewlib-arm-none-eabi \
19+
libstdc++-arm-none-eabi-newlib \
20+
cmake && \
21+
apt-get clean && \
22+
rm -rf /var/lib/apt/lists/*
1523

1624
# Raspberry Pi Pico SDK
1725
ARG SDK_PATH=/usr/local/picosdk
18-
RUN git clone --depth 1 --branch 1.5.1 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \
26+
RUN git clone --depth 1 --branch 2.0.0 https://github.com/raspberrypi/pico-sdk $SDK_PATH && \
1927
cd $SDK_PATH && \
2028
git submodule update --init
2129

@@ -30,11 +38,16 @@ RUN git clone --depth 1 --branch V11.0.1 https://github.com/FreeRTOS/FreeRTOS-Ke
3038
ENV FREERTOS_KERNEL_PATH=$FREERTOS_PATH
3139

3240
# Picotool installation
33-
RUN git clone --depth 1 --branch 1.1.2 https://github.com/raspberrypi/picotool.git /home/picotool && \
41+
RUN git clone --depth 1 --branch 2.0.0 https://github.com/raspberrypi/picotool.git /home/picotool && \
3442
cd /home/picotool && \
3543
mkdir build && \
3644
cd build && \
3745
cmake .. && \
38-
make && \
39-
cp /home/picotool/build/picotool /bin/picotool && \
46+
make -j$(nproc) && \
47+
cmake --install . && \
4048
rm -rf /home/picotool
49+
50+
# Install GCC RISC-V
51+
COPY --from=gcc_build /opt/riscv/gcc14-rp2350-no-zcmp /opt/riscv/gcc14-rp2350-no-zcmp
52+
ENV PATH="$PATH:/opt/riscv/gcc14-rp2350-no-zcmp/bin"
53+

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Raspberry Pi Pico Docker SDK
44

5-
A lightweight SDK environment for Raspberry Pi Pico in a Docker container.
5+
A SDK environment for Raspberry Pi Pico 1 and 2 in a Docker container.
66

77
## Pulling the Image from Docker Hub and Running
88

@@ -50,8 +50,8 @@ Follow [this](https://code.visualstudio.com/docs/devcontainers/tutorial#_prerequ
5050

5151
#### Using the Dev Container for Pico IDE
5252

53-
- Clone [pico-dev-container](https://github.com/lukstep/pico-dev-container/tree/main) repository.
54-
- Open `pico-dev-container` folder in Visual Studio Code.
53+
- Clone [pico-template-project](https://github.com/lukstep/pico-template-project) repository.
54+
- Open `pico-template-project` folder in Visual Studio Code.
5555
- In VSCode, click the button in the bottom left corner of VSCode and select: Reopen in Container...
5656
![image-1](https://github.com/lukstep/raspberry-pi-pico-docker-sdk/assets/20487002/f1f06bca-cb0b-4c2d-bf4c-611ef004e70a)
5757
- Build the project.
@@ -60,6 +60,9 @@ Follow [this](https://code.visualstudio.com/docs/devcontainers/tutorial#_prerequ
6060

6161
## Pico Memory Flashing and Debugging via Pico Probe and OpenOCD
6262

63+
> [!WARNING]
64+
> OpenOCD not support RP2350 (Pico 2). Currently this part is only valid for RP2040 boards (Pico 1).
65+
6366
To work efficiently on the project, we need the ability to upload firmware to the microcontroller, debug, and communicate through the serial port. The Raspberry Pi Pico board itself allows for software uploads, but this process is not very convenient or efficient for larger projects. The Pico Probe extends the capabilities of the Raspberry Pi Pico board to include fast firmware uploads to the microcontroller's memory, debugging via Serial Wire Debug (SWD), and it also serves as a USB UART converter.
6467

6568
The Debug Probe is compatible with the CMSIS-DAP interface, allowing OpenOCD to be used as the debugger server. By using OpenOCD, it becomes possible to communicate between development containers and the Debug Probe via TCP. On Linux, the Docker container can communicate directly through COM ports. However, on Mac and Windows, this is not possible because Docker runs in a dedicated virtual machine that does not have access to COM ports. Therefore, a solution with the OpenOCD server on the host machine was chosen.
@@ -148,4 +151,6 @@ Refer [here](docs/vscode_manual_setup.md) for step-by-step instruction
148151

149152
[Raspberry Pi Debug Probe](https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html)
150153

154+
[Raspberry Pi Pico C/C++ SDK](https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf)
155+
151156
[OpenOCD project page](https://openocd.org)

install_gcc.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
RET_VALUE=$?
4+
RED='\033[0;31m'
5+
NC='\033[0m' # No Color
6+
7+
apt-get update -y && \
8+
apt-get upgrade -y && \
9+
apt-get install -y autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev
10+
11+
12+
if [ $RET_VALUE != 0 ]; then
13+
echo "${RED}Instalation failed!${NC}"
14+
exit 1
15+
fi
16+
17+
mkdir -p /opt/riscv/gcc14-rp2350-no-zcmp
18+
19+
chown -R "$(whoami)" /opt/riscv/gcc14-rp2350-no-zcmp
20+
21+
git clone --depth 1 https://github.com/riscv/riscv-gnu-toolchain /home/riscv-gnu-toolchain
22+
23+
if [ $RET_VALUE != 0 ]; then
24+
echo "${RED}Cloning RISC-V repo failed!${NC}"
25+
exit 1
26+
fi
27+
28+
cd /home/riscv-gnu-toolchain || exit
29+
30+
git clone --depth 1 https://github.com/gcc-mirror/gcc gcc-14 -b releases/gcc-14
31+
32+
if [ $RET_VALUE != 0 ]; then
33+
echo "${RED}Cloning GCC repo failed!${NC}"
34+
exit 1
35+
fi
36+
37+
./configure --prefix=/opt/riscv/gcc14-rp2350-no-zcmp \
38+
--with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-abi=ilp32 \
39+
--with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" \
40+
--with-gcc-src=`pwd`/gcc-14
41+
42+
if [ $RET_VALUE != 0 ]; then
43+
echo "${RED}Configure failed!${NC}"
44+
exit 1
45+
fi
46+
47+
make -j$(nproc)
48+
49+
cd /home || exit
50+
51+
rm -rf /home/riscv-gnu-toolchain

test_poject/CMakeLists.txt

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
cmake_minimum_required(VERSION 3.13)
22

3-
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
4-
3+
include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)
54
project(sample C CXX ASM)
65

7-
set(CMAKE_C_COMPILER /usr/bin/arm-none-eabi-gcc CACHE PATH "" FORCE)
8-
set(CMAKE_CXX_COMPILER /usr/bin/arm-none-eabi-g++ CACHE PATH "" FORCE)
9-
106
set(CMAKE_C_STANDARD 11)
117
set(CMAKE_CXX_STANDARD 17)
128

test_sdk.sh

100644100755
+46-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,53 @@
1+
#! /usr/bin/env bash
2+
3+
RED="\e[31m"
4+
GREEN="\e[32m"
5+
NC="\e[0m"
6+
STATUS=0
7+
18
if [[ -z $1 ]]; then
29
echo "Please provide an SDK image you want to test"
310
fi
411

5-
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD}/test_poject,target=/home/dev $1
6-
docker exec pico-sdk /bin/sh -c "cd /home/dev && mkdir build && cd build && cmake .. && make -j4"
7-
docker exec pico-sdk /bin/sh -c "picotool"
8-
docker container kill pico-sdk
9-
docker container rm pico-sdk
12+
declare -a boards=("pico" "pico_w" "pico2" "pico2_riscv")
13+
14+
15+
docker run -d -it --name pico-sdk --mount type=bind,source="${PWD}"/test_poject,target=/home/dev "$1"
16+
17+
for board in "${boards[@]}"
18+
do
19+
echo "---- $board build test ----"
20+
docker exec pico-sdk /bin/bash -c "rm -rf /home/dev/build"
21+
if [[ $board = pico2_riscv ]] ; then
22+
docker exec -i pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-riscv && make -j4"
23+
else
24+
docker exec -i pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=${board} && make -j4"
25+
fi
26+
if [ $? != 0 ]; then
27+
echo -e "${RED}----- Test failed -----${NC}"
28+
STATUS=1
29+
break
30+
fi
31+
echo "${GREEN}----- Test passed -----${NC}"
32+
done
1033

11-
docker run -d -it --name pico-sdk --mount type=bind,source=${PWD}/freertos_test_project,target=/home/dev $1
12-
docker exec pico-sdk /bin/sh -c "cd /home/dev && mkdir build && cd build && cmake .. && make -j4"
13-
docker exec pico-sdk /bin/sh -c "picotool"
1434
docker container kill pico-sdk
1535
docker container rm pico-sdk
36+
37+
exit ${STATUS}
38+
39+
# for board in "${boards[@]}"
40+
# do
41+
# echo "FreeRTOS $board build test"
42+
# docker run -d -it --name pico-sdk --mount type=bind,source=${PWD}/freertos_test_project,target=/home/dev $1
43+
# if [[ $board -eq "pico2_riscv" ]] ; then
44+
# docker exec pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=pico2 -DPICO_PLATFORM=rp2350-riscv && make -j4"
45+
# else
46+
# docker exec pico-sdk /bin/bash -c "cd /home/dev && mkdir build && cd build && cmake .. -DPICO_BOARD=${board} && make -j4 && cd .. && rm -rf build"
47+
# fi
48+
# docker exec pico-sdk /bin/bash -c "rm -rf /home/dev/build"
49+
# docker container kill pico-sdk
50+
# docker container rm pico-sdk
51+
# rm -rf ./test_poject/build/
52+
# done
53+

0 commit comments

Comments
 (0)