microSD Card Hangs

When trying to write to one of the SanDisk Industrial microSD cards in recovery (with the latest firmware), after not very much I/O I get stuck with something like, which prints every 10-20 seconds or so for some time.

[  319.032172] mmc0: Timeout waiting for hardware interrupt.
[  319.037572] mmc0: sdhci: ============ SDHCI REGISTER DUMP ===========
[  319.044008] mmc0: sdhci: Sys addr:  0x00000400 | Version:  0x00002002
[  319.050443] mmc0: sdhci: Blk size:  0x00000200 | Blk cnt:  0x00000400
[  319.056875] mmc0: sdhci: Argument:  0x00000000 | Trn mode: 0x00000023
[  319.063310] mmc0: sdhci: Present:   0x01ed000e | Host ctl: 0x0000003a
[  319.069743] mmc0: sdhci: Power:     0x00000003 | Blk gap:  0x00000000
[  319.076177] mmc0: sdhci: Wake-up:   0x00000000 | Clock:    0x00000068
[  319.082611] mmc0: sdhci: Timeout:   0x0000000e | Int stat: 0x00000000
[  319.089044] mmc0: sdhci: Int enab:  0x037f108f | Sig enab: 0x037f108b
[  319.095477] mmc0: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00002002
[  319.101911] mmc0: sdhci: Caps:      0x35fa0000 | Caps_1:   0x0000af00
[  319.108344] mmc0: sdhci: Cmd:       0x00000c1b | Max curr: 0x00000000
[  319.114777] mmc0: sdhci: Resp[0]:   0x00000c00 | Resp[1]:  0x0000000c
[  319.121211] mmc0: sdhci: Resp[2]:   0x00000000 | Resp[3]:  0x00000000
[  319.127645] mmc0: sdhci: Host ctl2: 0x00000000
[  319.132080] mmc0: sdhci: ADMA Err:  0x00000000 | ADMA Ptr: 0x00000083a99f4200
[  319.139208] mmc0: sdhci: ============================================
[  322.147741] sdhci-esdhc 2140000.esdhc: Card stuck in wrong state! card_busy_detect status: 0xc00

I have seen this happen mostly with older sdcards. Most likely we will need to restrict what SD speeds are used.

How big is the file/image you are trying to write?

I was trying to write ~300MiB to the device, so definitely enough to keep write buffers full. The Industrial cards are definitely quite slow, but are generally of good quality so I’ve never seen them have any issues in any other sd reader/writer.

A fix/workaround for this has been added to the devicetree in the v0.8.8 firmware release (as well as the 5.10 based recovery builds which embed their own device tree).

The workaround is to reduce the maximum speed for the SD card.
I believe the issue is signal-integrity related and could be fixed (without a dramatic speed reduction) by tuning some physical settings in the SD controller but that will take a while to test and verify.

1 Like