cancel
Showing results for 
Search instead for 
Did you mean: 

FILEX: `fx_media_format` parameters.

HTD
Senior III

I need to implement formatting of various media like SD cards or USB disks.

With FATFS it was brain dead easy, it just worked without asking for the my shoe size and ultimate answer about universe and everything. With FILEX I need to provide just all binary data for the formatted media that I just don't know and don't even know how to get it.

Let's say that sectors per clusters are typical values for various FAT systems, but the total number of sectors? Just how should I get it?

I'd guess it should be obtainable by the driver, but how? I mean, total number of bytes would be fine, but how do I get it for media like SD cards and USB disks?

Number of heads? What? I'd guess 1 for all types of solid state devices.

I'm implementing a format function like this:

`virtual Status format(Media& media, const char* volumeName, MediaFormat fs = MediaFormat::ExFAT) = 0;`

Where fs can be FAT12, FAT16, FAT32 and ExFAT.

How to use `fx_media_format()` and `fx_media_exFAT_format()` to just format USB disk and SD card with some sane defaults?

I do have driver and driver info data. I do have media structure. What I don't have is everything else.

1 ACCEPTED SOLUTION

Accepted Solutions
Haithem Rahmani
ST Employee

Hi @HTD,

  • SDMMC
    Use the HAL/SD API below to get the sd card info.

 

 

HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo);​

 

 

where the HAL_SD_CardInfoTypeDef is defined here

      there you can have details USB thumb characteristics (ux_host_class_storage_media_number_sectors, ux_host_class_storage_media_sector_size)

 

regards
Haithem.

View solution in original post

1 REPLY 1
Haithem Rahmani
ST Employee

Hi @HTD,

  • SDMMC
    Use the HAL/SD API below to get the sd card info.

 

 

HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo);​

 

 

where the HAL_SD_CardInfoTypeDef is defined here

      there you can have details USB thumb characteristics (ux_host_class_storage_media_number_sectors, ux_host_class_storage_media_sector_size)

 

regards
Haithem.