Moved the flash init logic

This commit is contained in:
Philip Gladstone 2022-03-06 14:21:05 +00:00
parent 891cf01b87
commit 3e5ba2843c
2 changed files with 7 additions and 14 deletions

View File

@ -160,7 +160,13 @@ void __attribute__((noreturn)) app_main(void)
nodemcu_init ();
nvs_flash_init ();
// This is the standard flash init sequence
int rc = nvs_flash_init();
if (rc == ESP_ERR_NVS_NO_FREE_PAGES || rc == ESP_ERR_NVS_NEW_VERSION_FOUND) {
nvs_flash_erase();
nvs_flash_init();
}
esp_netif_init ();
start_lua ();

View File

@ -19,7 +19,6 @@
#include "sdkconfig.h"
#ifdef CONFIG_NODEMCU_CMODULE_BLE
#include "nvs_flash.h"
#include <assert.h>
#include <errno.h>
@ -615,18 +614,6 @@ lble_print_conn_desc(struct ble_gap_conn_desc *desc)
static int
lble_sys_init(lua_State *L) {
int rc = nvs_flash_init();
if (rc == ESP_ERR_NVS_NO_FREE_PAGES || rc == ESP_ERR_NVS_NEW_VERSION_FOUND) {
rc = nvs_flash_erase();
if (rc) {
return luaL_error(L, "Failed to erase flash: %d", rc);
}
rc = nvs_flash_init();
}
if (rc) {
return luaL_error(L, "Failed to init flash: %d", rc);
}
task_handle = task_get_id(lble_task_cb);
response_queue = xQueueCreate(2, sizeof(response_message_t));