Skip to content

feat(rp2040): support RAM-only UF2 loads#1072

Merged
zackees merged 1 commit into
mainfrom
fix/1049-rp2040-ram-uf2
Jul 15, 2026
Merged

feat(rp2040): support RAM-only UF2 loads#1072
zackees merged 1 commit into
mainfrom
fix/1049-rp2040-ram-uf2

Conversation

@zackees

@zackees zackees commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

  • accept canonical RP2040 UF2 pages targeting main SRAM or XIP-cache SRAM
  • reject mixed flash/RAM images, out-of-range pages, wraparound, overlap, and guessed RP2350 RAM layouts
  • preserve raw BIN as flash-only
  • return a truthful RAM load accepted outcome without waiting for runtime CDC
  • use O(n log n) interval validation for large UF2 images

Why

The attached Pico 1 already enters ROM USB, but every flash UF2 stalls on the first erase/program. Raspberry Pi's boot ROM supports RAM UF2 independently of QSPI, making it the decisive transport-vs-flash discriminator.

Validation

  • soldr cargo test -p fbuild-deploy: 188 passed, 8 ignored
  • soldr cargo clippy -p fbuild-deploy --all-targets -- -D warnings: passed (existing workspace MSRV warning only)
  • high-reasoning self-review: clean after replacing an initial quadratic overlap check
  • attached Pico 1, fbuild-only: two RAM UF2 cycles detached and re-enumerated RPI-RP2 automatically; DEVPKEY_Device_LastArrivalDate advanced; zero new Windows Disk 51/153 events
  • no BOOTSEL press, PC reboot, driver change, PlatformIO deploy, or GPIO

Supports #1049.

Summary by CodeRabbit

  • New Features

    • Added support for loading compatible RP2040 images directly into volatile RAM.
    • RAM loads are validated for supported memory regions, alignment, completeness, and overlap issues.
    • Deployment now reports a clear “RAM load accepted” result when non-volatile programming is not performed.
  • Bug Fixes

    • Invalid, mixed flash/RAM, incomplete, and overlapping RAM images are now rejected with validation errors.

@zackees
zackees merged commit 8f7e860 into main Jul 15, 2026
79 of 92 checks passed
@zackees
zackees deleted the fix/1049-rp2040-ram-uf2 branch July 15, 2026 08:41
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1ec4ef39-f9dc-4b9d-9c9e-fb8c2b09eb03

📥 Commits

Reviewing files that changed from the base of the PR and between 209f4b4 and 8f11ff5.

📒 Files selected for processing (2)
  • crates/fbuild-deploy/src/lib.rs
  • crates/fbuild-deploy/src/rp2040.rs

📝 Walkthrough

Walkthrough

RP2040 deployment now validates UF2 images as flash or RAM targets. RAM images produce a RamLoad result without non-volatile programming or CDC runtime recovery, while flash images retain the existing deployment path.

Changes

RP2040 RAM deployment

Layer / File(s) Summary
RAM load outcome contract
crates/fbuild-deploy/src/lib.rs
Adds DeployOutcome::RamLoad, documents the expanded outcome set, formats it as "RAM load accepted", and tests the description.
UF2 target classification
crates/fbuild-deploy/src/rp2040.rs
Adds RP2040 SRAM address ranges and returns Uf2Target from UF2 validation after checking metadata, target consistency, duplicates, alignment, and overlaps.
RAM deployment branch and coverage
crates/fbuild-deploy/src/rp2040.rs
Passes the target through artifact preparation, returns a RAM-load result before CDC handling, and tests valid, mixed, invalid, and overlapping RAM images.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DeployMethod
  participant prepare_uf2_artifact
  participant validate_uf2
  participant CDC_Runtime
  DeployMethod->>prepare_uf2_artifact: prepare UF2 artifact
  prepare_uf2_artifact->>validate_uf2: validate and classify UF2
  validate_uf2-->>prepare_uf2_artifact: Uf2Target::Ram or Uf2Target::Flash
  prepare_uf2_artifact-->>DeployMethod: artifact and target
  DeployMethod->>DeployMethod: return RamLoad for RAM target
  DeployMethod->>CDC_Runtime: discover or recover runtime port for flash target
Loading

Possibly related PRs

  • FastLED/fbuild#1046: Updates related RP2040 UF2 address mapping and validation logic.
  • FastLED/fbuild#1050: Modifies related RP2040 UF2 preparation, validation, and deployment flow behavior.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1049-rp2040-ram-uf2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant