fatfs: added an API to format FAT on spiflash

This commit is contained in:
Armando
2023-01-04 14:59:11 +08:00
parent 1bd8018a59
commit 4150bfb403
5 changed files with 292 additions and 83 deletions

View File

@@ -33,7 +33,7 @@ static void test_setup(void)
{
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = true,
.max_files = 5
.max_files = 5,
};
TEST_ESP_OK(esp_vfs_fat_spiflash_mount_rw_wl("/spiflash", NULL, &mount_config, &s_test_wl_handle));
@@ -46,13 +46,20 @@ static void test_teardown(void)
TEST_CASE("(WL) can format partition", "[fatfs][wear_levelling]")
{
const esp_partition_t* part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
ESP_PARTITION_SUBTYPE_DATA_FAT, NULL);
esp_partition_erase_range(part, 0, part->size);
TEST_ESP_OK(esp_vfs_fat_spiflash_format_rw_wl("/spiflash", NULL));
test_setup();
test_teardown();
}
TEST_CASE("(WL) can format when the FAT is mounted already", "[fatfs][wear_levelling]")
{
test_setup();
TEST_ESP_OK(esp_vfs_fat_spiflash_format_rw_wl("/spiflash", NULL));
test_fatfs_create_file_with_text("/spiflash/hello.txt", fatfs_test_hello_str);
test_fatfs_pread_file("/spiflash/hello.txt");
test_teardown();
}
TEST_CASE("(WL) can create and write file", "[fatfs][wear_levelling]")
{
test_setup();