|
1 | 1 | /* |
2 | | - QSPI Filesystem Example |
| 2 | + QSPI Filesystem Example with LittleFS |
3 | 3 |
|
4 | | - This example demonstrates how to use the QSPI library with LittleFS |
| 4 | + This example demonstrates how to use the QSPI library with Zephyr's LittleFS |
5 | 5 | filesystem to store and retrieve files on external QSPI flash memory. |
6 | 6 |
|
7 | 7 | Features: |
|
10 | 10 | - List directory contents |
11 | 11 | - Check filesystem statistics |
12 | 12 |
|
| 13 | + IMPORTANT CONFIGURATION REQUIRED: |
| 14 | + =================================== |
| 15 | + This example requires LittleFS support to be enabled in your Zephyr build. |
| 16 | +
|
| 17 | + 1. Add to your board's prj.conf file: |
| 18 | + CONFIG_FILE_SYSTEM=y |
| 19 | + CONFIG_FILE_SYSTEM_LITTLEFS=y |
| 20 | + CONFIG_FILE_SYSTEM_MAX_FILE_NAME=128 |
| 21 | +
|
| 22 | + 2. If using a custom board, ensure your device tree has flash partitions defined. |
| 23 | +
|
| 24 | + 3. Alternative: If you don't want to configure LittleFS, use the QSPISimpleFS.ino |
| 25 | + example instead, which implements a simple filesystem without dependencies. |
| 26 | +
|
13 | 27 | Note: |
14 | 28 | - QSPI flash must be configured in the board's device tree overlay |
15 | | - - Zephyr CONFIG_FILE_SYSTEM=y and CONFIG_FILE_SYSTEM_LITTLEFS=y must be enabled |
16 | | - - Add to prj.conf: |
17 | | - CONFIG_FILE_SYSTEM=y |
18 | | - CONFIG_FILE_SYSTEM_LITTLEFS=y |
19 | | - CONFIG_FILE_SYSTEM_MAX_FILE_NAME=128 |
| 29 | + - Build will fail if LittleFS is not enabled (missing lfs.h header) |
20 | 30 | */ |
21 | 31 |
|
| 32 | +// Check if filesystem support is available |
| 33 | +#ifndef CONFIG_FILE_SYSTEM |
| 34 | +#error "This example requires CONFIG_FILE_SYSTEM=y in prj.conf" |
| 35 | +#endif |
| 36 | + |
| 37 | +#ifndef CONFIG_FILE_SYSTEM_LITTLEFS |
| 38 | +#error "This example requires CONFIG_FILE_SYSTEM_LITTLEFS=y in prj.conf. Use QSPISimpleFS.ino if you don't want to enable LittleFS." |
| 39 | +#endif |
| 40 | + |
22 | 41 | #include <QSPI.h> |
23 | 42 | #include <zephyr/fs/fs.h> |
24 | 43 | #include <zephyr/fs/littlefs.h> |
|
0 commit comments