PolarFire SoC QSPI support and ELF parser hardening#677
PolarFire SoC QSPI support and ELF parser hardening#677danielinux merged 5 commits intowolfSSL:masterfrom
Conversation
633e7f8 to
5e963dc
Compare
danielinux
left a comment
There was a problem hiding this comment.
Looks good, some minor visibility issues
5e963dc to
2f8ce14
Compare
There was a problem hiding this comment.
Pull request overview
Adds QSPI NOR flash support for PolarFire SoC MPFS250 and updates the RISC-V/PolarFire boot flow to better support RAM-loaded (NO_XIP) and ELF-based images.
Changes:
- Introduces MPFS250 QSPI NOR driver + EXT_FLASH integration (including SC QSPI vs MSS QSPI selection).
- Updates RISC-V trap/vector handling to switch between S-mode and M-mode via
WOLFBOOT_RISCV_MMODE. - Adjusts build/link flow for RISC-V (update loader selection based on disk config; sign ELF when
ELF=1) and documents PolarFire QSPI usage.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
hal/mpfs250.c |
Implements QSPI init + transfer/read/write/erase and hooks it into hal_init() when EXT_FLASH is enabled. |
hal/mpfs250.h |
Adds SCB mailbox helpers/constants and CoreQSPI v2 register/flash command definitions under EXT_FLASH. |
hal/riscv.h |
Centralizes privilege-mode selection helpers and adds an I-cache sync helper for RISC-V. |
src/elf.c |
Uses memmove() for safer in-place ELF segment loading and syncs I-cache on RISC-V. |
src/vector_riscv.S |
Switches S-mode/M-mode selection logic to WOLFBOOT_RISCV_MMODE. |
src/boot_riscv_start.S |
Uses MODE_PREFIX from hal/riscv.h and updates mode checks to WOLFBOOT_RISCV_MMODE. |
src/boot_riscv.c |
Updates satp/MMU teardown conditional for S-mode vs M-mode. |
test-app/vector_riscv.S |
Adds RV64 trap entry/exit macros and uses sret vs mret based on WOLFBOOT_RISCV_MMODE. |
test-app/startup_riscv.c |
Sets stvec vs mtvec and reads scause vs mcause based on privilege mode. |
test-app/RISCV64-mpfs250.ld |
Adjusts placement for RAM boot / NO_XIP style execution and changes where .data/.bss live. |
arch.mk |
Chooses update loader based on disk enablement and switches signing target to .elf when ELF=1. |
docs/Targets.md |
Documents PolarFire QSPI usage and build-time selection between MSS QSPI and SC QSPI. |
config/examples/polarfire_mpfs250_qspi.config |
New example configuration for MPFS250 QSPI + NO_XIP + ELF flows. |
config/examples/polarfire_mpfs250.config |
Clarifies EXT_FLASH meaning for PolarFire MPFS250. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8eafade to
22ad9d1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
22ad9d1 to
d541c08
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 19 out of 19 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
QSPI Flash Support
Add full QSPI flash support for PolarFire SoC (MPFS250T), including read, write, and erase
operations for both QSPI controllers:
Both controllers share the CoreQSPI v2 register interface. Build-time selection via
MPFS_SC_SPIdefine. Includes example configconfig/examples/polarfire_mpfs250_qspi.config.HAL changes (
hal/mpfs250.c,hal/mpfs250.h):QSPI_IO_FENCE()macro for RISC-V RVWMO memory ordering on MMIO writesTEST_EXT_FLASHandDEBUG_QSPIbuild flagsext_flash_readreturn value checked consistently during erase verifyRISC-V improvements:
trap_exitmacro now usessret/mretconditional onWOLFBOOT_RISCV_MMODE,matching the existing 64-bit behavior (
test-app/vector_riscv.S,src/vector_riscv.S)hal/riscv.hDocumentation:
docs/Targets.mdwith architecture diagram andbuild instructions for both MSS and SC QSPI modes
ELF parser bounds checking
Add
image_szparameter toelf_load_image_mmu()to validate that all offsets and sizesread from ELF headers stay within the image buffer. Applies to both ELF32 and ELF64 code paths.
Checks added:
Example output