2017-07-05 01:53 AM
While using SDMMC with FatFS to interface with SDCards occasionally I get Command Timeout when issuing:
SDMMC_CmdReadSingleBlock
This is when using new 1.7.0 drivers. Did anyone experience similar issue?
2017-08-29 11:15 AM
Currently I resolved problems in my code by using following approach:
1) using two HAL callbacks for SDIO RX complete and TX complete:
2) after callback waiting for HAL_SD_CARD_TRANSFER.
__IO uint8_t nowRxSd=0;
__IO uint8_t nowTxSd=0;
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
{
if (hsd->Instance==SDIO)
{
nowRxSd=0;
}
}
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
{
if (hsd->Instance==SDIO)
{
nowTxSd=0;
}
}
...
reading:
nowRxSd=1;
HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t*)&tmpBuffer, sdaddr, 32);
while (nowRxSd==1) {}
while (1)
{
ch=HAL_SD_GetCardState(&hsd);
if (ch==HAL_SD_CARD_TRANSFER) break;
}
writing:
nowTxSd=1;
ch1=HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t*)&adcBuffer, address, 32);
while (nowTxSd==1) {}
while (1)
{
ch=HAL_SD_GetCardState(&hsd);
if (ch==HAL_SD_CARD_TRANSFER) break;
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2017-08-29 11:39 AM
Georgy, your solution wont solve timeouts on ReadBlocksDMA function. But its proper Flow to read and write with when using dma
2017-10-03 08:53 AM
Hi,
Thanks for highlighting this issue!
I will check it with our development team & come back to you ASAP.Sorry for the inconvenience it may bring.
-Nesrine-
2017-10-18 03:26 AM
Hi friends!
Do anybody have working project for STM32L476 for READ WRITE files with DMA mode using by FatFs?
Could you send me this project?
mailto:boretskyv@gmail.com
Best regards.
2017-10-19 08:44 AM
This worked. Similar situation with heavily loaded stm32F401.
Thanks Chris,
Tony
2017-10-30 01:28 AM
Hi Nesrine,
Any updates on this - will there be a fix when the next versions are released? The initial problem was reported for L4, but it's the same issue of F7.
2017-11-15 07:01 PM
I can also confirm it is the same case with the F4 library, and
Moshkin.Georgy
's fix works.2017-11-16 08:24 AM
Thank you for mentioning that. I used similar approach with callbacks not only for SDIO but also for SPI with the newest libraries around August. Wiznet chip Ethernet, AX1 software tool loopback works with DMA near full theoretical MBPS speed limit without errors. Had no problems with SD cards yet, although I use only old 2gb cards which are slow, and no fat FS. But setup is pretty heavy, Simultaneously working: SPI+DMA, sdio+DMA writing to SD card, i2s 4 channels + interrupts, UART+interrupts, signal processing, all on F4. I did not used DMA everywhere just because there are no more free DMA channels left, because there is also DAC-dma and some other stuff.
Here is email I sent to someone interested in solving similar problem:
Unfortunately I did not used FatFS in my projects.
Although someone mentioned that 'Georgy, your solution wont solve timeouts on ReadBlocksDMA function. But its proper Flow to read and write with when using dma',I think it will probably solve the problem.Main idea is to wait for HAL_SD_RxCpltCallback before calling any other SDIO functions. I did not traced the problem, but if HAL_SD_ReadBlocks_DMA is followed by any SDIO calls (reading SDIO status/etc.) then reading did not work properly. Note that problems with FatFS appear on newer HAL firmware libraries.I use SPI for WizNet Ethernet chip and SDIO for SD card, both in DMA modes.I had similar problems with SPI dma reading (latest HAL firmware). For example, random Ethernet exchange errors on high data rates. Problem solved in similar way: waiting for reading/writing CPLT callback.Although this approach is blocking execution until CPLT callback is called:
HAL_SD_ReadBlocks_DMAblocking execution, waiting for HAL_SD_RxCpltCallbackit may be improved: for example set flag in read CPLT callback. Check this flag before reading.default value of flag is 1 (CPLT is called)reading operation:
on program execution flag is initialized to 1, as if CPLT callback is already called.
check if flag is 1SDIO read, set flag=0
do not wait, continue execution
if later another read operation is performed:
check if flag is 1
SDIO read, set flag=0
do not wait, continue executionHope it helps.
Georgy.
2017-11-16 06:36 PM
The HAL library is a great work. However, it does needs some touch to work reliably. Thanks to this forum, I also solved a DMA FIFO error problem for SDRAM to SPI transfer the other day.
BTW, after your fix my FAT on TF card works so far so good. In my system, there are RTOS, and quite a few DMA, including 4 SPI, SDIO, DAC, timer for pulse sequence, and USB.
PS. a little off-topic, are you also aware some glitch with the USB library? maybe the USB HAL as well. As some of my USB stick does not work properly with the recent HAL, but it worked ok with the HAL some time last year.
2017-11-29 03:20 AM
Hi Nesrine,
When can we expect an official patch to SD timeout issue? It takes too much time in my opinion.