AnsweredAssumed Answered

Bug report STM32CubeMX 4.14.0 - SD_read, SD_write for DMA mode

Question asked by Kolomaznik.Petr.001 on May 11, 2016
Latest reply on Jan 24, 2017 by Kolomaznik.Petr.001
I have project generated by STM32CubeMX 4.14.0 and STM32CubeF7 1.3.1. I use the FATFS and SDIO with DMA. If I wrote a file with higher clock for sd card, then there is an error in the function FR_DISK_ERR f_write.

I found the problem in sd_diskio.c where SD_read and SD_write functions  call functions for polling mode and not for DMA mode.

For DMA mode is necessary to change:

DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
{
  DRESULT res = RES_OK;
 
  if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff,
                       ( (uint64_t)sector * BLOCK_SIZE),
                       BLOCK_SIZE,
                       count) != MSD_OK)

DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
{
  DRESULT res = RES_OK;
 
  if(BSP_SD_WriteBlocks_DMA((uint32_t*)buff,
                        ((uint64_t)sector * BLOCK_SIZE),
                        BLOCK_SIZE, count) != MSD_OK)

Outcomes