Skip to content

Commit 7e22575

Browse files
Merge pull request #30 from philipstarkey/philipstarkey/rp235x
Add support for Pico 2 (RP2350) - faster clock speeds and more instructions!
2 parents 9020318 + 0197a35 commit 7e22575

File tree

9 files changed

+216
-130
lines changed

9 files changed

+216
-130
lines changed

.github/workflows/build.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
uses: actions/upload-artifact@v4
2626
with:
2727
name: prawnblaster-firmware-${{ github.sha }}
28-
path: build/prawnblaster/*.uf2
28+
path: build_*/prawnblaster/*.uf2
2929

3030
- name: Create release
3131
if: (github.event_name == 'push' && contains(github.ref, '/tags'))
@@ -35,5 +35,7 @@ jobs:
3535
prerelease: false
3636
files: |
3737
LICENSE.txt
38-
build/prawnblaster/prawnblaster.uf2
39-
build/prawnblaster/prawnblasteroverclock.uf2
38+
build_rp2040/prawnblaster/prawnblaster_rp2040.uf2
39+
build_rp2350/prawnblaster/prawnblaster_rp2350.uf2
40+
build_rp2040/prawnblaster/prawnblaster_rp2040_overclock.uf2
41+
build_rp2350/prawnblaster/prawnblaster_rp2350_overclock.uf2

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
build/*
1+
build*/*
2+
pico_sdk_import.cmake

CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.17)
22

33
# Pull in PICO SDK (must be before project)
44
include(pico_sdk_import.cmake)
55

6-
project(pico_examples C CXX ASM)
6+
project(prawnblaster C CXX ASM)
77
set(CMAKE_C_STANDARD 11)
88
set(CMAKE_CXX_STANDARD 17)
99

1010

1111
# Initialize the SDK
1212
pico_sdk_init()
1313

14-
# Add blink example
14+
# Add project directory
1515
add_subdirectory(prawnblaster)
16-

docker-compose.yaml

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
name: prawnblaster
22

33
services:
4-
buildfirmware:
4+
firmware_base:
55
build:
66
dockerfile: docker/Dockerfile
7-
command: /bin/bash -c 'cmake .. && make'
7+
image: prawnblaster/build-firmware
88
volumes:
99
- .:/prawnblaster
10-
working_dir: /prawnblaster/build
10+
command: /bin/bash -c 'cp /pico/pico-sdk/external/pico_sdk_import.cmake /prawnblaster/'
11+
container_name: firmware_base
12+
13+
build_rp2040_firmware:
14+
image: prawnblaster/build-firmware
15+
command: /bin/bash -c 'cmake .. -D PICO_PLATFORM=rp2040 && make'
16+
volumes:
17+
- .:/prawnblaster
18+
working_dir: /prawnblaster/build_rp2040
19+
init: true
20+
depends_on:
21+
- firmware_base
22+
build_rp2350_firmware:
23+
image: prawnblaster/build-firmware
24+
command: /bin/bash -c 'cmake .. -D PICO_PLATFORM=rp2350 && make'
25+
volumes:
26+
- .:/prawnblaster
27+
working_dir: /prawnblaster/build_rp2350
1128
init: true
29+
depends_on:
30+
- firmware_base

docker/Dockerfile

+19-4
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,39 @@ ARG APT_MIRROR="mirror://mirrors.ubuntu.com/mirrors.txt"
66
# ARG APT_MIRROR="http://mirror.aarnet.edu.au/pub/ubuntu/archive/"
77

88
# 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
9+
RUN sed -i "s#htt[p|ps]://archive.ubuntu.com/ubuntu/#$APT_MIRROR#g" /etc/apt/sources.list.d/ubuntu.sources
1010

1111
# Install packages
1212
RUN \
1313
apt update && \
1414
apt install -y git python3 && \
15-
apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
15+
# For Pico SDK
16+
apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib build-essential
1617

1718
# Install Pico SDK into a new stage
18-
FROM base as buildtools
19+
FROM base AS buildtools
1920

21+
# Install Pico SDK
2022
RUN \
2123
mkdir -p /pico/ && \
2224
cd /pico/ && \
23-
git clone https://github.com/raspberrypi/pico-sdk.git --branch 1.5.1 && \
25+
git clone https://github.com/raspberrypi/pico-sdk.git --branch 2.1.1 && \
2426
cd pico-sdk/ && \
2527
git submodule update --init && \
2628
cd /
2729

