| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add timeout guards to unbounded busy-wait loops in the SD card drivers. A problematic SD card could cause sdcardSpi_deselect() to spin forever on busIsBusy(), freezing the entire FC since blackbox runs inline with the PID loop. - sdcard_spi.c: Add 100K-iteration timeout to sdcardSpi_deselect(), matching the existing pattern in sdcardSpi_init(). On timeout, increment failureCount and disable card at threshold. - sdmmc_sdio_f4xx.c: Add 10K-iteration timeout to DMA disable loop. Add SD_DATATIMEOUT software backstop to three FIFO read loops (SD_HighSpeed, SD_GetCardStatus, SD_FindSCR) as defense-in-depth behind the hardware SDIO_STA_DTIMEOUT.
PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Sorry, something went wrong.
If the DMA stream remains enabled after the timeout, set TransferError and return early to avoid configuring a still-active DMA stream.
|
I have been giving this a pushing in bench testing with H743 and F765 controllers.. But it's a hard one to reproduce.. Most of the time when it does occur, it's under specific flight conditions. When maybe higher task usage functions are in operation at the same time as higher logging rate. Or logging specific data like Gyro or Motors. In any case. Having this in place can only help when one of these random events does inevitably occur in flight. |
Sorry, something went wrong.
|
Thanks, Jetrell. I think this would be mostly for bad SD cards or perhaps a BB logging rate far too high. Maybe the best we can really confirm here is that I didn't break it in normal operation. |
Sorry, something went wrong.
…d-lockup Fix SD card busy-wait loops that can lock up flight controller
| Back | FazBrowse Home | New Git URL |
User description
Summary
Changes
sdcard_spi.c — sdcardSpi_deselect() (called ~15 times after every SPI transaction):
sdmmc_sdio_f4xx.c — DMA disable loop:
sdmmc_sdio_f4xx.c — FIFO read loops (3 locations: SD_HighSpeed, SD_GetCardStatus, SD_FindSCR):
Test plan
PR Type
Bug fix
Description
Add timeout guards to unbounded busy-wait loops in SD card drivers
Prevents flight controller lockup from problematic SD cards during blackbox operations
Diagram Walkthrough
File Walkthrough
src/main/drivers/sdcard/sdcard_spi.c
(~4µs at 168MHz)
is reached
src/main/drivers/sdcard/sdmmc_sdio_f4xx.c
SD_StartBlockTransfert() (~0.4µs)
loops: SD_HighSpeed(), SD_GetCardStatus(), and SD_FindSCR()
SDIO_STA_DTIMEOUT
impact