Skip to main content
shabbir.hussain
Associate II
October 10, 2019
Question

Is there a fix on using FREERTOS + FATFS + SDIO + DMA?

  • October 10, 2019
  • 6 replies
  • 1910 views

I am creating a project for the STM32F767ZI. The Fatfs library WITHOUT freeRTOS works well. When I include freeRTOS in my project, I cannot get past mounting the disk:

retSD = f_mount(&SDFatFS, (TCHAR const*) SDPath, 1);

From reading the forums, I found that some people have found a solution for certain MCUs. Is there a configuration where I can use FREERTOS + FATFS + SDIO + DMA?

My cubemx settings are as follows: I am using SDIO 1 bit bus and DMA for RX and TX. I have set my stack size to 0x2000, my heap size to 0x4000. I'm using FatFS with the DMA template.

This topic has been closed for replies.

6 replies

Tesla DeLorean
Guru
October 10, 2019

Try keeping ALL the SDIO/FATFS stuff in a singular thread, and use DTCMRAM for all SDIO/SDMMC work. Put checks in DISKIO to confirm both memory usage AND alignment.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
shabbir.hussain
Associate II
October 10, 2019

I am using it in a single thread. In fact, I'm calling the mount command in the "default task", so I'm already single threaded.

Is setting the SDIO to use DTCRAM an option in cubeMX?

Can you point to any resources for putting checks in DiskIO that check memory usage and alignment? On my cube IDE I see that my current project uses only 20% of the ram resources.

shabbir.hussain
Associate II
October 11, 2019

I have solved this issue and it comes down to choosing the correct cubeMX settings. Here are the settings that work on the STM32F767ZI:

SDMMC

  • SDIO 1 bit
  • Hardware flow control turned ON
  • enable NVIC for all 3 items in the table (it should read DMA2 chan 0, DMA2 chan5, SDMMC)
  • Add SDMMC_TX, SDMMC_RX in the DMA menu
  • Ensure DO and CMD pins in the GPIO have a pullup resistor

FreeRTOS

  • Enabled
  • Disable premption
  • under tasks and queues make the default task stack size 512 words

FatFS

  • Enable LFN
  • under platform settings choose a GPIO input pin to serve as the SD detect pin. Create one if the menu is empty.
Dave Nadler
Senior III
October 11, 2019

Whoa! Any idea why you need to disable preemption??

shabbir.hussain
Associate II
October 14, 2019

I'm assuming that the FatFs library is not actually reentrant.