diff --git a/components/base_nodemcu/user_main.c b/components/base_nodemcu/user_main.c index adb8832f..0735c2a4 100644 --- a/components/base_nodemcu/user_main.c +++ b/components/base_nodemcu/user_main.c @@ -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 (); diff --git a/components/modules/ble.c b/components/modules/ble.c index e8551dd8..3d465abe 100644 --- a/components/modules/ble.c +++ b/components/modules/ble.c @@ -19,7 +19,6 @@ #include "sdkconfig.h" #ifdef CONFIG_NODEMCU_CMODULE_BLE -#include "nvs_flash.h" #include #include @@ -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));