2025-06-08 9:45 AM
I am using STM32F407VE Black Board. It contains the STM32F407VET6 chip. It has a microSD slot but the slot's CD pin is not connected. Due to this f_mount() is always returning faults. I don't know if this hardware miss connection is the primary problem why f_mount() returns faults or there are more problems. Please help me out with this. I am stuck since 2-3 days. I tried modifying the dist_status and dist_initialize functions to bypass this hardware check but when I upload the code, the board does nothing for 20-30sec and f_mount again returns error. I have attached my code changes
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 */
0x04 indicates 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;
}
}
stat = 0x04;
return stat;
// return 0;
}
2025-06-08 10:55 AM - edited 2025-06-08 11:06 AM
What is the "slot's CD pin " ? micro SD , see ->
...and this is connection on F407VET black board :
2025-06-17 2:21 AM
Hi @jayanth0625 ,
Missing CD is very unlikely to be the cause of your problems. You can single step through the code to confirm this and most likely something else is going wrong. If you were to see that an expected CD GPIO is read and indicates no card present, then you can easily comment out that code (but as mentioned, I doubt this will be the issue).
Much more likely is problems with the cache and or buffer alignment. If you search this forum for "SDMMC cache" you will find a lot of questions raised and various answers given. As a starting point I would ensure that your data cache is disabled until you have the SDMMC basically working, then consider enabling cache. Also be careful to check MX for the SD initial clock freq.
Good luck!
2025-06-17 10:59 PM
I realize now that CD pin is not a problem. I read about some bugs in the automatic code generated by cubemx. Something with first using 1B bus and then switching to 4B. Nobody seems to be sure why this works. But I will look into this too and let you know. Thanks for the response.
2025-06-17 11:00 PM
When you use it in 4B mode, CD is being utilized as DAT3 which leaves no other pin for selecting the chip