This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Formatting a SD-Card with the nRF52840

Hi DevZone,

Does anyone have any experience with performing a SD-Card format with the nRF52840. This is to avoid removing the SD-Card from the hardware when a format is required.

I have been looking through the FatFS example from the Nordic SDK version 15.3. Below is the local location on my PC:

C:\SDK\nRF5_SDK_15.3.0_59ac345\examples\peripheral\fatfs\pca10056\blank\ses

This example uses the FatFS from ChaN (2014) and I have found the format IOCTL command at this location:

C:\SDK\nRF5_SDK_15.3.0_59ac345\external\fatfs\src\diskio.h (Line 59)

It seems like the user has to define their own disk format function to be attached to this command as it is not included in the nRF block device driver IOCTL function:

C:\SDK\nRF5_SDK_15.3.0_59ac345\components\libraries\block_dev\sdc\nrf_block_dev_sdc.c (line 336)

Has anyone done this successfully?

Br. Casper

Parents Reply Children
  • Hi Simonr,

    Thank you for the reply.
    What I am looking for specifically is how to use the nRF52840 to perform the formatting of the SD-Card. I was thinking that it would make sense to be able to perform the formatting without a successful mount on the Fat32 filesystem, and actually as a reaction to a failed mount. The comment attached to the to the CTRL_FORMAT command in the diskio.h file suggests this as well in my opinion:

    /* Generic command (Not used by FatFs) */
    #define CTRL_POWER			5	/* Get/Set power status */
    #define CTRL_LOCK			6	/* Lock/Unlock media removal */
    #define CTRL_EJECT			7	/* Eject media */
    #define CTRL_FORMAT			8	/* Create physical format on the media */

    From what I am finding I need to use the low level "IOCTL" functions on which I can't find the information I need. Maybe I am wrong and a different approach is needed?

    I was not able to find any information about this using the search function, or by looking into the threads you linked above.

    Br. Casper

Related