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