cancel
Showing results for 
Search instead for 
Did you mean: 

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

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?
1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

7 REPLIES 7

Back to the top

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
Up vote any posts that you find helpful, it shows what's working..

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

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
Up vote any posts that you find helpful, it shows what's working..

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

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!

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.