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.
SDMMCv2 sleeps forever after some failed transactions Topic is solved
SDMMCv2 sleeps forever after some failed transactions Topic is solved
- Attachments
-
- chibios-sdmmcv2-fixes-2025-11-30.zip
- (1.06 KiB) Downloaded 10 times
Who is online
Users browsing this forum: No registered users and 100 guests
