Bare-Metal STM32MP2: Trading FMC for PCIe to Connect FPGAs
An engineer explores running the STM32MP2 without Linux, using its PCIe interface to replace the pin-hungry FMC bus for FPGA connectivity.
For embedded developers pairing STM32 microcontrollers with FPGAs, the FMC parallel bus has long been the standard interface—but it comes with a cost: over 30 pins, scattered across the package, making routing on low-cost boards painful. One engineer, frustrated with these limitations, turned to the STM32MP2, an applications processor with a 5 Gbps SERDES that can operate as PCIe Gen1/2 x1. The goal: replace FMC with two differential pairs, and run the chip as a bare-metal MCU without Linux.
Why PCIe Instead of FMC
The author had previously used STM32H735 with an external FPGA over FMC, achieving near-Gbps Ethernet throughput. However, the parallel bus remained a board design challenge. The STM32MP2’s SERDES, configurable as PCIe or USB3, offered a cleaner path. The chip also retains familiar STM32 peripherals, including AES-GCM and TRNG IP, reducing the learning curve. The STM32MP257F-EV1 board includes a mini PCIe slot, adaptable to M.2 for testing with NVMe SSDs and FPGA modules.
Bare-Metal Boot: M33 and A35
The experiment set strict rules: no vendor SDKs, no external DDR, no TrustZone or U-Boot—just a simple event loop running from SRAM. The first milestone was bringing up the Cortex-M33 auxiliary core. A blinky was loaded via JTAG, then a tool was built to package a RAM image into an FSBL with the necessary headers for boot ROM execution. The M33 boots in TD mode with full TrustZone privileges. Key configuration: code in RETRAM at boot alias 0x0e08_0000, stack and globals in D-side alias 0x3008_0000 (no physical overlap). Two FSBL slots exist in flash.
Starting the Cortex-A35 required more steps: check CPU state, send SEV via EXTI, reset, set software interrupt, release boot via RCC.CPUBOOTCR. The FSBL-A image, stored at flash offset 0x0008_0000 (primary) or 0x000C_0000 (fallback), loads to SYSRAM alias 0x0e00_0000. Initialization includes assembly code for register clearing, exception table setup, FPU/NEON enabling, and MMU page table creation. Core 0 builds the page tables (1:1 mapping, used for caching and NX), enables MMU, and runs BSP init; core 1 spins then shares the same tables. Both cores then enter CoreMain().
PCIe Bring-Up and a Stubborn Link Flap
Enabling PCIe involved poking registers to power up the COMBOPHY, select PCIe mode, calibrate impedance, and start LTSSM. No firmware blob was needed. Initial testing showed the link training to L0 and passing a few TLPs, but then it repeatedly dropped to Recovery and retrained. Using a fast oscilloscope and ngscopeclient, the engineer observed the link flapping and eventually staying down. The issue appeared to be related to the TLP scrambler not being enabled on the FPGA side, but the fix is pending.
During the project, an unexpected silicon bug with security implications was found and reported to ST. Publication was delayed until ST released an advisory. Details will appear in a separate post.