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

formatting an uSDcard from ext4 to fat32

Hi, I have a problem that when formatting an uSDcard from ext4 to fat32 it gets with both file systems.

  • In my code I use the FAT FS library [http://elm-chan.org/fsw/ff/00index_e.html] and the nordic 12.2.0 SDK [http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.2.0%2Findex.html].

The purpose of my code is to use SD card with any content, I always format the SDCard when starting the code..

I did several tests with the support of the gparted tool:

Test 1:

  1. Ensure with gparted that the sd card is empty (If there is any partition select it and delete it)
  2. Run my code
  3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 3: 1.With gparted remove the fat32 partition (select the partition and delete it) and create a new with fat16 filesystem with 4gb (New->Partition) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 4: 1.With gparted remove the fat32 partition (select the partition and delete it) and create a new with ext4 filesystem with max size (New->Partition) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 5: 1.With gparted remove the fat32 partition (select the partition and delete it) and create a new with ntfs filesystem with max size (New->Partition) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 6: 1.With gparted format the current partition to one of type fat 16 (select the partition and choose format to... -> fat16) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 7: 1.With gparted format the current partition to one of type ntfs (select the partition and choose format to... -> ntfs) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 8: 1.With gparted remove the fat32 partition (select the partition and delete it) and create a new with fat32 filesystem with max size (New->Partition). After created format the partition to one of type ext4 (select the partition and choose format to... -> fat32) 2. Run my code 3. Insert the sd card into the pc verify that the filesystem is a fat32 and that all the desired files were created.

Test 9: 1.With gparted format the current partition to one of type ext4 (select the partition and choose format to... -> ext4) 2. Run my code 3. When I insert the file system is not recognized if I run the command: $mount /dev/{device} I verified the existence of more than one file system. I need to run the command mount -t vfat /dev/{device} to ru the fat32 filesystem and see the files created by my code. -To recover the sdcard I need to delete the two file systems created with the command: sudo dd bs=512 count=100 if=/dev/zero of=/dev/{device}

Steps to format and create the fat32 filesystem:

/* Partition table must be initialized by the user */
PARTITION VolToPart[] = {0}; /* "0:" ==> Physical drive 0, 1st partition */

/* Use a total size of a single partition */
DWORD plist[] = {100};

/* Maximum working area 512 bytes */
BYTE work[_MAX_SS];

/* Creating a partition */
f_fdisk(0, plist, &work);

/* Creating FAT32 file system */
create_fs_result = f_mkfs(DEFAULT_DRIVE, FM_FAT32, DEFAULT_ALLOCATION_UNIT_SIZE, work, sizeof(work));
Parents
  • Hi,

    This sounds like a very specific and less common use-case. It could sound like a bug/issue in FatFs, more than a MCU specific issue. Have you tried looking in the documentation of FatFs, to see if it mentions anything about such cases?

    I also see that there is a user forum on the FatFs site, maybe someone there can shed some light on what might be causing this behaviour?

    Also, which device did you try this on (nRF51/nRF52832/nRF52840)? I could try to replicate your issue with one of my devices, if I can get hold of a microSD connector.

    Best regards,

    Jørgen

Reply
  • Hi,

    This sounds like a very specific and less common use-case. It could sound like a bug/issue in FatFs, more than a MCU specific issue. Have you tried looking in the documentation of FatFs, to see if it mentions anything about such cases?

    I also see that there is a user forum on the FatFs site, maybe someone there can shed some light on what might be causing this behaviour?

    Also, which device did you try this on (nRF51/nRF52832/nRF52840)? I could try to replicate your issue with one of my devices, if I can get hold of a microSD connector.

    Best regards,

    Jørgen

Children
Related