console example: initialize nvs on startup
Fixes https://github.com/espressif/esp-idf/issues/1478
This commit is contained in:
parent
ff726b4c79
commit
24b07a3f45
1 changed files with 14 additions and 0 deletions
|
@ -18,6 +18,8 @@
|
||||||
#include "argtable3/argtable3.h"
|
#include "argtable3/argtable3.h"
|
||||||
#include "cmd_decl.h"
|
#include "cmd_decl.h"
|
||||||
#include "esp_vfs_fat.h"
|
#include "esp_vfs_fat.h"
|
||||||
|
#include "nvs.h"
|
||||||
|
#include "nvs_flash.h"
|
||||||
|
|
||||||
static const char* TAG = "example";
|
static const char* TAG = "example";
|
||||||
|
|
||||||
|
@ -45,6 +47,16 @@ static void initialize_filesystem()
|
||||||
}
|
}
|
||||||
#endif // CONFIG_STORE_HISTORY
|
#endif // CONFIG_STORE_HISTORY
|
||||||
|
|
||||||
|
static void initialize_nvs()
|
||||||
|
{
|
||||||
|
esp_err_t err = nvs_flash_init();
|
||||||
|
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
|
||||||
|
ESP_ERROR_CHECK( nvs_flash_erase() );
|
||||||
|
err = nvs_flash_init();
|
||||||
|
}
|
||||||
|
ESP_ERROR_CHECK(err);
|
||||||
|
}
|
||||||
|
|
||||||
static void initialize_console()
|
static void initialize_console()
|
||||||
{
|
{
|
||||||
/* Disable buffering on stdin and stdout */
|
/* Disable buffering on stdin and stdout */
|
||||||
|
@ -94,6 +106,8 @@ static void initialize_console()
|
||||||
|
|
||||||
void app_main()
|
void app_main()
|
||||||
{
|
{
|
||||||
|
initialize_nvs();
|
||||||
|
|
||||||
#if CONFIG_STORE_HISTORY
|
#if CONFIG_STORE_HISTORY
|
||||||
initialize_filesystem();
|
initialize_filesystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue