Code: Select all
# 16 KiB
nvs, data, nvs, 0x9000, 0x4000,
# 8 KiB
otadata, data, ota, 0xd000, 0x2000,
# 4 KiB
phy_init, data, phy, 0xf000, 0x1000,
# 1 MiB + 128 KiB
ota_0, app, ota_0, 0x10000, 0x120000,
# 1 MiB + 128 KiB
ota_1, app, ota_1, 0x130000, 0x120000,
# 1 MiB + 704 KiB
storage_1, data, fat, 0x250000, 0x1B0000,
Code: Select all
#include <stdio.h>
#include <sys/stat.h>
#include <dirent.h>
#include "esp_vfs_fat.h"
wl_handle_t g_wl_handle = WL_INVALID_HANDLE;
void app_main(void)
{
// Mount partition
esp_vfs_fat_mount_config_t wear_levelling_mount_config;
wear_levelling_mount_config.allocation_unit_size = CONFIG_WL_SECTOR_SIZE; // sector size is 4096
wear_levelling_mount_config.max_files = 10;
wear_levelling_mount_config.format_if_mount_failed = true;
esp_err_t ret = esp_vfs_fat_spiflash_mount("/spiflash", "storage_1", &wear_levelling_mount_config, &g_wl_handle);
// Read files from partition
DIR* fd;
struct dirent* dir = NULL;
fd = opendir("/spiflash");
if (NULL != fd)
{
printf("dirent: /spiflash opendir successful.\n");
do
{
dir = readdir(fd);
if (NULL != dir)
{
printf("file: %s\n", strlwr(dir->d_name));
}
} while (NULL != dir);
}
}
Code: Select all
dirent: /spiflash opendir successful.
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
file: ��������.���
... // a lot more files