Skip to main content
Mohammed Eshaq
Associate II
May 20, 2021
Question

SDMMC with Internal (I)DMA + FATFS with DMA Template - not working! [STM32H7]

  • May 20, 2021
  • 4 replies
  • 5461 views

Hi, everyone!

I have a custom board with an STM32H7. I configured SDMMC2 correctly on it.

0693W00000AP0rtQAD.png 

As you can see there is no options for configuring DMA since it has an Internal (I)DMA.

I have also added FATFS, as follows.

0693W00000AP0s3QAD.png 

I managed to write/ready successfully to SD CARD mounted via FATFS. My problem arises when I enable the ‘Use DMA Template’. It is a must in order to later add FreeRTOS to the project.

After hours of debugging I realized that:

  • f_write() calls disk_write(), which calls sd_write(), which calls BSP_SD_WriteBlocks_DMA(), which calls HAL_SD_WriteBlocks_DMA(), and does not return any errors.
  • In sd_write(), WriteStatus desn’t get set to 1 [in sd_diskio.c] and times out.
  • HAL_SD_IRQHandler() gets called but it subsequently never calls HAL_SD_TxCpltCallBack() (which should eventually via many wrappers set WriteStatus to 1), and completely skips it.
  • I get HAL_SD_ERROR_TX_UNDERRUN.

Any help is highly appreciate it :folded_hands: .

This topic has been closed for replies.

4 replies

Amel NASRI
ST Technical Moderator
May 20, 2021

Hi @Mohammed Eshaq​ ,

Please make sure that you are not hitting one of the conditions that makes "DMA is not working on STM32H7 devices".

You can also refer to following example available under STM32CubeH7 package (path: Projects\STM32H743I-EVAL\Applications\FatFs\FatFs_uSD_DMA_RTOS).

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Amel NASRI
ST Technical Moderator
June 2, 2021

Hi @Mohammed Eshaq​ ,

Were you able to solve the issue you described here? If yes it will be helpful for us and other Community members to know what was the solution?

-Amel

To give better visibility on the answered topics, please click on "Best Answer" on the reply which solved your issue or answered your question.
Mohammed Eshaq
Associate II
June 7, 2021

Hi @Amel NASRI​ ,

I appreciate your follow-up. But, no, the solution provided did not solve my problem. I have tried the following.

  • I have completely disabled the Data and Instruction Cache completely.
  • Changed the Linker Description File so that .data .bss, and user heap points to RAM_D1 (also tried D2 since SDMMC is located on D2).
  • Changed the starting address in the Linker Description File for RAM.

I noticed that SDMMC2_IRQHandler() does get called but exits without calling BSP_SD_WriteCpltCallBack(). I get HAL_SD_ERROR_TX_UNDERRUN. I spent days debugging this and trying different configurations but with no luck!