I want to switch from SPIFFS to FAT on my Esp32 projects due to encryption. In my example project I have this.
esp_vfs_spiffs_conf_t conf = {
.base_path = "/spiffs",
.partition_label = NULL,
.max_files = 5, // This decides the maximum number of files that can be created on the storage
.format_if_mount_failed = true
};
esp_err_t ret = esp_vfs_spiffs_register(&conf);
...
ESP_LOGI(TAG, "Opening file 1");
FILE *f = fopen("/spiffs/hello.json", "w");
if (f == NULL) {
ESP_LOGE(TAG, "Failed to open file 1 for writing test");
}
ESP_LOGI(TAG, "Opening file 2");
FILE *f2 = fopen("/spiffs/hello.txt", "w");
if (f2 == NULL) {
ESP_LOGE(TAG, "Failed to open file 2 for writing test");
return ESP_FAIL;
}
It works fine and creates both files as expected, but this:
esp_vfs_fat_mount_config_t conf = {
.format_if_mount_failed = true,
.max_files = 5,
.allocation_unit_size = CONFIG_WL_SECTOR_SIZE
};
esp_err_t ret = esp_vfs_fat_spiflash_mount("/fatfs", "storage", &conf, &s_wl_handle);
ESP_LOGI(TAG, "Opening file 1");
FILE *f = fopen("/fatfs/hello.json", "w");
if (f == NULL) {
ESP_LOGE(TAG, "Failed to open file 1 for writing test");
}
ESP_LOGI(TAG, "Opening file 2");
FILE *f2 = fopen("/fatfs/hello.txt", "w");
if (f2 == NULL) {
ESP_LOGE(TAG, "Failed to open file 2 for writing test");
return ESP_FAIL;
}
fails for the json file.
I (3672) example: Opening file 1
E (3672) example: Failed to open file 1 for writing test
I (3682) example: Opening file 2
...
Google so far gave me nothing on FatFS having any issue with file extensions. Can someone help me understand this?