2830
# Set the Pico SDK environment variable
2931
ENV PICO_SDK_PATH=/pico/pico-sdk/
32+
33+
# Install picotool
34+
# ensure versions of sdk and picotool match
35+
RUN \
36+
git clone https://github.com/raspberrypi/picotool.git --branch 2.1.1 && \
37+
cd picotool && \
38+
mkdir build && \
39+
cd build && \
40+
cmake .. && \
41+
make -j$(nproc) && \
42+
cmake --install . && \
43+
cd ../.. && \
44+
rm -rf picotool

pico_sdk_import.cmake

-62
This file was deleted.

prawnblaster/CMakeLists.txt

+49-30
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,49 @@
1-
add_executable(prawnblaster
2-
prawnblaster.cpp
3-
fast_serial.c
4-
)
5-
6-
pico_generate_pio_header(prawnblaster ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)
7-
8-
9-
# Pull in our pico_stdlib which aggregates commonly used features
10-
target_link_libraries(prawnblaster pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
11-
target_include_directories(prawnblaster PRIVATE .)
12-
13-
# create map/bin/hex/uf2 file etc.
14-
pico_add_extra_outputs(prawnblaster)
15-
16-
add_executable(prawnblasteroverclock
17-
prawnblaster.cpp
18-
fast_serial.c
19-
)
20-
21-
pico_generate_pio_header(prawnblasteroverclock ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)
22-
23-
set_target_properties(prawnblasteroverclock PROPERTIES COMPILE_DEFINITIONS PRAWNBLASTER_OVERCLOCK=1)
24-
25-
# Pull in our pico_stdlib which aggregates commonly used features
26-
target_link_libraries(prawnblasteroverclock pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
27-
target_include_directories(prawnblasteroverclock PRIVATE .)
28-
29-
# create map/bin/hex/uf2 file etc.
30-
pico_add_extra_outputs(prawnblasteroverclock)
1+
set(overclocks 0;1)
2+
3+
foreach (overclock IN LISTS overclocks)
4+
# Compute firmware name
5+
set(firmware_name prawnblaster)
6+
if(PICO_PLATFORM MATCHES "^rp2350")
7+
set(firmware_name "${firmware_name}_rp2350")
8+
else()
9+
set(firmware_name "${firmware_name}_${PICO_PLATFORM}")
10+
endif()
11+
if(overclock)
12+
set(firmware_name "${firmware_name}_overclock")
13+
endif()
14+
15+
add_executable(${firmware_name} prawnblaster.cpp fast_serial.c)
16+
17+
pico_generate_pio_header(${firmware_name} ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)
18+
19+
# Pass in number of instructions to firmware as a compiler definition
20+
set(num_instructions 30000)
21+
if(PICO_PLATFORM MATCHES "^rp2350")
22+
set(num_instructions 60000)
23+
endif()
24+
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_NUM_INSTRUCTIONS=${num_instructions}")
25+
26+
# Pass in board type to firmware as a compiler definition. Note that PICO_BOARD is passed in by the SDK, but it's passed in a string which isn't valid and so I can't use it...
27+
# This is also, to some extent, a duplicate of the above PRAWNBLASTER_NUM_INSTRUCTIONS but I think it makes sense to keep these seperate.
28+
if (PICO_BOARD STREQUAL "pico")
29+
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=1")
30+
elseif (PICO_BOARD STREQUAL "pico2")
31+
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=2")
32+
else ()
33+
message(FATAL_ERROR "Unsupported PICO_BOARD")
34+
endif()
35+
36+
37+
# Pass in overclock state to firmware as a compiler definition
38+
if(overclock)
39+
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_OVERCLOCK=1")
40+
endif()
41+
42+
# Pull in our pico_stdlib which aggregates commonly used features
43+
target_link_libraries(${firmware_name} pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
44+
target_include_directories(${firmware_name} PRIVATE .)
45+
46+
# create map/bin/hex/uf2 file etc.
47+
pico_add_extra_outputs(${firmware_name})
48+
49+
endforeach()

0 commit comments

Comments
 (0)