2025-08-13 5:27 AM - last edited on 2025-08-13 6:33 AM by Saket_Om
Hi, It works, apparently a different microSd card works.
however, it is strange that, DATALOG2 could write into the card.
May i know how shall i perform sd card format function or what to fill up in the function?
Follow-up of the the topic below:
Solved: Re: Standalone FileX SDIO SD Card Initializing err... - STMicroelectronics Community
2025-08-13 6:03 AM
Hello @frogrammer
To format your SD card you can use f_mkfs(). Please refer to the article below:
How to create a file system on a SD card using STM... - STMicroelectronics Community
2025-08-13 6:05 AM
thats using fatfs, not FileX
2025-08-13 6:27 AM
For FileX it is fx_media_format(). Pledase refer to the implementation on the example below:
2025-08-13 8:20 AM
Usually every new SD card is formatted,
at the optimum for this card.
So you just could do it worse by format the card.
And always first do only read tests, with existing file on card, then read and write tests. Format should be never needed, bzw bigger cards are exfat formatted and need this enabled in fat drivers.
2025-08-18 6:30 AM
Hello @frogrammer
Did you manage to format your SD card using FileX API?
2025-08-28 6:36 AM
Hello @frogrammer,
How to Format an SD Card with FileX
To format an SD card, the main steps are as follows:
Initialize the File System
Before any operation, you need to initialize the file system using the fx_system_initialize() function. This prepares the FileX environment to manage storage media.
Use the fx_media_format() Formatting Function
This function formats the card with a file system (FAT32). It requires several important parameters:
UINT _fx_media_format(FX_MEDIA *media_ptr,
VOID (*driver)(FX_MEDIA *media),
VOID *driver_info_ptr,
UCHAR *memory_ptr,
UINT memory_size,
CHAR *volume_name,
UINT number_of_fats,
UINT directory_entries,
UINT hidden_sectors,
ULONG total_sectors,
UINT bytes_per_sector,
UINT sectors_per_cluster,
UINT heads,
UINT sectors_per_track);
media_ptr:
Pointer to the media control block. This structure manages the media and does not need to be opened before calling this function.
driver:
Pointer to the FileX driver function. This driver must be able to handle requests before the media is opened.
driver_info_ptr:
Optional pointer to driver-specific information or context.
memory_ptr:
Pointer to a memory buffer used by FileX during formatting. This buffer must be at least 512 bytes plus one sector size.
memory_size:
Size of the memory buffer pointed to by memory_ptr.
volume_name:
Name of the volume (label) to assign to the formatted media.
number_of_fats:
Number of FAT copies to create (usually 2 for redundancy).
directory_entries:
Number of root directory entries.
hidden_sectors:
Number of hidden sectors before the start of the volume.
total_sectors:
Total number of sectors on the media.
bytes_per_sector:
Number of bytes per sector (commonly 512 bytes for SD cards).
sectors_per_cluster:
Number of sectors per cluster, which defines the allocation unit size.
heads:
Number of heads (used to simulate disk geometry; usually 1 for removable media).
sectors_per_track:
Number of sectors per track (used for disk geometry simulation).
Regards,
Maher