|
|
7 年之前 | |
|---|---|---|
| .. | ||
| main | 7 年之前 | |
| CMakeLists.txt | 7 年之前 | |
| Makefile | 9 年之前 | |
| README.md | 7 年之前 | |
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This example demonstrates how to read and write a single integer value and a blob (binary large object) using NVS to preserve them between ESP32 module restarts.
Example also shows how to implement diagnostics if read / write operation was successful.
Detailed functional description of NVS and API is provided in documentation.
If not done already, consider checking simpler example storage/nvs_rw_value, that has been used as a starting point for preparing this one.
This example can be run on most common development boards which have an active button connected to GPIO0. On most boards, this button is labeled as "Boot". When pressed, the button connects GPIO0 to ground.
If using Make based build system, run make menuconfig and set serial port under Serial Flasher Options.
If using CMake based build system, no configuration is required.
Build the project and flash it to the board, then run monitor tool to view serial output:
make -j4 flash monitor
Or, for CMake based build system (replace PORT with serial port name):
idf.py -p PORT flash monitor
(To exit the serial monitor, type Ctrl-].)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
First run:
Restart counter = 0
Run time:
Nothing saved yet!
At this point, press "Boot" button and hold it for a second. The board will perform software restart, printing:
Restarting...
After booting again, restart counter and run time array will be printed:
Restart counter = 1
Run time:
1: 5110
After pressing "Boot" once more:
Restart counter = 2
Run time:
1: 5110
2: 5860
To reset the counter and run time array, erase the contents of flash memory using make erase_flash (or idf.py erase_flash, if using CMake build system), then upload the program again as described above.