‎2020-10-06 03:09 AM
Dear all,
i'm developing an application with STM32F750N8 and I'm using SDMMC peripheral (48MHz clock, rising clock transition, no prescaler and hardware flow control) and FatFs library, for read and write the micro SD Card.
I tried to use a 1GB SD Card, formatted with FAT32 and 512 byte for sector size, and all works fine.
If I try to use a 16GB SD Card, first of all windows make me format it with minimum sector size of 4096 byte and, also if I set the FatFs library with MAX_SS at 4096 and MIN_SS at 512, I can't mount it. I tired also with MAX_SS = MIN_SS = 512 but nothing change.
I noticied that:
1) if mount the SD at startup it fails in this point:
f_mount(...) -> find_volume(...)
inside find_volume return error in:
if(fmt == 4) return FR_DISK_ERR;
2) if remove and insert the SD (the same) during application run, the mount fails in this point:
f_mount(...) -> find_volume(...) -> check_fs(...) -> move_window(...) -> disk_read(...) -> SD_read(...) -> BSP_SD_ReadBlocks(...) -> HAL_SD_ReadBlocks(...)
inside HAL_SD_ReadBlocks return error in (errorstate has value 4):
/* Set Block Size for Card */
errorstate = SDMMC_CmdBlockLength(hsd->Instance, BLOCKSIZE);
if(errorstate != HAL_SD_ERROR_NONE)
{
/* Clear all the static flags */
__HAL_SD_CLEAR_FLAG(hsd, SDMMC_STATIC_FLAGS);
hsd->ErrorCode |= errorstate;
hsd->State = HAL_SD_STATE_READY;
return HAL_ERROR;
}
In this case I tried also to set BLOCKSIZE to 4096 but nothing changes.
When SD Card detected I call FATFS_LinkDriver and after f_mount (for mount); when SD Card removed I call f_mount (for unmount) and after FATFS_UnLinkDriver.
Where could be the problem? Any ideas?
Is it mandatory to have an SD card formatted with 512 sector size? If so I can use only SD Card smaller than 2GB?
Thanks in advance.
‎2020-10-06 04:49 AM
This is all very confused.
I've got cards 10's of GB in size using 512 byte sectors​, and clusters using multiples of those, that run just fine, using FAT32.
Beyond 32GB FATEX is generally used, and needs to be enabled in FatFs.
FatFs is not going to support NTFS volumes.​
‎2020-10-06 05:43 AM
Thanks for your reply.
Yes is very confused also for me 😅 (sorry).
Try to summarize: I have problems with 16's and 32's of GB SD Card.
I formatted the 16's of GB SD Card with FAT32 and 4096 cluster size:
The block size in the stm32f7xx_hal_sd.h is 512:
#define BLOCKSIZE 512U /*!< Block size is 512 bytes */
but when I insert the SD Card and try to mount it, the operation fails as described in the main question.
Inside find_volume function (called from f_mount function) it return with error in:
1) the first time in
if (fmt >= 2) return FR_NO_FILESYSTEM; /* No FAT volume is found */
becasue fmt has value 3.
2) the next times in
if (fmt == 4) return FR_DISK_ERR;
because fmt has value 4.
With 1's of GB SD Card I have no problems.
I hope I was clearer now.
‎2021-01-14 03:09 AM
I tried the example in the STM32 Cube repository and I found the problem: if I call the function f_mount with the option parameter to 1 (Mount immediately) the problem occurs; if I call the same function with the option parameter to 0 (Do not mount (delayed mount)) it works perfectly.
Can anyone tell me why?
‎2021-01-14 05:51 AM
It is hard to tell from here.
I'd assume it relates to if things are initialized properly and in the right order. Perhaps PLL sources clocking the SDMMC?
I would instrument the DISKIO routines, and dump the MBR/BPB sectors, as read, to check the content. Check where it initializes the SDMMC vs the first read operation.
Don't open a view of the SDMMC peripheral in the debugger, it will break the FIFO.
Make sure you have a large enough stack to accommodate any local/auto usage in the code.
With 4K clusters the sectors are still 512 bytes, FatFS should figure this out. The SDHC/SDXC cards definitely assume the sectors are 512 bytes.
What HSE clock frequency are you using? How is the SD Card wired? Pull-ups on the CMD/DATA signals?
Do you have a USART that can be used for diagnostic output? Please specify which, and the pins it uses.
‎2021-01-14 12:08 PM
hello,
Currently I work on SDcard, on SDIO 1 bit, fatfs and freeRTOS.
I use my logic analyzer to watch...where is the problem....
When we f_mount with 0 option (delyed mount) no transaction on the sdio bus
When we f_mount with 1 option (imediat mount) transaction on the sdio bus
If I let the CS to low, the SDcard make answer on DO (SDcard is in SPI mode)
When CS is still high, the SDcard is in mode SDIO, and now answer, the SDIO let time to the SDcard to make the answer, but no data...
Normaly we must have CDM0 (reset the sdcard), CMD8 (define the SD version.... no answer for Version1).... A new CMD0 to reset the SD...CDM55....no answer.... time out.....
No answer, same bus? problem? mistake?
Tomorow I don't talk to the SD..... I will work on it on saturday....
best regards
Eric