AnsweredAssumed Answered

STM32 FatFS SDIO DMA bug

Question asked by Anonymous Anonymous on Jun 14, 2018

How to reproduce:

1) Use STM32Cube FW_F4 V1.21.0 (not tested on other versions)

2) Set up SDIO 1-bit mode with default parameters.

3)

4) Set up FatFS with SDIO driver with default parameters.

5) Set "Use dma template"=enabled for SDIO (this is critical, bug does not exist in "disabled" mode).

6) You need a microsd with file longer than sector size.

7) Use code:


FATFS SDFatFs;
FIL TestFile;
UINT BytesRead;

uint8_t buffer[2048];
FRESULT res = f_mount(&SDFatFs, (char*)SDPath, 0);
if (res==FR_OK)
{
res = f_open(&TestFile, "test.bin", FA_READ);
if (res != FR_OK)
while (1);
}

f_lseek(&TestFile, 4);
f_read(&TestFile, buffer, sizeof(buffer), &BytesRead);

 

8) Result: first 498 byte read correctly, then byte offset jumps 4 bytes back (exactly the value, used in f_lseek) and next data is read with broken offset.

 

Temporary fix: 

Outcomes