FATFS multi partition support

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

FATFS multi partition support

Post by ucasano »

Hello all, I am starting this topic because I am experiencing a lot of troubles using a multi partioned FATFS filesystem on a 4GB eMMC device connected to an STM32F4 cpu.

Stated that everything works really fine with a single partition, I report below the way I am trying to use the multi partioned memory.

First, eMMC is not a removable device, so I had to partition (f_fdisk) and make filesystem (f_mkfs) from internal code. As stated above, single partition works really fine.

This is my ffconf.h file for multipartition setup (changed definition only):

Code: Select all

#define _FS_READONLY   0   /* 0:Read/Write or 1:Read only */
#define _FS_MINIMIZE   0   /* 0 to 3 */
#define   _USE_MKFS      1   /* 0:Disable or 1:Enable */
#define   _USE_LFN   2      /* 0 to 3 */
#define   _MAX_LFN   32      /* Maximum LFN length to handle (12 to 255) */
#define _VOLUMES   2
#define   _MULTI_PARTITION   2


then the initialization code, trying to split the eMMC in two 2GB partitions:

Code: Select all

FATFS MMC_FS[2];
PARTITION VolToPart[] = {
   {0, 1},      /* Logical drive 0 ==> Physical drive 0, 1st partition */
   {0, 2},      /* Logical drive 1 ==> Physical drive 0, 2nd partition */
   {0, 3},      /* Logical drive 2 ==> Physical drive 0, 3nd partition */
   {0, 4}      /* Logical drive 3 ==> Physical drive 0, 4nd partition */
};
uint8_t work[_MAX_SS];
DWORD plist[] = { 50, 50, 0, 0 };

DIR dir;
FRESULT err = 0;

FRESULT tres;
void
emmcInit(void)
{
   tres = f_fdisk(0, plist, work);  /* Divide physical drive 0 */

   tres = f_mount(0, &MMC_FS[0]);
   tres = f_mkfs(0, 0, 0);          /* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */
   tres = f_mount(0, 0);

   tres = f_mount(1, &MMC_FS[1]);
   tres = f_mkfs(1, 0, 0); /* Create an FAT volume on the logical drive 1. 2nd argument is ignored. */
   tres = f_mount(1, 0);
}

sdcStart(&SDCD1, &sdc_cfg);

if (!status.fs_ready) {
   f_mount(0, &MMC_FS[0]);
   f_mount(1, &MMC_FS[1]);
   err = f_opendir(&dir, "0:");
   if ((err == FR_NOT_READY) || (err == FR_NO_FILESYSTEM)) {
      f_mount(0, 0);
      f_mount(1, 0);
      emmcInit();
   } else if (err == FR_OK) {
      status.fs_ready = true;
   } else {
      sdcDisconnect(&SDCD1);
   }
}


The above initialization return only one 2GB working partition, the MMC_FS[0]; the f_mkfs fails (DISK_ERR) when executed for partition number 1.

I tried to find informations and code examples on google and chibios forums, but I just found the example reported on elm fatfs website and nothing more.

Did somebody ty to use the multi partition feature of FATFS with successfull results?
What is wrong with above code?

Thank you in advance for your time.
Bye.
-g
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: FATFS multi partition support

Post by ucasano »

any ideas??
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: FATFS multi partition support

Post by Giovanni »

Not from me, probably you should ask on the FatFS forum.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: FATFS multi partition support

Post by Tectu »

I'm not sure if this helps but I did some testing with multiple partitions support using FatFS 0.10b a couple of months ago and I had no problems. There's sadly no code that I can point you at at the moment as I am integrating this into the GFILE module of the uGFX library and I am not finished yet.


~ Tectu
ucasano
Posts: 57
Joined: Mon Aug 06, 2012 1:05 pm
Has thanked: 1 time

Re: FATFS multi partition support

Post by ucasano »

Hello,

are you telling me there are some known issues concerning fatfs 0.9b partitioning code?

Could you please share the part of your code related to fatfs partitioning?

Thank you for your answer.
-g
Post Reply