Skip to main content
Visitor II
November 19, 2021
Question

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

  • November 19, 2021
  • 2 replies
  • 729 views

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).

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    November 29, 2021

    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

    Graduate
    February 21, 2025

    Any updates on when this will be fixed?