SDMMCv2 sleeps forever after some failed transactions Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
tpw_rules
Posts: 6
Joined: Wed Nov 12, 2025 4:35 am
Been thanked: 3 times

SDMMCv2 sleeps forever after some failed transactions

Post by tpw_rules »

Certain error states on the SD card bus can get the data path state machine (DPSM) stuck busy. According to the reference manual, it can be aborted by sending a command using the command path state machine (CPSM) with the CMDSTOP bit set in the CMD register. As ChibiOS does not use the CMDSTOP bit, the DPSM can stay busy forever in some cases. This results in future commands failing (and possibly getting stuck?) and an SD card re-init sleeping forever as data transfer does not finish during card detection due to the stuck DPSM.

Our application (ArduPilot) disconnects and stops the SD card after an error, so this patch fixes the issue by simply resetting the peripheral before stopping its clock in the shutdown path. This clears the state machine and causes the next start and connect to function properly. This fix may not be complete for all applications, the driver should probably be fixed to use CMDSTOP correctly and send a STOP_TRANSMISSION command in all cases.

This has the same root case (vibration) as viewtopic.php?f=35&t=6616 . The attached patch fixes the issue in our application and was tested on STM32H753. It applies correctly to ChibiOS master.
Attachments
chibios-sdmmcv2-fixes-2025-11-30.zip
(1.06 KiB) Downloaded 51 times
Post Reply