cancel
Showing results for 
Search instead for 
Did you mean: 

BUG - Race condition in the FATFS SD DMA template (BSPv1)

Grann
Associate II

Hello,

there is a race condition in the function SD_read() in the template file used by CubeMX when using FATFS with DMA template (sd_diskio_dma_template_bspv1.c).

if(BSP_SD_ReadBlocks_DMA((uint32_t*)buff,
                             (uint32_t) (sector),
                             count) == MSD_OK)
    {
      ReadStatus = 0;

The variable ReadStatus should be set to zero BEFORE the call to BSP_SD_ReadBlocks_DMA(), as it is already the case in the BSP V2 template (sd_diskio_dma_template_bspv2.c) and in the examples using FATFS and SD DMA (e.g. Projects\STM32F412G-Discovery\Applications\USB_Host\AUDIO_Standalone\Src\sd_diskio_dma.c).

1 REPLY 1
Amel NASRI
ST Employee

Good catch @Grann​ !

I'll report this limitation to our development team who will take care to provide a fix.

Internal ticket number: 118428 (PS: This is an internal tracking number and is not accessible or usable by customers).

-Amel

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.