Page 1 of 1

Cannot mount more than two FATFS partitions

Posted: Wed Dec 05, 2018 7:28 pm
by brp80000
My partitios
nvs, data, nvs, 0x9000, 0x4000
otadata, data, ota, 0xd000, 0x2000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 0x1F0000
ota_0, app, ota_0, 0x200000, 4M
ota_1, app, ota_1, 0x600000, 4M
fat_1, data, fat, 0xA00000, 2M
fat_2, data, fat, 0xC00000, 2M
fat_3, data, fat, 0xE00000, 2M

sdconfig config
# SPIFFS Configuration
#
CONFIG_SPIFFS_MAX_PARTITIONS=3

1. when I initialize only two fatfs partitions (any two of fat_1 fat_2 fat_3), everything is OK. Under adding a third mean problems
2. when I use three I get an error: the maximum count of volumes is already mounted ESP_ERR_NO_MEM
3. In the file ffconf.h I found:
/*---------------------------------------------------------------------------/
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/

#define FF_VOLUMES 2
/* Number of volumes (logical drives) to be used. (1-10) */

When I change the value to 3 i have
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.

My program crash inside
ESP_ERROR_CHECK(esp_vfs_fat_spiflash_mount("/spiflash3", "fat_3", &mountConfig3, &m_wl_handle3));
without any messages from ESP_ERROR_CHECK

Re: Cannot mount more than two FATFS partitions

Posted: Thu Dec 06, 2018 10:26 am
by brp80000
It was a big problem. I found constants that I have never seen described. FF_VOLUMES 2 default, FF_MULTI_PARTITION 1 default, although it says 0 by default. These constants are not accessible from the "make menuconfig" and they need to change the inside of the original IDF files. I lost my working day
Безымянный.jpg
Безымянный.jpg (207.5 KiB) Viewed 4829 times
It seems to me that if I update the IDF again I have to remember that they need to be changed

Re: Cannot mount more than two FATFS partitions

Posted: Fri Dec 07, 2018 2:04 am
by ESP_Sprite
If you want, you can open an issue on Github about this, as a feature request to put these things into Menuconfig.

Re: Cannot mount more than two FATFS partitions

Posted: Fri Dec 07, 2018 3:37 am
by ESP_igrr
Also the reason why you had to set FF_MULTI_PARTITION to 0 is that "VolToPart" array initializer in diskio.c needs to be updated if you need to mount more than two partitions. I.e.:

PARTITION VolToPart[] = {
{0, 0}, /* Logical drive 0 ==> Physical drive 0, auto detection */
{1, 0} /* Logical drive 1 ==> Physical drive 1, auto detection */
{2, 0} /* Logical drive 2 ==> Physical drive 2, auto detection */
};

So switching FF_MULTI_PARTITION off might not be necessary, only FF_VOLUMES configuration needs to be added.