Skip to main content
Oliver Sedlacek
Senior
September 22, 2020
Solved

FATFS on SD card with FreeRTOS, does it insist on using DMA?

  • September 22, 2020
  • 7 replies
  • 2913 views

So I'm back to getting the FATFS-SDMMC-FreeRTOS combo working on my board. I've got a simple project working without FreeRTOS and it uses the HAL_SD in polled mode. Stepping through my FreeRTOS project I see that this project calls HAL_SD_ReadBlocks_DMA() which fails. This doesn't surprise me as I haven't set up DMA and I can't see that CubeMX does either!

My questions are:

  1. Do I have to use DMA with FATFS-SD card and FreeRTOS? If not, where do I change it to polled mode?
  2. If I do need to use DMA, how do I set it up? CubeMX offers options I don't understand, so is there a crib somewhere?
This topic has been closed for replies.
Best answer by Tesla DeLorean

The data transfer is intolerant to you wandering off mid task. DMA allows it to meet the hard clock deadlines.

7 replies

Oliver Sedlacek
Senior
October 21, 2020

Back to the top

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 21, 2020

The data transfer is intolerant to you wandering off mid task. DMA allows it to meet the hard clock deadlines.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Oliver Sedlacek
Senior
October 21, 2020

0693W0000058tUCQAY.pngOK, DMA it is. CubeMX offers three DMA requests in the 'Select' drop down, so which do I want?

Tesla DeLorean
Guru
October 21, 2020

Not a CubeMX guy, the RM should provide details of the DMA plumbing options. The SDMMC/SDIO is half-duplex, so it is either reading or writing, it doesn't do both concurrently. Took ST a couple of part generations to determine this. Often 2x choices for RX/TX, choice usually depends on utilization by other peripheral sharing a stream/channel (limited mapping options). On the H7 DMA is done by the SDMMC1 peripheral itself.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Oliver Sedlacek
Senior
October 22, 2020

The STM32F7 reference manual is pretty helpful (section 39.3) but it's not completely clear how it relates to all the CubeMX settings. The good news is that the defaults for SDMMC DMA seem to work!0693W00000591MWQAY.png

Oliver Sedlacek
Senior
October 29, 2020

This is going backwards at a fair rate of knots! The settings I shared previously only worked for reads, not writes. I tried setting up two DMA streams, one for read and one for write, which seemed to help for a while. Now nothing works and I can't seem to get back to anything working.

Come on ST, provide some documentation!

Oliver Sedlacek
Senior
November 4, 2020

Just for anyone following this thread, I'd opened a new thread at https://community.st.com/s/question/0D53W00000MgE7qSAF/stm32f767-sdmmc-dma-read-missing-first-16-bytes. Once the DMA cache coherency problem was addressed the SDMMC FATFS sprang into life. It's disappointing that the ST Cube example projects aren't 'real world robust' and will fail in unexpected ways.