Skip to main content
Visitor II
November 19, 2025
Solved

STM32U5 FATFS with FreeRTOS

  • November 19, 2025
  • 2 replies
  • 238 views

Hi,

I'm attempting to write to an SD Card using a Riverdi STM32U5A9 display board.  Since TouchGFX natively uses FreeRTOS, I'm attempting to keep it within FreeRTOS.  Porting to ThreadX has caused it's own issues which I have in a separate thread.  In the Configurator, there is no longer an option for FATFS, so I'm using the STM32U5 Classic MW Git Repository as recommended by the FAE.  I copy over and update the templates as required, but am still getting a Hard Fault during f_mkfs while the HAL library is initializing the SDMMC.  I believe that my configuration is incorrect, but the example is only for SDRAM, so I'm not entirely sure where I've gone wrong...  I have it setup for 4-bit width and I've changed the clocks to be 24MHz at the SDMMC clock output.  The examples within the configuration are for older MCUs and have a tab to enable the DMA.  My understanding is that the STM32U5 has an Internal DMA, so it's not required to setup the DMA within the configuration.

Any help is appreciated!

co2meter_0-1763562827680.png

 

co2meter_1-1763562850347.png

co2meter_2-1763563015363.pngco2meter_3-1763563045901.pngco2meter_4-1763563075518.png

Thank you!

 

    This topic has been closed for replies.
    Best answer by co2meter

    Update:

    Got it working entirely thanks to this post:

    https://community.st.com/t5/stm32-mcus-embedded-software/buffer-overflow-in-cubemx-sdmmc-driver/td-p/426184

    Enabling the Hardware Flow Control, setting the clock to 8MHz, and keeping it at 4bit width is working.

    2 replies

    co2meterAuthor
    Visitor II
    November 19, 2025

    Update:

    I've managed to get beyond this issue.  It turned out that CubeMX was not adding the SDMMC_Init to the main.  After adding, I no longer hard fault.  I now get FR_DISK_ERR at disk_write in ff.c during f_mkfs.  Still leads me to believe that there is an issue with the configuration.  I've lowered the SDMMC clock down to 12MHz, but that's not fixing the issue.

    co2meterAuthorAnswer
    Visitor II
    November 19, 2025

    Update:

    Got it working entirely thanks to this post:

    https://community.st.com/t5/stm32-mcus-embedded-software/buffer-overflow-in-cubemx-sdmmc-driver/td-p/426184

    Enabling the Hardware Flow Control, setting the clock to 8MHz, and keeping it at 4bit width is working.