Skip to main content
DYann.1
Senior II
January 10, 2025
Solved

How to configure FatFs with DMA on STM32L5 using CubeMx.

  • January 10, 2025
  • 3 replies
  • 1702 views

Hello, 

I would like to have advice, I see this video about SD Card :

https://www.youtube.com/watch?v=I9KDN1o6924&t=359s

And in the video (5:30) I can see DMA tab via CubeMX

DYann1_0-1736510553492.png

But with me I don't have this tab, do you know why ?

DYann1_1-1736510815033.png

I have STM32L552E-EV Evaluation Board with STM32L552ZET6QU microcontroller, after me It's possible to have the DMA with SD Card.
I have this Version: 1.13.1 for STM32CubeIDE

Thank you for your helps.

Regards

Best answer by mƎALLEm

@DYann.1 wrote:

Thank you for this information, does this mean by default I am already in DMA with my STM32L5xx card ? Right ? For CubeMX I have this version

 

 As said SDMMC is already a DMA but in sd_diskio.c / SD_read() and SD_write() there are two types of implementations with and without DMA:

HAL_SD_ReadBlocks_DMA(): with DMA 

HAL_SD_ReadBlocks(): without DMA

HAL_SD_WriteBlocks_DMA(): with DMA 

HAL_SD_WriteBlocks(): without DMA

Look at the implementations of SD_read() and SD_write() in the examples:

STM32L552E-EV/Applications/FatFs/FatFs_uSD_Standalone

and

STM32L552E-EV/Applications/FatFs/FatFs_uSD_DMA

Their corresponding sd_diskio.c are respectively:

1- https://github.com/STMicroelectronics/STM32CubeL5/blob/master/Projects/STM32L552E-EV/Applications/FatFs/FatFs_uSD_Standalone/FATFS/Target/sd_diskio.c

2- https://github.com/STMicroelectronics/STM32CubeL5/blob/master/Projects/STM32L552E-EV/Applications/FatFs/FatFs_uSD_DMA/FATFS/Target/sd_diskio.c

PS: in any case you need to update your CubeMx version.

3 replies

Andrew Neil
Super User
January 10, 2025

Do you really need DMA?

Maybe simpler to start without DMA first?

 


@DYann.1 wrote:

I have this Version: 1.13.1 for STM32CubeIDE


That's quite old now - latest is 1.17.0:

https://community.st.com/t5/stm32cubeide-mcus/stm32cubeide-1-17-0-released/td-p/747656

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
DYann.1
DYann.1Author
Senior II
January 10, 2025

@Andrew Neil wrote:

Maybe simpler to start without DMA first?

https://community.st.com/t5/stm32cubeide-mcus/stm32cubeide-1-17-0-released/td-p/747656


I know without DMA but our real application requires the use of DMA that's 100% certain. Thank you for the last version STM32CubeIDE, I'll going to install it and see if I have the DMA tab.

Andrew Neil
Super User
January 10, 2025

@DYann.1 wrote:


I know without DMA but our real application requires the use of DMA that's 100% certain. .


But, again, why not start with the simpler case?

Don't add unnecessary complications too early.

Get the simple case working first, then move on to the more advanced case.

As the old proverbs go,

Learn to walk before trying to run

Don't bite of more than you can chew

Don't dive straight in to the deep end

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
DYann.1
DYann.1Author
Senior II
January 10, 2025

@unknown wrote:

Hello,

The reason you don't see the DMA tab in CubeMX for your STM32L552E-EV board might be due to the following factors

  1. CubeMX or Firmware Version: The version of CubeMX or the STM32 firmware package you’re using might not fully support the DMA configuration for the SDMMC peripheral on your specific microcontroller. Make sure you have the latest STM32CubeIDE (1.13.1 in your case) and the STM32 firmware package installed for the L5 series.


M Tanveer


Hi,

Thank you for this information, yes I think the version of CubeMX is not recent. Even if I install the new version of STMCubeIDE, I won't have the DMA tab either since the video is quite old.

Thank you for your helps.

Regards

mƎALLEm
Technical Moderator
January 10, 2025

@DYann.1 wrote:

I have STM32L552E-EV Evaluation Board with STM32L552ZET6QU microcontroller, after me It's possible to have the DMA with SD Card.


There is no DMA configuration for the SDMMC on L5 as it's already a master (a kind of DMA):

SofLit_1-1736521839711.png

Unlike the F7 family, SDMMC1 is mounted as a slave on APB2 where you can configure a DMA (a master) for DMA transfer:

SofLit_2-1736521998973.pngSofLit_3-1736522171402.png

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
DYann.1
DYann.1Author
Senior II
January 10, 2025

Thank you for this information, does this mean by default I am already in DMA with my STM32L5xx card ? Right ? For CubeMX I have this version

DYann1_0-1736523067950.png

 

mƎALLEm
mƎALLEmBest answer
Technical Moderator
January 10, 2025

@DYann.1 wrote:

Thank you for this information, does this mean by default I am already in DMA with my STM32L5xx card ? Right ? For CubeMX I have this version

 

 As said SDMMC is already a DMA but in sd_diskio.c / SD_read() and SD_write() there are two types of implementations with and without DMA:

HAL_SD_ReadBlocks_DMA(): with DMA 

HAL_SD_ReadBlocks(): without DMA

HAL_SD_WriteBlocks_DMA(): with DMA 

HAL_SD_WriteBlocks(): without DMA

Look at the implementations of SD_read() and SD_write() in the examples:

STM32L552E-EV/Applications/FatFs/FatFs_uSD_Standalone

and

STM32L552E-EV/Applications/FatFs/FatFs_uSD_DMA

Their corresponding sd_diskio.c are respectively:

1- https://github.com/STMicroelectronics/STM32CubeL5/blob/master/Projects/STM32L552E-EV/Applications/FatFs/FatFs_uSD_Standalone/FATFS/Target/sd_diskio.c

2- https://github.com/STMicroelectronics/STM32CubeL5/blob/master/Projects/STM32L552E-EV/Applications/FatFs/FatFs_uSD_DMA/FATFS/Target/sd_diskio.c

PS: in any case you need to update your CubeMx version.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."