PolarFire SoC M-Mode LPDDR4 + minimal SBI runtime#774
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds standalone wolfBoot M-mode support for the PolarFire SoC MPFS250T Video Kit, including LPDDR4 bring-up (replacing HSS in the early boot path) and Linux S-mode handoff plumbing.
Changes:
- Enhance SDHCI diagnostics and reliability workarounds (CMD0→CMD8 delay, single-block read option, capability logging).
- Extend RISC-V M-mode boot flow with a reusable M→S handoff API and MPFS-specific “release U54 hart” implementation.
- Introduce MPFS250 DDR/PHY init infrastructure, build-time enablement via
LIBERO_FPGA_CONFIG_DIR, new config template, and CI build job.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/sdhci.c | Adds richer error logging, controller register dump, and reliability workarounds for Cadence SD4HC. |
| src/boot_riscv.c | Adds trap register dump support (regs frame) and factors M→S handoff into overridable helpers. |
| hal/mpfs250.h | Adds MPFS250 peripheral bits and extensive DDRC/PHY register definitions + DDR init declarations. |
| hal/mpfs250.c | Implements MPFS250 DDR/PLL/PHY init, M→S boot on a U54 via IPI handoff, and UART reinit after PLL. |
| docs/Targets.md | Documents new “M-Mode + DDR” configuration and build-time Libero config integration. |
| config/examples/polarfire_mpfs250_m.config | Adds new example config for M-mode + LPDDR4 + SD + S-mode Linux boot. |
| arch.mk | Enables MPFS DDR init when LIBERO_FPGA_CONFIG_DIR is provided (adds -DMPFS_DDR_INIT and include path). |
| .github/workflows/test-configs.yml | Adds CI build job for the new MPFS250 M-mode + DDR config template. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
115db4a to
776474f
Compare
4310c4b to
730fa69
Compare
82a4de3 to
036fee2
Compare
| * boards where CPU writes to the load destination do not land (e.g. the | ||
| * PolarFire MPFS250 DDR, where cached writes thrash L2 Scratch) override this | ||
| * with a DMA-based copy (see hal/mpfs250.c). */ | ||
| void __attribute__((weak)) wolfBoot_fit_memcpy(void *dst, const void *src, |
There was a problem hiding this comment.
it seems that PDMA copy could fail when DMA-based copy is on, and the error is not propagated. This is not a security issue, but missed DMA copy might let the callers panic explicitly if a void* is returned
| if (chunk > (1024U * 1024U)) { | ||
| chunk = 1024U * 1024U; | ||
| } | ||
| (void)mpfs_pdma_memcpy((void *)(d + off), |
There was a problem hiding this comment.
Error propagation; see comment on wolfBoot_fit_memcpy weak prototype
| STACK_SIZE_PER_HART ?= 0 | ||
| CFLAGS+=-DSTACK_SIZE_PER_HART=$(STACK_SIZE_PER_HART) |
There was a problem hiding this comment.
Should those be gated by RISC-V arch only?
Summary
wolfBoot runs standalone in M-mode on the E51 monitor core, replacing both HSS and OpenSBI: it brings up LPDDR4 in software, secure-boots a signed Yocto FIT from SD, and stays resident as a minimal SBI runtime so the U54 cores boot Linux. Result: secure-boot 4-CPU SMP Yocto Linux to a login prompt in ~40 s from power-on, with no Microchip firmware in the boot chain.
Commits
src/ddr_cadence.c+include/ddr_cadence.h; the Microchip PHY/PLL/clock/training and the boardLIBERO_SETTING_*values stay inhal/mpfs250_ddr.c.src/riscv_sbi.c): BASE/TIME/IPI/RFENCE/HSM/DBCN plus the legacy calls, with per-hart M-mode trap stacks,rdtimeand misaligned load/store emulation, atomic cross-hart IPI ops with self-directed SSIP delivery, and the trap-entry / M->S hand-off wiring. PolarFire SoC bring-up adds CLINT MTIME enable, per-hart HSMhart_startmailboxes, the watchdog policy, and the dtb fixups that bring up 4-CPU SMP Linux.Key design points
DDR_CADENCE_CTRL_BASE); the SoC-specific PHY/PLL/training is behind the platform HAL. Both compile only whenMPFS_DDR_INITis set.rdtimeis emulated in M-mode for S and U mode.Validation (MPFS250T Video Kit, power-controlled cold boots)
smp: Brought up 1 node, 4 CPUswith zero "failed to come online"; login at ~40 s.ddr_cadence.o(driver correctly gated).versal_vmk180_sdcard,zynqmp_sdcard,zynq7000_sdcardalso build (shared sdhci/boot files).Notes for reviewers
src/vector_riscv.Strap-macro changes areWOLFBOOT_RISCV_MMODE-gated; S-mode builds keep the original frame behavior.src/sdhci.ckeeps the cross-platform driver clean: the MPFS PDMA/watchdog specifics are behind weaksdhci_platform_block_copy()/sdhci_platform_wdt_pet()hooks.src/fdt.cgains a weakwolfBoot_fit_memcpyhook so the platform can route FIT subimage copies through PDMA.tools/ci/mpfs_libero_stub/fpga_design_config.hlets the M-mode + DDR path compile in GitHub Actions (compile-only; not runnable).lib/wolfsslsubmodule pointer is bumped (came in with the DDR work); drop it if the project prefers to bump separately.docs/Targets.mddocuments the M-mode + DDR Linux boot flow, the wolfSBI runtime, the watchdog policy, and the generic Cadence driver split.