FF_Format() does not work as expected on STM32F4
Hello,
I am tyring to use FF_Format() as descibed in the standrd example provided on freertos website, but unfortunatley the formated SD card is not recongnized by Windows and also after formating I cannot create any file on the embedded device. I am using FAT32 format and currently trying with 8Gb uSD card. Please help me to resolve this issue.
Thanks & Best Regards,
Sanjay
FF_Format() does not work as expected on STM32F4
Hi Sanjay,
When you use a pre-formatted card, can your device correctly read and write that card?
I just tried to format a card on my STM32F4 EVAL, by calling
FF_SDDiskFormat()
from ff_sddisk.c
.
It calls FF_Format()
as follows:
~~~
/* Format the drive – try FAT32 with large clusters. */
BaseType_t xPartitionNumber = 0;
xError = FF_Format( pxDisk, xPartitionNumber, pdFALSE, pdFALSE);
~~~
It produces this logging with a 16GB card:
~~~
00.000 [SvrWork ] >> format
00.000 [SvrWork ] FFFormat: Secs 31291384 Rsvd 32 Hidden 8 Root 0 Data 31291352
00.000 [SvrWork ] FFFormat: SecCluster 64 DatSec 31283704 DataClus 488807 ulClusterBeginLBA 7688
00.037 [SvrWork ] FFFormat: Clearing entire FAT (2 x 3819 sectors):
14.473 [SvrWork ] FFFormat: Clearing done
14.473 [SvrWork ] FFFormat: Clearing root directory at 00001E08: 64 sectors
14.681 [SvrWork ] FFSDDiskFormat: OK, now remounting
14.686 [SvrWork ] prvDetermineFatType: firstWord 0000FFF8
14.687 [SvrWork ] ****** FreeRTOS+FAT initialized 31291384 sectors
14.687 [SvrWork ] FF_SDDiskFormat: rc 00000001
14.687 [SvrWork ] Reading FAT and calculating Free Space
14.687 [SvrWork ] Partition Nr 0
14.687 [SvrWork ] Type 12 (FAT32)
14.688 [SvrWork ] VolLabel ‘MY NAME ‘
14.688 [SvrWork ] TotalSectors 31291384
14.688 [SvrWork ] SecsPerCluster 64
14.688 [SvrWork ] Size 15275 MB
14.688 [SvrWork ] FreeSize 15275 MB ( 100 perc free )
~~~
I copied directories and files to the SD-card and checked them under Linux with fsck.vfat. It passed the tests.
Can you show any logging as here above?
Does your uSD card contain a valid partition table? Was it already formatted before you tried to format it?
Here is how you can create a partition:
FF_IOManager_t *pIoMan = sddisk_ioman( xMyDisk );
FF_PartitionParameters_t xParameters;
memset( &xParameters, ' ', sizeof xParameters );
xParameters.xSizes[0] = 100; /* Assign 100% to the first partition. */
xParameters.ulSectorCount = pxDisk->ulNumberOfSectors;
xParameters.ulHiddenSectors = 8; /* Keep at least these initial sectors free. */
xParameters.xPrimaryCount = 1; /* If true, the partition will become of type "extended". */
FF_Error_t xError = FF_Partition( &xMyDisk, &xParameters );
if( FF_isERR( xError ) == 0 )
{
/* partition OK. */
}
Regards.