SPIFFS or LittleFS fail at open file

vilanova
Posts: 1
Joined: Wed Jul 28, 2021 8:12 am

SPIFFS or LittleFS fail at open file

Postby vilanova » Wed Jul 28, 2021 8:28 am

Hi,
I want to store some files inside the esp32 in order to play some sounds, I'm using platformio with esp-idf.
I tried with both filesystems, spiffs and littlefs and I receive an error when trying to open for example a .txt built into the image.

my partition table is the following:

Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, , 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 1M,
storage, data, spiffs, , 1M,

and inside my cmakelists.txt i have this:

spiffs_create_partition_image(storage ./data FLASH_IN_PROJECT)


I have no errors on building the filesystem and uploading it:
Captura.PNG
Captura.PNG (12.53 KiB) Viewed 2600 times
Captura2.PNG
Captura2.PNG (15.13 KiB) Viewed 2600 times
yet after uploading the code, which mounts the image with the esp_vfs_spiffs_register function and asking esp_spiffs_info i get 0 used space which seems odd.
And calling fopen of "/test.txt" or "/data/test.txt" or other combinations gives always null.

So I don't know how to proceed. I find lots of information about spiffs but the majority are based on Arduino. So a little help would be great.
Thanks

StridingDragon
Posts: 46
Joined: Fri Aug 02, 2019 11:59 pm

Re: SPIFFS or LittleFS fail at open file

Postby StridingDragon » Wed Jul 28, 2021 7:04 pm

Did you make sure to set the base path for LittleFS correctly when initializing it and calling esp_vfs_littlefs_register() to mount the partition?

Code: Select all

static esp_vfs_littlefs_conf_t conf =
{
    .base_path = "/data",
    .partition_label = "data",
    .format_if_mount_failed = true,
    .dont_mount = false,
};
After mounting the VFS, you can also call esp_littlefs_info(); to see what info you get back and if the VFS has been mounted correctly.

Who is online

Users browsing this forum: awegel, Google [Bot] and 129 guests