mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/wl_fatfs_format' into 'master'
fix(storage/fatfs): fix double mouting of spiflash Closes IDF-9677 See merge request espressif/esp-idf!30162
This commit is contained in:
commit
a75bacf781
@ -13,7 +13,7 @@ components/fatfs/test_apps/flash_ro:
|
||||
|
||||
components/fatfs/test_apps/flash_wl:
|
||||
disable_test:
|
||||
- if: IDF_TARGET not in ["esp32", "esp32c3"]
|
||||
- if: IDF_TARGET not in ["esp32", "esp32c3", "linux"]
|
||||
reason: only one target per arch needed
|
||||
depends_components:
|
||||
- esp_partition
|
||||
|
10
components/fatfs/test_apps/flash_wl/main/Kconfig.projbuild
Normal file
10
components/fatfs/test_apps/flash_wl/main/Kconfig.projbuild
Normal file
@ -0,0 +1,10 @@
|
||||
menu "Test configuration"
|
||||
config SPI_WL_TEST_ERASE_PARTITION
|
||||
bool "Erase partition"
|
||||
default y if IDF_TARGET_LINUX
|
||||
help
|
||||
Erase the partition before each format operation.
|
||||
This will destroy the flash fairly quickly in CI, but is necessary to
|
||||
ensure that the test is not affected by previous test runs.
|
||||
Run with caution.
|
||||
endmenu
|
@ -46,8 +46,20 @@ static void test_teardown(void)
|
||||
TEST_ESP_OK(esp_vfs_fat_spiflash_unmount_rw_wl("/spiflash", s_test_wl_handle));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_WL_TEST_ERASE_PARTITION
|
||||
static void corrupt_wl_data(void)
|
||||
{
|
||||
const esp_partition_t* part = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, NULL);
|
||||
TEST_ASSERT_NOT_NULL(part);
|
||||
TEST_ESP_OK(esp_partition_erase_range(part, 0, part->size));
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE("(WL) can format partition", "[fatfs][wear_levelling][timeout=120]")
|
||||
{
|
||||
#ifdef CONFIG_SPI_WL_TEST_ERASE_PARTITION
|
||||
corrupt_wl_data();
|
||||
#endif
|
||||
TEST_ESP_OK(esp_vfs_fat_spiflash_format_rw_wl("/spiflash", NULL));
|
||||
test_setup();
|
||||
vfs_fat_spiflash_ctx_t* ctx = get_vfs_fat_spiflash_ctx(s_test_wl_handle);
|
||||
@ -58,6 +70,9 @@ TEST_CASE("(WL) can format partition", "[fatfs][wear_levelling][timeout=120]")
|
||||
|
||||
TEST_CASE("(WL) can format partition with config", "[fatfs][wear_levelling][timeout=120]")
|
||||
{
|
||||
#ifdef CONFIG_SPI_WL_TEST_ERASE_PARTITION
|
||||
corrupt_wl_data();
|
||||
#endif
|
||||
esp_vfs_fat_mount_config_t format_config = {
|
||||
.format_if_mount_failed = true,
|
||||
.max_files = 5,
|
||||
|
@ -242,7 +242,8 @@ esp_err_t esp_vfs_fat_spiflash_format_cfg_rw_wl(const char* base_path, const cha
|
||||
assert(found);
|
||||
if (s_ctx[id]->flags & FORMATTED_DURING_LAST_MOUNT) {
|
||||
ESP_LOGD(TAG, "partition was formatted during mounting, skipping another format");
|
||||
return ESP_OK;
|
||||
ret = ESP_OK;
|
||||
goto mount_back;
|
||||
}
|
||||
} else {
|
||||
partition_was_mounted = true;
|
||||
|
Loading…
Reference in New Issue
Block a user