AnsweredAssumed Answered

Configure SDMMC+FATFS+DMA+RTOS in STM32CubeMX for STM32L4

Question asked by Evgeny Kirshin on Jan 24, 2018
Latest reply on Apr 11, 2018 by Evgeny Kirshin



There were questions similar to this before, but not exactly. 

This is applicable to STM32CubeMX V4.24.0 with STM32CubeL4 fw package V1.11.0 (latest at this time).


Previously code generated by STM32CubeMX for configuration of SDMMC+FATFS+DMA+RTOS was not working. Some workarounds were found on the discussion boards which required modification of code generated by STM32CubeMX (i.e. these modifications would be erased by following code regenerations). The code generated by STM32CubeMX did not match code from the STM32CubeL4 package (STM32Cube_FW_L4_V1.11.0\Projects\32L496GDISCOVERY\Applications\FatFs\FatFs_uSD_DMA_RTOS). For example, SD_initialize() function from sd_diskio.c was missing initialization of queue SDQueueID (compared to the same function in sd_diskio_dma_rtos.c from the STM32CubeL4 example). Essentially, the queue was left uninitialized at all (should this have been done by user?). 

Right now, in STM32CubeMX V4.24.0 I see this has been corrected (initialization of SDQueueID is now present in the generated SD_initialize() function). However, it is still not clear how to correctly configure the project in STM32CubeMX and what are additional modifications required in the generated code (what is left to be done by user).

Also, the STM32CubeL4 example uses only one SDMMC DMA channel for both TX and RX. Is it possible to generate code from STM32CubeMX which will be using only one channel in the same way as the STM32CubeL4 example? Comparing the generated code by STM32CubeMX with the STM32CubeL4 example, it currently doesn't look like there is a way to adjust the code (by using only sections for USER code) so that it works as the example code. 


Does anyone have a solution for this? Are there guidelines on SDMMC+FATFS+DMA+RTOS project generation from STM32CubeMX?


Thank you.