void FilesystemHandler::register_filesystem(const char *partition_name, const char * mountpt) { ESP_LOGI(TAG, "Mounting FAT filesystem"); esp_vfs_fat_mount_config_t mount_config; mount_config.format_if_mount_failed = false; mount_config.max_files = 20; esp_err_t err = esp_vfs_fat_spiflash_mount(mountpt, partition_name, &mount_config, &s_wl_handle); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to mount FATFS (0x%x)", err); return; } }
#include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "test_fatfs_common.h" #include "wear_levelling.h" #include "esp_partition.h" static wl_handle_t s_test_wl_handle; static void test_setup() { esp_vfs_fat_sdmmc_mount_config_t mount_config = { .format_if_mount_failed = true, .max_files = 5 }; TEST_ESP_OK(esp_vfs_fat_spiflash_mount("/spiflash", NULL, &mount_config, &s_test_wl_handle)); } static void test_teardown() { TEST_ESP_OK(esp_vfs_fat_spiflash_unmount("/spiflash", s_test_wl_handle)); } TEST_CASE("(WL) can format partition", "[fatfs][wear_levelling]") { const esp_partition_t* part = get_test_data_partition(); esp_partition_erase_range(part, 0, part->size); test_setup(); test_teardown(); }