cancel
Showing results for 
Search instead for 
Did you mean: 

SD card issue in SDIO peripheral in Stm32f407VET6 Black Board

toufik_iddou
Associate II

hi, community!

I need to use SDIO integrated into Stm32f407VET6 BlackBoard I followed two videos on youtube and always gave me the same problem  res=f_mount(&fs,"",1); always gives me FR_NOT_READY I asked Gemini and he told me to change it to   res=f_mount(&fs,"",0); when I change it the function return FR_OK but the rest of the functions not work like  f_write f_read are return FR_NOT_READY

I found someone in stack overflow has the same problem but without solution

I hope you can help me

 

videos I followed : 

STM32F4 Discovery board - Keil 5 IDE with CubeMX: Tutorial 22 SD Card SDIO 4 Bits + DMA - YouTube

SD card using SDIO in STM32 || Uart RIng buffer || 4-Bit Mode || CubeMx - YouTube

stack overflow question:

stm32 - SD card issue in SDIO peripheral in Stm32f407VET6 Black Board - Stack Overflow

thank you

4 REPLIES 4

Need to debug at the DISKIO level. Is it failing due to a Card Detect pin on the socket?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I think you are talking about an external module. if I'm wrong tell me,

I'm using the SD card integrated into stm32 Blackboard 

black_f407ve.jpg

One of the main reasons for FR_NOT_READY is not implementing the card detect switch on the SD Card socket, or handling it improperly. It's going to be a GPIO, checked in DISKIO.c layer.

You're not going to be able to debug FatFs via top-level code and errors. You're going to need to debug the DISKIO and SDIO layers. Would suggest instrumenting (messages to a terminal) so you understand what's happening and failing.

Don't write or format cards until you have reading working flawlessly. The cards come formatted, so should rarely, if ever, need f_mkfs()

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I am facing the same issue. I think is it due to the CD pin. In the schematics of this board, the CD pin is connected to GND. I am not able to bypass this hardware check by diskio changes. I am returning 0x004 in disk_status by default but still f_mount doesn't return RES_OK at the end. When I looked on the board's website they said it's easy to get around this CD issue by some software changes but I am not able to find out what to change. Whatever I change, the board hangs for 10-15 secs then returns faults. 

DSTATUS disk_status (
	BYTE pdrv		/* Physical drive number to identify the drive */
)
{
//  DSTATUS stat;
//
//  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
//  return stat;
	return 0x04;
}
// Inside diskio.h:
/* Disk Status Bits (DSTATUS) */

#define STA_NOINIT		0x01	/* Drive not initialized */
#define STA_NODISK		0x02	/* No medium in the drive */
#define STA_PROTECT		0x04	/* Write protected */

 ...

DSTATUS disk_initialize (
	BYTE pdrv				/* Physical drive nmuber to identify the drive */
)
{
  DSTATUS stat = RES_OK;

  if(disk.is_initialized[pdrv] == 0)
  {
    stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
    if(stat == RES_OK)
    {
      disk.is_initialized[pdrv] = 1;
    }
  }
  
  return 0x004;
//	return 0;
}