Hello Electro-smith team !
Here is a problem I have encountered when trying to implement SD card writes on the daisy patch.
I must admit that without an LLM to help me debug I would never found the fix by myself.
The fix is not ideal as polling mode is slightly slower and blocks the CPU during transfers, but for my use case (saving presets), it is sufficient.
Description
When using FatFS with the SDMMC peripheral on Daisy Patch, SD card writes always fail with FR_DISK_ERR (error 1) after a 30-second timeout. The file is created but remains at 0 bytes. Switching to polling mode in sd_diskio.c fixes the issue.
Hardware
- Board: Daisy Patch
- SD Card: FAT32, MBR partition scheme (tested with multiple cards)
Problem
The DMA completion callbacks (BSP_SD_WriteCpltCallback / BSP_SD_ReadCpltCallback) in sd_diskio.c are never called. This causes the while loop in SD_write() to spin until SD_TIMEOUT (30 seconds) expires:
// sd_diskio.c line ~220
while((WriteStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)) {}
WriteStatus stays 0 because BSP_SD_WriteCpltCallback() never fires.
Workaround
Replacing DMA calls with polling versions fixes the issue:
// In SD_read():
// Change: BSP_SD_ReadBlocks_DMA(...)
// To: BSP_SD_ReadBlocks(..., SD_TIMEOUT)
// In SD_write():
// Change: BSP_SD_WriteBlocks_DMA(...)
// To: BSP_SD_WriteBlocks(..., SD_TIMEOUT)
Full diff: master...CyberDuck79:libDaisy:fix/sd-polling-mode
Steps to Reproduce
- Use the official SDMMC example pattern on Daisy Patch
- Try to write any file with
f_write() / f_close()
- Observe 30-second hang, then
FR_DISK_ERR
- File exists but size = 0
Environment
- libDaisy version: master (latest)
- Toolchain: arm-none-eabi-gcc 14.2.1
Questions
- Is the SDMMC DMA/interrupt configuration correct for Daisy Patch?
- Are there known issues with IDMA on STM32H750?
Hello Electro-smith team !
Here is a problem I have encountered when trying to implement SD card writes on the daisy patch.
I must admit that without an LLM to help me debug I would never found the fix by myself.
The fix is not ideal as polling mode is slightly slower and blocks the CPU during transfers, but for my use case (saving presets), it is sufficient.
Description
When using FatFS with the SDMMC peripheral on Daisy Patch, SD card writes always fail with
FR_DISK_ERR(error 1) after a 30-second timeout. The file is created but remains at 0 bytes. Switching to polling mode in sd_diskio.c fixes the issue.Hardware
Problem
The DMA completion callbacks (
BSP_SD_WriteCpltCallback/BSP_SD_ReadCpltCallback) in sd_diskio.c are never called. This causes the while loop inSD_write()to spin untilSD_TIMEOUT(30 seconds) expires:WriteStatusstays 0 becauseBSP_SD_WriteCpltCallback()never fires.Workaround
Replacing DMA calls with polling versions fixes the issue:
Full diff: master...CyberDuck79:libDaisy:fix/sd-polling-mode
Steps to Reproduce
f_write()/f_close()FR_DISK_ERREnvironment
Questions