Repository navigation
refactor(rx): migrate rx_spi.c to extDevice_t/DMA-aware transfers - #1390
Draft
nerdCopter wants to merge 13 commits into
Draft
nerdCopter wants to merge 13 commits into
nerdCopter wants to merge 13 commits into
Conversation
drivers/rx/rx_spi.c called spiTransferByte() directly against the raw SPI instance, bypassing dev/segment/DMA handling entirely. BF 4.5-maintenance and master both route this through extDevice_t + spiReadWrite()/spiWrite()/ spiWriteReg()/spiWriteRegBuf()/spiReadReg()/spiReadRegBuf(). rxSpiDeviceInit() gains two calls required for correctness on the new per-device path, not optional: spiSetClkPhasePolarity(dev, true) (the field zero-initializes to Mode 3, wrong for nRF24L01/CC2500/A7105) and spiSetClkDivisor(dev, SPI_CLOCK_STANDARD) (replaces the old instance-based spiSetDivisor() call; the field zero-initializes to an undefined divisor). Write-family functions (rxSpiWriteByte/WriteCommand/WriteCommandMulti/ ReadCommandMulti and their callers in rx_nrf24l01.c/rx_cc2500.c/rx_xn297.c) change uint8_t -> void to match BF's current signatures. Verified every call site up through callers-of-callers across the tree before changing: the discarded status byte is never read anywhere in EF or BF. Closes part of emuflight#1366 (DMA-plumbing stage only; EXTI interrupt-driven frame detection deferred to a follow-up).
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


AI Generated pull-request
Summary
drivers/rx/rx_spi.ccalledspiTransferByte()directly against the raw SPIinstance, bypassing
dev/segment/DMA handling entirely. BF 4.5-maintenanceand master both route this through
extDevice_t+spiReadWrite()/spiWrite()/spiWriteReg()/spiWriteRegBuf()/spiReadReg()/spiReadRegBuf().rxSpiDeviceInit()gains two calls required for correctness on the newper-device path:
spiSetClkPhasePolarity(dev, true)(the fieldzero-initializes to Mode 3, wrong for nRF24L01/CC2500/A7105) and
spiSetClkDivisor(dev, SPI_CLOCK_STANDARD)(replaces the old instance-basedspiSetDivisor()call; the field zero-initializes to an undefined divisor).Write-family functions (
rxSpiWriteByte/WriteCommand/WriteCommandMulti/ReadCommandMultiand their callers inrx_nrf24l01.c/rx_cc2500.c/rx_xn297.c) changeuint8_t->voidto match BF's current signatures.Every call site was traced up through callers-of-callers across the tree
before changing — the discarded status byte is never read anywhere in EF
or BF.
Scope: this PR is the DMA-plumbing migration only. BF's EXTI
interrupt-driven frame-detection feature is deliberately deferred to a
separate follow-up (#1391).
Closes part of #1366.
Hardware test result: FAILED — real, reproducible regression, root cause not yet confirmed
First hardware flash on NBDHMBF4PRO (real board, FrSky/CC2500) reproduced a severe,
deterministic failure: connecting shows normal sensor data, but entering CLI mode causes a
total board lockup — zero CLI output ever (not even the static entry banner), MSP requests
time out indefinitely, and the entire scheduler (confirmed via a raw SysTick-ISR-driven
heartbeat, independent of the normal task loop) stops. Reflash-verified deterministic
(identical result twice on the same commit); confirmed NOT the board's known,
already-documented CC2500 solder-defect (current
masterworks fine on this same hardware).A fault-handler redirect test ruled out a normal caught/handled fault — no distinctive
blink pattern ever appears, meaning the CPU likely locks up before even entering the fault
handler (consistent with memory corruption, most plausibly a stack overflow, though
unconfirmed). Root-causing this further requires a hardware debugger (SWD/JTAG), which is
not currently available.
BF-parity check: this migration's direction is validated by BF's own fleet — BF ships
this exact combination (F411 + CC2500/FrSky +
extDevice_t) on real, popular boards (e.g.CRAZYBEEF4FR), so the architecture itself is not the problem. That comparison did surfaceone real, concrete gap: BF's shipped board wires interrupt-driven GDO detection
(
RX_SPI_EXTI_PIN→rxSpiExtiConfigured()/rxSpiExtiInit()), while EF'srx/rx_spi.chasno such mechanism at all —
cc2500getGdo()still polls (already tracked as #1391, previouslyscoped as a separate follow-up, not yet confirmed to be the root cause of this specific
lockup).
This PR is not safe to merge or un-draft pending further root-causing with a debugger.
Full investigation trace:
refactor/rx-spi-dma-migration/CONTEXT_rx-spi-dma-migration.mdinthe AI docs tree.
Test plan
make test(unit suite, unchanged),NBDHMBF4PRO,CRAZYBEEF4FS,NUCLEOF446RE,SITL— 0 warnings