32 lines
1.3 KiB
Markdown
32 lines
1.3 KiB
Markdown
|
|
# Exercise 17_Flash
|
||
|
|
|
||
|
|
This exercise demonstrates using Flash storage as a persistent directory-like file system on an ESP32-S3 board.
|
||
|
|
|
||
|
|
Behavior:
|
||
|
|
- Mounts SPIFFS at boot and reports total / used / free flash space.
|
||
|
|
- Ensures a flash directory at `/flash_logs` exists.
|
||
|
|
- Creates a new log file when the device boots, based on the current timestamp: `YYYYMMDD_HHMM.log`.
|
||
|
|
- Writes a timestamped line into the new log file once per second.
|
||
|
|
- Supports console commands to inspect the current file, read it, clear it, append or rewrite it, and list stored files.
|
||
|
|
- Files persist across reboots and are stored in flash.
|
||
|
|
|
||
|
|
Build and upload:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cd /usr/local/src/microreticulum/microReticulumTbeam/exercises/17_Flash
|
||
|
|
pio run -e amy -t upload
|
||
|
|
pio device monitor -b 115200
|
||
|
|
```
|
||
|
|
|
||
|
|
Commands:
|
||
|
|
- `help` - show command menu
|
||
|
|
- `stat` - show flash / current file status
|
||
|
|
- `list` - list files under `/flash_logs`
|
||
|
|
- `read` - read the current flash file contents
|
||
|
|
- `clear` - clear the current flash file contents
|
||
|
|
- `write <text>` - overwrite the current flash file with text
|
||
|
|
- `append <text>` - append text to the current flash file
|
||
|
|
|
||
|
|
Notes:
|
||
|
|
- If the current timestamp file name already exists, the exercise will append a numeric suffix to keep the file unique.
|
||
|
|
- On each reboot a new file is created so persistent flash logs accumulate.
|