Esp32 fat filesystem questions

agatrost1620
Posts: 8
Joined: Thu Mar 05, 2020 1:24 pm

Esp32 fat filesystem questions

Postby agatrost1620 » Wed Apr 29, 2020 8:43 pm

I am trying to use the fat file system with wear leveling and posix file access. Very little documentation on the api's other than what I have found in the idf examples to use. Also I am looking for instructions on creating my own fatfs for my project.

These are the function calls in this order that I am using in code:

esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, "/fatfs");
wl_mount(const esp_partition_t *partition, wl_handle_t *out_handle);
ff_diskio_register_wl_partition(BYTE pdrv, wl_handle_t flash_handle);
diskDrive[0] = (char)('0' + pdrv);
diskDrive[1] = ':';
diskDrive[2] = 0;
esp_vfs_fat_register(const char* base_path, const char* fat_drive, size_t max_files, FATFS** out_fs)

then when I call :
f_mount (FATFS* fs, diskDrive, 1);
f_mount returns an error 13
/* (13) There is no valid FAT volume */

here is my partitions.csv:
# Name Type SubType Offset Size
phy_init data phy 0xf000 0x1000
otadata data ota 0x10000 8K
nvs data nvs 0x12000 56K
at_customize 0x40 0 0x20000 0x12000
fatfs data fat 0x32000 0xCE000
ota_0 app ota_0 0x100000 0x180000
ota_1 app ota_1 0x280000 0x180000
#Note: at_customize has had portions removed including fatfs

I also tried to create my own fatfs.img using:
dd if=/dev/zero of=fatfs.img bs=1K count=824
mkfs.vfat fatfs.img
i mounted the image and copied in a file for testing
I used esptool to flash the esp32
esptool --port /dev/ttyUSB0 write_flash --flash_freq 80m -fm dio 0x32000 fatfs.img
and once again the f-mount returned 13.

The questions would be why is it not finding my partition?
and how do I create a filesytem to flash into my project?

Any help or documentation would be appreciated,
thank you in advance,
Andrew

cnlohr
Posts: 65
Joined: Sat Dec 03, 2016 5:39 am

Re: Esp32 fat filesystem questions

Postby cnlohr » Sun Apr 04, 2021 5:59 am

For those examining this in 2021, I found that I needed to make a custom partition table, something like this.

Code: Select all

# ESP-IDF Partition Table
# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x6000,
phy_init, data, phy,     0xf000,  0x1000,
factory,  app,  factory, 0x10000, 1M,
# 0x81 = ESP_PARTITION_SUBTYPE_DATA_FAT
fatfs,    data, 0x81,    0x110000, 0xf0000,
And configure my sdkconfig to look at that partitions.csv file.

Who is online

Users browsing this forum: jainil and 236 guests