Cannot find File after mounting FatFs with VFS in read-only mode.

andreasp
Posts: 2
Joined: Thu Apr 13, 2023 7:19 am

Cannot find File after mounting FatFs with VFS in read-only mode.

Postby andreasp » Thu Jun 01, 2023 4:47 pm

Hello, I have a file that I can create and open no problem with a build that uses the

Code: Select all

esp_vfs_fat_spiflash_mount(PERM_STORE_MOUNT_POINT, STORAGE_LABEL,
                                                &mount_config);

function , but if I switch to read only mode using the

Code: Select all

esp_vfs_fat_rawflash_mount(PERM_STORE_MOUNT_POINT, STORAGE_LABEL,
						&mount_config);

function I get the following error: errno(2) = No such file or directory.

This is my config for the spiflash function:

Code: Select all

const esp_vfs_fat_mount_config_t mount_config = {
            .max_files = 3,
            .format_if_mount_failed = true,
            .allocation_unit_size = CONFIG_WL_SECTOR_SIZE
};
This is my config for the rawflash function:

Code: Select all

const esp_vfs_fat_mount_config_t mount_config = {
            .max_files = 3,
            .format_if_mount_failed = false,
};
It mounts just fine but for some reason fopen() cannot find the file anymore. I know for sure that the flashing process or application code is not deleting the file. If I re-flash the spiflash build without the code for creating the file I can still access it. What am I doing wrong?
Last edited by andreasp on Mon Jun 05, 2023 5:52 am, edited 1 time in total.

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: Cannot find File after mounting FatFs with VFS in read-only mode.

Postby ESP_Sprite » Fri Jun 02, 2023 9:01 am

I think the issue is that esp_vfs_fat_spiflash_mount uses a wear leveling layer (needed for writing to flash), while esp_vfs_fat_rawflash_mount uses the raw FAT filesystem without wear leveling (which it can do because it's read-only). In other words: you can't mount a filesystem created for one function using the other function.

Who is online

Users browsing this forum: No registered users and 144 guests