docs(storage): clarify example READMEs and when to use each

Update storage example docs so FATFS getting_started and wear_levelling
are clearly distinct, refresh the storage index paths, and add
"When to use this example" sections across storage examples.
This commit is contained in:
sonika.rathi
2026-08-25 12:51:01 +02:00
parent ae2088092e
commit 8eade5a911
28 changed files with 221 additions and 51 deletions
+5
View File
@@ -26,6 +26,11 @@ The key advantage of BDL is that **the same `diskio_bdl` adapter works with any
You can swap the bottom of the stack (e.g., use `sdmmc_get_blockdev()` for an SD card) without
changing the FatFS integration code.
## When to use this example
- You want the newer Block Device Layer (BDL) approach to mounting FATFS instead of the legacy `wl_handle_t` API.
- You plan to reuse the same FATFS integration across different backends (flash partition, SD card, etc.).
## How to use example
### Build and flash
@@ -17,6 +17,11 @@ The flow of the example is as follows:
4. Do some read and write operations using C standard library functions: create a file, write to it, open it for reading, print the contents to the console.
## When to use this example
- You need to add FATFS storage on an *external* SPI flash chip (e.g. to extend a module with only 4 MB of internal flash).
- You want to see how to register an external flash chip as a partition (`esp_flash_t` / `esp_partition_t`).
## How to use example
### Hardware required
@@ -67,3 +67,8 @@ I (342) example: Done
The logic of the example is contained in a [single source file](./main/fatfsgen_example_main.c),
and it should be relatively simple to match points in its execution with the log outputs above.
## When to use this example
- You want to ship pre-created files on a FATFS partition, generated at build time from a host folder.
- You need a read-only or read-write FATFS image flashed together with the app.
@@ -8,6 +8,11 @@
This example demonstrates some of the POSIX functions available for working with the FATFS filesystem.
Including basic read and write operations, as well as creating moving, and deleting files and directories.
## When to use this example
- You already know how to mount FATFS and want to see richer file/directory operations (`fstat`, append, list, `mkdir`, rename/move, delete).
- You need a reference for POSIX calls against a FATFS volume.
## Overview
1. Partition labeled `storage` is mounted (and formatted if necessary) as FATFS filesystem to `/spiflash` mountpoint.
@@ -1,32 +1,49 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-H21 | ESP32-H4 | ESP32-P4 | ESP32-S2 | ESP32-S3 | ESP32-S31 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | --------- | -------- | -------- | -------- | -------- | --------- |
# FATFS minimal example
# FATFS getting started (minimal) example
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example demonstrates the minimal setup required to store persistent data on SPI Flash using the FAT filesystem.
Beware that the minimal required size of the flash is 4 MB.
## Purpose
Minimal FAT filesystem example for beginners: mount a FAT volume on internal SPI flash, write one file, read it back, then unmount.
Wear levelling is enabled by the mount API used here (`esp_vfs_fat_spiflash_mount_rw_wl`), which is required for safe read-write FAT on SPI flash.
## When to use this example
- You want the shortest path to store files with FATFS on internal SPI flash.
- You are learning the basic mount / write / read / unmount flow.
## What this example demonstrates
- Mount FAT on the `storage` partition with `esp_vfs_fat_spiflash_mount_rw_wl`
- Create and write a file with `fopen` / `fprintf`
- Read the file back with `fopen` / `fgets`
- Unmount with `esp_vfs_fat_spiflash_unmount_rw_wl`
Source: [main/fatfs_getting_started_main.c](./main/fatfs_getting_started_main.c)
## Requirements
- Internal SPI flash large enough for the example partition table (typically at least 4 MB modules)
- Partition label: `storage` (see [partitions_example.csv](./partitions_example.csv))
## How to use example
### Build and flash
To run the example, type the following command:
```CMake
# CMake
```
idf.py -p PORT flash monitor
```
(To exit the serial monitor, type ``Ctrl-]``.)
(Replace `PORT` with the serial port name. Exit the serial monitor with ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Example output
Here is the example's console output:
```
...
I (321) example: Mounting FAT filesystem
@@ -39,6 +56,3 @@ I (741) example: Unmounting FAT filesystem
I (851) example: Done
...
```
The logic of the example is contained in a [single source file](./main/fatfs_getting_started_main.c),
and it should be relatively simple to match points in its execution with the log outputs above.