Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


FF_Format() does not work as expected on STM32F4

Posted by sanjayanvekar on May 26, 2017

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

Posted by heinbali01 on May 27, 2017

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. */ BaseTypet xPartitionNumber = 0; xError = FFFormat( 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, '\0', 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. */


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists