Skip to main content
Graduate
December 10, 2023
Solved

FILEX: `fx_media_format` parameters.

  • December 10, 2023
  • 1 reply
  • 3285 views

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.

    This topic has been closed for replies.
    Best answer by Haithem Rahmani

    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.

    1 reply

    ST Employee
    December 11, 2023

    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.