feat(bsp): Raspberry Pi 5 Support (PoC on Tutorial 19)#233
feat(bsp): Raspberry Pi 5 Support (PoC on Tutorial 19)#233devansh-lodha wants to merge 5 commits intorust-embedded:masterfrom
Conversation
|
@devansh-lodha Thanks so much for this! It looks like a huge pile of work, done well. I'm not sure what the best overall merge strategy is. For now, I'd honestly suggest you hold until we have a stable version of https://github.com/FlamingosProject/flamingos-preview that we believe in; probably a couple weeks. PM me somewhere and we will invite you to our weekly meeting where we're working on that if you like 😀 . The Raspberry Pi Debug Probe solution looks great; thanks for working that out. It looks like it should work with Pi 4 as well? Let us think a bit about the way forward. I really don't want you to have to backport your thing here, and then you or we do it again in a few weeks. Documentation-wise, we are keeping the non-patch portion of the READMEs. I would suggest you wait on documenting until backporting, and then stick the relevant in stuff in the README where it is introduced. |
|
Understood. I will hold off on backporting and documentation updates to avoid redundant work given the transition to Flamingos. I am happy to coordinate on the new architecture and will definitely reach out to discuss more! Regarding Debug Probe on Pi 4: Regarding CI Failures: Thank you! |
Description
This PR introduces support for the Raspberry Pi 5 (BCM2712). Unlike previous generations, the Pi 5 utilizes a disaggregated architecture (Cortex-A76 SoC connected via PCIe to the RP1 Southbridge), mandating a strict hierarchical driver initialization order.
I am aware (per feedback on my previous draft) that a major rebuild of the tutorial series is in progress.
I am submitting this PR primarily to establish the hardware support logic for the BCM2712/RP1.
Regardless of how the future tutorial structure looks, the hardware constraints (PCIe BAR mapping, MSI-X/MIP routing, edge-triggering) remain constant. This PR proves that this logic works and fits cleanly into a modular driver architecture. I hope this can serve as the "Reference Implementation" for Pi 5 support in the new version, or be merged now to unblock Pi 5 users in the interim.
To validate this architecture without introducing churn across all 20 tutorials, this is implemented as a Vertical Slice on Tutorial 19 (Kernel Heap). This tutorial was selected because it exercises the complete kernel stack (MMU, Dynamic Allocation, Interrupts), providing the strongest proof of correctness.
1. Architectural Implementation
I have adhered strictly to the repository's existing structure, avoiding the creation of a separate
raspberrypi5BSP folder in favor of#[cfg(feature = "bsp_rpi5")]gates.Boot Orchestration (
driver.rs): Implemented a specialized boot sequence for Pi 5:0xFFFF_F000to the CPU Physical Address0x10_0013_0000(MIP Doorbell). This allows the RP1 to trigger MSI-X interrupts.Interrupt Subsystem:
BCM2712InterruptControllerwhich wraps the standardGICv2driver. It handles the BCM2712-specific MIP (Machine Interrupt Peripheral) configuration required to route PCIe MSI-X traffic to GIC SPIs.GICv2driver to support Edge-triggered interrupts (required for RP1 logic), whereas Pi 4 uses Level triggers.2. Workflow & Tooling
The Pi 5 introduces the dedicated Raspberry Pi Debug Probe, necessitating a move away from the legacy UART-based
chainloaderworkflow to a professional SWD (JTAG) workflow.debug/pi5/containing OpenOCD (CMSIS-DAP) and GDB initialization scripts.X2_pi5_jtag_halt_stub): Added a standalone project (analogous toX1) that builds a minimalwfeloop binary.make jtagboot BSP=rpi5: Builds the Halt Stub and instructs the user to copy it to the SD card.make openocd BSP=rpi5: Connects via Debug Probe.make gdb BSP=rpi5: Loads the kernel ELF directly into RAM via DMA and begins execution.Pre-commit steps
make testpass.clippy../contributor_setup.shfollowed by./devtool ready_for_publishdevtoolto includerpi5in the global loop, as this PR only targets Tutorial 19.BSP=rpi5 make clippyandcargo fmtinside19_kernel_heap.Questions for Maintainers
19_kernel_heap/README.mdexplaining the Pi 5 hardware differences, or does this merit a separate document?MakefileandBSPprimitives to Tutorials 01-18 in follow-up PRs. I did not port Tutorial 20 since it looks like the original author left it open for further modifications and hence I've considered up-to Tutorial 19 as "complete" as per the original author.