-
Notifications
You must be signed in to change notification settings - Fork 206
Add support for RP2350 aka Raspberry Pi Pico 2 #2210
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
Open
thenewwazoo
wants to merge
5
commits into
oxidecomputer:master
Choose a base branch
from
thenewwazoo:bmatt/rp2350
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6475620
Add support for RP2350 aka Raspberry Pi Pico 2
thenewwazoo 5186a01
Make the Pi Pico 2's external flash a bit more obvious
thenewwazoo 27d44dc
Add test runner for RPi Pico 2
thenewwazoo 23db079
Put the firmware map file in dist
thenewwazoo 198fc9c
Typo fix in caboose doc
thenewwazoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
edition = "2021" | ||
readme = "README.md" | ||
name = "demo-pi-pico-2" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
cortex-m = { workspace = true } | ||
cortex-m-rt = { workspace = true } | ||
cfg-if = { workspace = true } | ||
rp235x-pac = { workspace = true, features = ["rt"] } | ||
|
||
kern = { path = "../../sys/kern", default-features = false } | ||
|
||
[build-dependencies] | ||
build-util = {path = "../../build/util"} | ||
|
||
# this lets you use `cargo fix`! | ||
[[bin]] | ||
name = "demo-pi-pico-2" | ||
test = false | ||
doctest = false | ||
bench = false | ||
|
||
[lints] | ||
workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Raspberry Pi Pico 2 demo application | ||
|
||
This is a minimal application to demonstrate support for the Raspberry Pi Pico 2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name = "demo-pi-pico-2" | ||
target = "thumbv8m.main-none-eabihf" | ||
chip = "../../chips/rp235x" | ||
board = "pi-pico-2" | ||
memory = "memory-pico-2.toml" | ||
stacksize = 944 | ||
|
||
[kernel] | ||
name = "demo-pi-pico-2" | ||
requires = {flash = 20000, ram = 1136} | ||
stacksize = 640 | ||
|
||
[tasks.jefe] | ||
name = "task-jefe" | ||
priority = 0 | ||
max-sizes = {flash = 4096, ram = 512} | ||
start = true | ||
stacksize = 352 | ||
notifications = ["fault", "timer"] | ||
|
||
[tasks.idle] | ||
name = "task-idle" | ||
priority = 5 | ||
max-sizes = {flash = 128, ram = 256} | ||
stacksize = 256 | ||
start = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
fn main() { | ||
build_util::expose_target_board(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
#![no_std] | ||
#![no_main] | ||
|
||
// We have to do this if we don't otherwise use it to ensure its vector table | ||
// gets linked in. | ||
use rp235x_pac as _; | ||
|
||
use cortex_m_rt::entry; | ||
|
||
/// Image definition to set up the chip for booting | ||
/// | ||
/// See datasheet 5.1.4 Image Definitions for more. These specific values come from | ||
/// section 5.9.5. Minimum viable image metadata. | ||
#[link_section = ".image_def"] | ||
#[used] | ||
pub static RP235X_IMAGE_DEF_ARM_MIN: [u32; 5] = [ | ||
0xFFFF_DED3, // START | ||
0x1021_0142, // PICOBIN_BLOCK_ITEM_1BS_IMAGE_TYPE, (EXE | S-mode | ARM | RP2350) | ||
0x0000_01FF, // PICOBIN_BLOCK_ITEM_2BS_LAST, (size=1 word) | ||
0x0000_0000, // next = self | ||
0xAB12_3579, // END | ||
]; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let p = unsafe { rp235x_pac::Peripherals::steal() }; | ||
|
||
p.RESETS.reset().modify(|_, w| w.io_bank0().clear_bit()); | ||
while !p.RESETS.reset_done().read().io_bank0().bit() {} | ||
|
||
// TODO fix/update this for RP2350 | ||
let cycles_per_ms = if p.CLOCKS.clk_sys_ctrl().read().src().is_clk_ref() { | ||
// This is the reset state, so we'll assume we launched directly from | ||
// flash running on the ROSC. | ||
6_000 // ish | ||
} else { | ||
// This is _not_ the reset state, so we'll assume that the pico-debug | ||
// resident debugger has reconfigured things to run off the 48 MHz USB | ||
// clock. | ||
48_000 | ||
}; | ||
|
||
unsafe { kern::startup::start_kernel(cycles_per_ms) } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[probe-rs] | ||
chip-name = "rp235x" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[resets] | ||
address = 0x4002_0000 # 2.2.4. APB registers | ||
size = 32 | ||
|
||
[sio] | ||
address = 0xd000_0000 # 2.2.6. Core-local peripherals (SIO) | ||
size = 512 | ||
|
||
[spi0] | ||
address = 0x4008_0000 # 12.3.5 List of registers | ||
size = 0x1000 | ||
interrupts = { irq = 31 } # SPI0_IRQ from 3.2 Interrupts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[[flash]] | ||
address = 0x1000_0000 # 2.2. Address map "XIP 0x10000000" | ||
# NOTE: RP235x flash is external, so the value here is a property of the Pico 2, not the RP2350 | ||
# itself. Update to suit your actual hardware. | ||
size = 0x40_0000 # Pico 2 datasheet: "RP2350 microcontroller with 4 MB of flash memory" | ||
read = true | ||
execute = true | ||
|
||
[[ram]] | ||
address = 0x2000_0000 # 4.2. SRAM "SRAM is mapped to system addresses starting at 0x20000000." | ||
size = 0x8_2000 # 4.2. SRAM "There is a total of 520 kB (520 × 1024 bytes) of on-chip SRAM." | ||
read = true | ||
write = true | ||
execute = false # 4.2. SRAM "you can use any bank to store processor code, data buffers, or a | ||
# mixture of the two." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
gdb_port 3340 | ||
telnet_port 4450 | ||
|
||
# OpenOCD configuration for the RP235x | ||
source [find interface/cmsis-dap.cfg] | ||
source [find target/rp2350.cfg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
target extended-remote :3333 | ||
|
||
# print demangled symbols | ||
set print asm-demangle on | ||
|
||
# set backtrace limit to not have infinite backtrace loops | ||
set backtrace limit 32 | ||
|
||
# detect hard faults | ||
break HardFault | ||
|
||
monitor arm semihosting enable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: This seems like it should rather be a
repr(C)
struct with named fields instead of an array with commented indexes.nitpick: I'd personally go with
usize
types since these seem to be addresses, though the Hubris codebase does useu32
for addresses very often. It makes sense in the APIs but (IMO) less so inside the services / tasks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this should eventually be a
repr(C)
struct since it encodes fields with values and flags (in 5.9.3.1). For now I've gone with the raw bytes described in the datasheet (5.9.5.1) since it's an MVP and I'm not even sure Oxide wants this in their repo 😆 If I get any sort of encouragement from them, I expect I'll expand on this and other aspects of the PR.As for
u32
vsusize
, in the ultimate structure, it'd be a mix of types, withu8
/u16
/u32
for values andusize
for the address, as noted. For now, it's justu32
bytes straight out of the datasheet.