# SDIO: CRC error on command 17, response timeout

- **ID:** `embedded/sdio-crc-error`
- **Domain:** embedded
- **Category:** protocol_error
- **Error Code:** `SDIO_STA_CCRCFAIL`
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

CRC mismatch between SD card and host during command or data transfer, often due to electrical noise, clock timing issues, or card initialization failure.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32Cube_FW_L4 v1.18.0 | active | — | — |
| SDIO v2.0 | active | — | — |
| GCC ARM Embedded 10.3.1 | active | — | — |

## Workarounds

1. **Reduce SDIO clock divider to lower frequency: set SDIO_CLKCR_CLKDIV to 2 (e.g., for 48 MHz clock, output 12 MHz) and ensure clock polarity matches SD card spec.** (85% success)
   ```
   Reduce SDIO clock divider to lower frequency: set SDIO_CLKCR_CLKDIV to 2 (e.g., for 48 MHz clock, output 12 MHz) and ensure clock polarity matches SD card spec.
   ```
2. **Enable internal pull-ups on SDIO data lines and add external 10-100 pF capacitors to ground on each line to filter noise.** (75% success)
   ```
   Enable internal pull-ups on SDIO data lines and add external 10-100 pF capacitors to ground on each line to filter noise.
   ```
3. **Reinitialize the SD card with a slower clock and retry command 17: use HAL_SD_Init() with SDIO_INIT_CLK_DIV of 0x76, then switch to high-speed after successful read.** (80% success)
   ```
   Reinitialize the SD card with a slower clock and retry command 17: use HAL_SD_Init() with SDIO_INIT_CLK_DIV of 0x76, then switch to high-speed after successful read.
   ```

## Dead Ends

- **Increase SDIO clock frequency to improve throughput** — Higher clock frequency worsens timing margins and increases CRC errors. (90% fail)
- **Replace SD card with a different brand without changing settings** — Different cards have varying timing requirements; the issue may persist without proper clock adjustment. (70% fail)
- **Disable CRC checking in SDIO peripheral** — CRC is mandatory for reliable data transfer; disabling it can cause silent data corruption. (95% fail)
