feat(bsp): Raspberry Pi 5 Support (PoC on Tutorial 19) #233
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.
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.