File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
examples/system/console/main Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1818#include "argtable3/argtable3.h"
1919#include "cmd_decl.h"
2020#include "esp_vfs_fat.h"
21+ #include "nvs.h"
22+ #include "nvs_flash.h"
2123
2224static const char * TAG = "example" ;
2325
@@ -45,6 +47,16 @@ static void initialize_filesystem()
4547}
4648#endif // CONFIG_STORE_HISTORY
4749
50+ static void initialize_nvs ()
51+ {
52+ esp_err_t err = nvs_flash_init ();
53+ if (err == ESP_ERR_NVS_NO_FREE_PAGES ) {
54+ ESP_ERROR_CHECK ( nvs_flash_erase () );
55+ err = nvs_flash_init ();
56+ }
57+ ESP_ERROR_CHECK (err );
58+ }
59+
4860static void initialize_console ()
4961{
5062 /* Disable buffering on stdin and stdout */
@@ -94,6 +106,8 @@ static void initialize_console()
94106
95107void app_main ()
96108{
109+ initialize_nvs ();
110+
97111#if CONFIG_STORE_HISTORY
98112 initialize_filesystem ();
99113#endif
You can’t perform that action at this time.
0 commit comments