STMicroelectronics / STM32CubeL4

STM32Cube MCU Full Package for the STM32L4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
262 stars 153 forks source link

SDMMC with dma ( with or withour freertos ) don't work #28

Closed Hhdd06 closed 3 years ago

Hhdd06 commented 3 years ago

after configuration of Sdmmc prephiral with stm32cubeMx for nucelo board L452RE and a costum board with an mcu stm32L462ve , the driver generated don't work . even when i use a project compiled for anthoer STM31L4 board and used with the other board don't work . when i descativate the DMA for SDmmc , the driver work correctly and i can use my sd card

i use all the new version of stm32cubeid and cubemx and FwCube

ASELSTM commented 3 years ago

Hi @Hhdd06,

Thank you for this report. For a better understanding of the problem may I ask you some question :

  1. When you say "the driver generated don't work" does this mean that there is compilation errors or the behavior of the SDMMC is not what is expected.

  2. If possible, would you please share the generated project for further analysis.

With regards,

Hhdd06 commented 3 years ago

i mean the behavior of SDMMC when i activate the dma with CubeMX : when i use fopen function . it return FR_DISK_ERR always but when i deactivate the dma for SDMMC , the application ( write and read in a file) work correctly . note : even when i activate freertos which forced dma, i see the same problem . Sb_uSD.zip

ASELSTM commented 3 years ago

Hi @Hhdd06,

After checking out the sent project, it seems like CubeMX is not importing the right files according to the configuration of FATFS. Indeed, when enabling "Use dma template" within the FATAFS "Advanced settings" , CubeMX should include sd_diskio_dma.h/c files instead of including sd_diskio.h/c files so that you can use SDMMC in dma mode.

You can check the FATFS application FatFs_uSD_DMA_Standalone proposed within the repository. It's working well and there is no issue with SDMMC in dma mode. This issue is therefore related to CubeMX rather than to the firmware published within this repository.

Actually, aspects related to CubeMX tool are not handled at GitHub level. They are rather treated at ST Community level, precisely within the CubeMX dedicated section. There, you may find posts that already raised the issue you are pointing out here. Otherwise, you can create a new post to submit your issue.

As this issue is not directly related to software component published within this repository (CMSIS, HAL, BSP, etc.) but rather to ecosystem (CubeMX tool), please allow me to close it. Thank you for your comprehension.

With regards,

smartel99 commented 3 years ago

After having this bug as well, I have narrowed the issue down to the sd_diskio files created by the cube when using FATFS with SDMMC. I don't know exactly what the bug is since I do not have the time to troubleshoot a third-party library, so my solution was to simply get rid of the SDMMC layer and use the SPI instead. Since this is not an option offered by CubeMX, you need to select "User Defined" in FATFS, then use this library.

Looking around online for solutions, I've noticed people complaining about this exact issue since at least 2016. Kind of disappointing to see that the issue has not been solved 5 years later