Skip to main content
JSmit.18
Associate II
August 6, 2023
Question

Wrong returned value in the library function SD_initialize()?

  • August 6, 2023
  • 0 replies
  • 594 views

I am having problem with FATFS remounting with Cube IDE and STM327H50.  Tracing the program surfaced the SD_initialize() function which is defined in the ST library file  FATFS/Target/sd_diskio.c

The problem is that when BSP_SD_Init() failed, SD_initialize() returns whatever value previous functions left in the variable Stat, which can cause SD_initialize() to sometimes return OK even if BSP_SD_Init() failed.

Am I missing something?

 

 

/**
 * @brief Initializes a Drive
 * @PAram lun : not used
 * @retval DSTATUS: Operation status
 */
DSTATUS SD_initialize(BYTE lun)
{
#if !defined(DISABLE_SD_INIT)
 if(BSP_SD_Init() == MSD_OK)
 {
 Stat = SD_CheckStatus(lun);
 }
#else
 Stat = SD_CheckStatus(lun);
#endif
 return Stat;
}

 

 

    This topic has been closed for replies.