AI Generated [issue-ticket]
Summary
Add a new debug_mode for continuous, blackbox-correlated diagnostics of the IMUF9001 SPI link: CRC error count and stale-transfer (skipped GYROPID cycle) count. Currently these are either not measured at all, or only available as a cumulative CLI query, not correlated against flight time/motor output/vibration in blackbox.
Background
refactor/imuf9001-dma-migration (PR #1283) moved the IMUF9001 SPI transfer from the EXTI ISR into GYROPID task context, gated by a dataReady flag and an imufTransferPending race-clear flag (accgyro_mpu.c, accgyro_imuf9001.c). Two health signals exist for this path today but neither is continuously observable during flight:
- CRC errors —
crcErrorCount (accgyro_mpu.c:198,211-212) increments on every CRC mismatch in imufIntCallback. Only exposed via the reportimuferrors CLI command (cli.c:4376,4448-4452) as a cumulative total queried before/after flight — not logged continuously, so a CRC error burst cannot be correlated to a specific flight moment (e.g. high vibration, hard throttle punch).
- Stale/skipped transfers —
imufSpiGyroRead() (accgyro_imuf9001.c:208-214) returns gyro->dataReady; if false, GYROPID skips the cycle (no new IMUF sample was ready). There is currently no counter for how often this happens. The theoretical race window from clearing imufTransferPending before the SPI call is estimated at ~0.1% of cycles but has never been measured on real hardware.
Neither of these is specific to any board — IMUF9001 is shared by HELIOSPRING, STRIXF10, and MODE2FLUX. A per-target name (e.g. HELIO_CRC) was considered and rejected in favor of a driver-scoped name, matching existing precedent: DEBUG_RX_FRSKY_SPI and DEBUG_RX_SFHSS_SPI (build/debug.h:70-71) are named after the protocol/driver, not the board they happen to run on.
Proposed Name
DEBUG_IMUF9001_CRC (working name — open to bikeshedding at implementation time).
Proposed Implementation
- Add
DEBUG_IMUF9001_CRC to debugType_e (build/debug.h) and debugModeNames[] (build/debug.c)
- In
imufIntCallback() (accgyro_mpu.c): DEBUG_SET(DEBUG_IMUF9001_CRC, 0, crcErrorCount)
- Add a new counter (e.g.
imufStaleTransferCount) incremented in imufSpiGyroRead() when dataReady is false at return; DEBUG_SET(DEBUG_IMUF9001_CRC, 1, imufStaleTransferCount)
- Guard both behind
#ifdef USE_GYRO_IMUF9001
Constraint
EmuFlight's debug[] array is DEBUG16_VALUE_COUNT = 4 (Betaflight is 8 — tracked separately in #1338). This proposal uses 2 of the 4 slots, leaving 2 free. Only one debug_mode can be active at a time, so this competes with any other diagnostic a pilot wants during the same flight — by design, this is meant for driver validation, not routine flying.
Scope
Out of scope for PR #1283 (pure host-driver migration, no debug_mode changes). This should land as its own focused PR once resourced.
AI Generated [issue-ticket]
Summary
Add a new
debug_modefor continuous, blackbox-correlated diagnostics of the IMUF9001 SPI link: CRC error count and stale-transfer (skipped GYROPID cycle) count. Currently these are either not measured at all, or only available as a cumulative CLI query, not correlated against flight time/motor output/vibration in blackbox.Background
refactor/imuf9001-dma-migration(PR #1283) moved the IMUF9001 SPI transfer from the EXTI ISR into GYROPID task context, gated by adataReadyflag and animufTransferPendingrace-clear flag (accgyro_mpu.c,accgyro_imuf9001.c). Two health signals exist for this path today but neither is continuously observable during flight:crcErrorCount(accgyro_mpu.c:198,211-212) increments on every CRC mismatch inimufIntCallback. Only exposed via thereportimuferrorsCLI command (cli.c:4376,4448-4452) as a cumulative total queried before/after flight — not logged continuously, so a CRC error burst cannot be correlated to a specific flight moment (e.g. high vibration, hard throttle punch).imufSpiGyroRead()(accgyro_imuf9001.c:208-214) returnsgyro->dataReady; if false, GYROPID skips the cycle (no new IMUF sample was ready). There is currently no counter for how often this happens. The theoretical race window from clearingimufTransferPendingbefore the SPI call is estimated at ~0.1% of cycles but has never been measured on real hardware.Neither of these is specific to any board — IMUF9001 is shared by HELIOSPRING, STRIXF10, and MODE2FLUX. A per-target name (e.g.
HELIO_CRC) was considered and rejected in favor of a driver-scoped name, matching existing precedent:DEBUG_RX_FRSKY_SPIandDEBUG_RX_SFHSS_SPI(build/debug.h:70-71) are named after the protocol/driver, not the board they happen to run on.Proposed Name
DEBUG_IMUF9001_CRC(working name — open to bikeshedding at implementation time).Proposed Implementation
DEBUG_IMUF9001_CRCtodebugType_e(build/debug.h) anddebugModeNames[](build/debug.c)imufIntCallback()(accgyro_mpu.c):DEBUG_SET(DEBUG_IMUF9001_CRC, 0, crcErrorCount)imufStaleTransferCount) incremented inimufSpiGyroRead()whendataReadyis false at return;DEBUG_SET(DEBUG_IMUF9001_CRC, 1, imufStaleTransferCount)#ifdef USE_GYRO_IMUF9001Constraint
EmuFlight's
debug[]array isDEBUG16_VALUE_COUNT = 4(Betaflight is 8 — tracked separately in #1338). This proposal uses 2 of the 4 slots, leaving 2 free. Only onedebug_modecan be active at a time, so this competes with any other diagnostic a pilot wants during the same flight — by design, this is meant for driver validation, not routine flying.Scope
Out of scope for PR #1283 (pure host-driver migration, no debug_mode changes). This should land as its own focused PR once resourced.