0

由于加密,我想在我的 Esp32 项目上从 SPIFFS 切换到 FAT。在我的示例项目中,我有这个。

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;
}

它工作正常并按预期创建两个文件,但是:

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;
}

json文件失败。

I (3672) example: Opening file 1
E (3672) example: Failed to open file 1 for writing test
I (3682) example: Opening file 2
...

到目前为止,谷歌没有给我任何关于 FatFS 文件扩展名问题的信息。有人可以帮我理解这一点吗?

4

0 回答 0