Repository navigation
Description
Summary
The ARMHardwareSPIOutputDMA<> driver (src/platforms/arm/lpc/spi_arm_lpc_dma.h, #3454) wedges the LPC845 on the first dmaSpiTransferOnce RPC. With the new WWDT + NMI backtrace tooling (landed on feat/delegate-flash-to-fbuild), the wedge is now precisely located:
FAULT: HardFault PC=0x100018BC LR=0xFFFFFFF9 xPSR=0x40058000
firmware.map symbolication:
0x100018b4 autoresearch::dma_spi::harnessDriver()::inited
0x100018b8 guard variable for autoresearch::dma_spi::harnessDriver()::drv
0x100018bc autoresearch::dma_spi::harnessDriver()::drv ← PC lands HERE
0x100018c0 autoresearch::dma_spi::harnessBuffer()::buf
The CPU was executing the driver's static object as code — control flow jumped into .bss. The stacked frame is the wedged (thread-mode) context, and the fault line is emitted by the watchdog warning-NMI hook 3.0 s after the wedge, after which the chip resets and answers RPC echo again (self-recovery verified).
Repro
On the feat/delegate-flash-to-fbuild branch with an LPC845-BRK attached (and fbuild ≥ 2.3.18 + probe-rs in ~/.fbuild/prod/tools/):
bash autoresearch lpc845 --dma-spi --skip-lint
Build: 56.42 KB flash / 10.60 KB RAM (the FASTLED_LPC_SPI_DMA=1 + FASTLED_LPC_SPI_DMA_MAX_BYTES=512 defines are injected by the harness — at the driver-default 2048 the build was at 94% static RAM and HardFaulted at PC=0 on any RPC; that separate issue is fixed). Deploy succeeds via probe-rs SWD; echo works; first dmaSpi* call wedges.
Where to look
The wedge is in the lazy-init path of the harness (harnessDriver() → first-call construction + drv.init()) or the first kickDmaStream():
- DMA descriptor table (SRAMBASE) placement — the LPC845 DMA controller reads channel descriptors from RAM at
DMA0->SRAMBASE, which must be 512-byte aligned and point at a properly laid-out descriptor table. If SRAMBASE is misprogrammed (or the descriptor block overlaps other statics), the DMA engine can scribble on.bssnear the driver's statics — consistent with control flow later diving intodrv's address. - Vendor-PAL migration state of
spi_arm_lpc_dma.h— audit any remaining hand-rolled offsets against<LPC845.h>the same way Meta: Replace all hand-rolled LPC register maps with vendor CMSIS PAL headers #3437 did elsewhere. The WWDT MOD/TC swap (fixed in the same branch) shows this class of bug ships silently. FASTLED_LPC_SPI_DMA_CHANNELdefault vs the fixed DMA request map — SPI0_TX = DMA ch 6, SPI1_TX = ch 8 (UM11029 §12). A wrong channel with HWTRIGEN can fire on the wrong peripheral's request line.
Why this wasn't visible before
Three masking layers, all removed this week: (a) pyocd HID wedge blocked any flash; (b) at default buffer sizes the firmware RAM-exhausted and HardFaulted at PC=0 on any RPC; (c) the WWDT never armed (MOD/TC register swap) so a wedge looked like "device dead, no output" instead of a backtrace line.
Refs: #3456 (bench), #3453 (bring-up meta), #3454 (driver), #3300 (the empty-RX blocker this explains), #3437 (vendor PAL policy).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
fix(lpc): SPI+DMA driver works on silicon — 6 stacked hardware bugs (c…
zackees commentedon Jul 2, 2026
Fixed in commit
7f4f912ee9onfeat/delegate-flash-to-fbuild(PR #3550's branch). The single reported wedge turned out to be six stacked silicon bugs, each masking the next — bisected live on the LPC845-BRK with the WWDT NMI backtrace, breadcrumb prints, and bounded-spin register snapshots:DMA0->SRAMBASEnever programmed → descriptors fetched from the flash vector table (the original PC-in-.bsswedge). Fixed with a sharedFL_ALIGNAS(512)descriptor table (lpc_dma_descriptor_table.h).spi->STATread stalled the bus forever. init() now owns SYSAHBCLKCTRL0 + PRESETCTRL0 + SWM routing.XFERCFG.SWTRIGmissing — PERIPHREQEN requests only pace a channel; it must first be triggered (snapshot showed CFGVALID=1, TXRDY=1, TRIG=0, XFERCOUNT frozen).SYSCON->FCLKSEL[9]resets to "none" — the SPI shift engine had no function clock and froze mid-byte with STAT=0.waitFully()(bench alternated PASS/WEDGE through watchdog reboots). Fixed with a one-time softwareSTAT.ENDTRANSFERafter the stream drains (per-byte EOT was tried and rejected: measured 39% throughput loss).Acceptance (LPC845-BRK, 2026-07-02),
bash autoresearch lpc845 --dma-spiend-to-end:Note on the SCK number: the LPC845 SPI is FIFO-less, so each byte costs 8/SCK shift + ~0.76 µs DMA refill. Wire SCK is a true 4 MHz; ~2.9 MHz is the physically attainable effective throughput at divider 6, and the bench now models it that way.
This closes #3517 Phase B.1's silicon acceptance for real.
fix(lpc): polled SPI driver owns its LPC845 peripheral plumbing too
feat(lpc): ISR-refillable async streaming (SPI + UART) + review fixes
fix(lpc): DMA ISR hygiene — stale-INTA clear, end-of-stream quiesce, …
Delegate all flashing to fbuild + LPC845 drivers + ban raw pyserial i…