Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Pico 2 (RP2350) #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: prawnblaster-firmware-${{ github.sha }}
path: build/prawnblaster/*.uf2
path: build_*/prawnblaster/*.uf2

- name: Create release
if: (github.event_name == 'push' && contains(github.ref, '/tags'))
Expand All @@ -35,5 +35,7 @@ jobs:
prerelease: false
files: |
LICENSE.txt
build/prawnblaster/prawnblaster.uf2
build/prawnblaster/prawnblasteroverclock.uf2
build_rp2040/prawnblaster/prawnblaster_rp2040.uf2
build_rp2350/prawnblaster/prawnblaster_rp2350.uf2
build_rp2040/prawnblaster/prawnblaster_rp2040_overclock.uf2
build_rp2350/prawnblaster/prawnblaster_rp2350_overclock.uf2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/*
build*/*
pico_sdk_import.cmake
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
cmake_minimum_required(VERSION 3.13)
cmake_minimum_required(VERSION 3.17)

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

project(pico_examples C CXX ASM)
project(prawnblaster C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)


# Initialize the SDK
pico_sdk_init()

# Add blink example
# Add project directory
add_subdirectory(prawnblaster)

25 changes: 22 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
name: prawnblaster

services:
buildfirmware:
firmware_base:
build:
dockerfile: docker/Dockerfile
command: /bin/bash -c 'cmake .. && make'
image: prawnblaster/build-firmware
volumes:
- .:/prawnblaster
working_dir: /prawnblaster/build
command: /bin/bash -c 'cp /pico/pico-sdk/external/pico_sdk_import.cmake /prawnblaster/'
container_name: firmware_base

build_rp2040_firmware:
image: prawnblaster/build-firmware
command: /bin/bash -c 'cmake .. -D PICO_PLATFORM=rp2040 && make'
volumes:
- .:/prawnblaster
working_dir: /prawnblaster/build_rp2040
init: true
depends_on:
- firmware_base
build_rp2350_firmware:
image: prawnblaster/build-firmware
command: /bin/bash -c 'cmake .. -D PICO_PLATFORM=rp2350 && make'
volumes:
- .:/prawnblaster
working_dir: /prawnblaster/build_rp2350
init: true
depends_on:
- firmware_base
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@ ARG APT_MIRROR="mirror://mirrors.ubuntu.com/mirrors.txt"
# ARG APT_MIRROR="http://mirror.aarnet.edu.au/pub/ubuntu/archive/"

# Configure mirror. Pass --build-arg APT_MIRROR=<mirror URL> to set a mirror if this is slow
RUN sed -i "s#htt[p|ps]://archive.ubuntu.com/ubuntu/#$APT_MIRROR#g" /etc/apt/sources.list
RUN sed -i "s#htt[p|ps]://archive.ubuntu.com/ubuntu/#$APT_MIRROR#g" /etc/apt/sources.list.d/ubuntu.sources

# Install packages
RUN \
apt update && \
apt install -y git python3 && \
apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
# For Pico SDK
apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib build-essential

# Install Pico SDK into a new stage
FROM base as buildtools

# Install Pico SDK
RUN \
mkdir -p /pico/ && \
cd /pico/ && \
git clone https://github.com/raspberrypi/pico-sdk.git --branch 1.5.1 && \
git clone https://github.com/raspberrypi/pico-sdk.git --branch 2.0.0 && \
cd pico-sdk/ && \
git submodule update --init && \
cd /
Expand Down
62 changes: 0 additions & 62 deletions pico_sdk_import.cmake

This file was deleted.

79 changes: 49 additions & 30 deletions prawnblaster/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
add_executable(prawnblaster
prawnblaster.cpp
fast_serial.c
)

pico_generate_pio_header(prawnblaster ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)


# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(prawnblaster pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
target_include_directories(prawnblaster PRIVATE .)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(prawnblaster)

add_executable(prawnblasteroverclock
prawnblaster.cpp
fast_serial.c
)

pico_generate_pio_header(prawnblasteroverclock ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)

set_target_properties(prawnblasteroverclock PROPERTIES COMPILE_DEFINITIONS PRAWNBLASTER_OVERCLOCK=1)

# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(prawnblasteroverclock pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
target_include_directories(prawnblasteroverclock PRIVATE .)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(prawnblasteroverclock)
set(overclocks 0;1)

foreach (overclock IN LISTS overclocks)
# Compute firmware name
set(firmware_name prawnblaster)
if(PICO_PLATFORM MATCHES "^rp2350")
set(firmware_name "${firmware_name}_rp2350")
else()
set(firmware_name "${firmware_name}_${PICO_PLATFORM}")
endif()
if(overclock)
set(firmware_name "${firmware_name}_overclock")
endif()

add_executable(${firmware_name} prawnblaster.cpp fast_serial.c)

pico_generate_pio_header(${firmware_name} ${CMAKE_CURRENT_LIST_DIR}/pseudoclock.pio)

# Pass in number of instructions to firmware as a compiler definition
set(num_instructions 30000)
if(PICO_PLATFORM MATCHES "^rp2350")
set(num_instructions 60000)
endif()
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_NUM_INSTRUCTIONS=${num_instructions}")

# 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...
# This is also, to some extent, a duplicate of the above PRAWNBLASTER_NUM_INSTRUCTIONS but I think it makes sense to keep these seperate.
if (PICO_BOARD STREQUAL "pico")
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=1")
elseif (PICO_BOARD STREQUAL "pico2")
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_PICO_BOARD=2")
else ()
message(FATAL_ERROR "Unsupported PICO_BOARD")
endif()


# Pass in overclock state to firmware as a compiler definition
if(overclock)
target_compile_definitions(${firmware_name} PUBLIC "PRAWNBLASTER_OVERCLOCK=1")
endif()

# Pull in our pico_stdlib which aggregates commonly used features
target_link_libraries(${firmware_name} pico_stdlib hardware_pio pico_multicore pico_unique_id hardware_clocks hardware_dma tinyusb_device tinyusb_board)
target_include_directories(${firmware_name} PRIVATE .)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(${firmware_name})

endforeach()
Loading