From 5261fb194853f7f56c9578fa582f9984c3cd955e Mon Sep 17 00:00:00 2001 From: HuangRui Date: Thu, 21 May 2015 15:18:35 +0800 Subject: [PATCH] Update spiffs to latest. --- app/Makefile | 4 +- app/platform/flash_api.c | 91 +++++++++++++++++------------------- app/platform/flash_api.h | 8 ++-- app/spiffs/spiffs.c | 41 +++++++++------- app/spiffs/spiffs.h | 3 +- app/spiffs/spiffs_config.h | 6 +-- app/spiffs/spiffs_hydrogen.c | 1 + app/spiffs/spiffs_nucleus.c | 12 ++++- app/user/user_main.c | 23 ++++++++- 9 files changed, 112 insertions(+), 77 deletions(-) diff --git a/app/Makefile b/app/Makefile index 4d04d7f5..a1c0d66a 100644 --- a/app/Makefile +++ b/app/Makefile @@ -53,11 +53,11 @@ TARGET_LDFLAGS = \ --text-section-literals ifeq ($(FLAVOR),debug) - TARGET_LDFLAGS += -g -O2 + TARGET_LDFLAGS += -g -Os endif ifeq ($(FLAVOR),release) - TARGET_LDFLAGS += -g -O0 + TARGET_LDFLAGS += -Os endif LD_FILE = $(LDDIR)/eagle.app.v6.ld diff --git a/app/platform/flash_api.c b/app/platform/flash_api.c index 5f9772f6..7a918041 100644 --- a/app/platform/flash_api.c +++ b/app/platform/flash_api.c @@ -4,8 +4,8 @@ * 2014-12-31 *******************************************************************************/ #include "user_config.h" +#include "osapi.h" #include "flash_api.h" -#include "spi_flash.h" #include "c_stdio.h" static volatile const uint8_t flash_init_data[128] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = @@ -103,43 +103,40 @@ uint8_t flash_rom_get_size_type(void) uint32_t flash_rom_get_size_byte(void) { static uint32_t flash_size = 0; - if (flash_size == 0) + switch (flash_rom_getinfo().size) { - switch (flash_rom_getinfo().size) - { - case SIZE_2MBIT: - // 2Mbit, 256kByte - flash_size = 256 * 1024; - break; - case SIZE_4MBIT: - // 4Mbit, 512kByte - flash_size = 512 * 1024; - break; - case SIZE_8MBIT: - // 8Mbit, 1MByte - flash_size = 1 * 1024 * 1024; - break; - case SIZE_16MBIT: - // 16Mbit, 2MByte - flash_size = 2 * 1024 * 1024; - break; - case SIZE_32MBIT: - // 32Mbit, 4MByte - flash_size = 4 * 1024 * 1024; - break; - case SIZE_64MBIT: - // 64Mbit, 8MByte - flash_size = 8 * 1024 * 1024; - break; - case SIZE_128MBIT: - // 128Mbit, 16MByte - flash_size = 16 * 1024 * 1024; - break; - default: - // Unknown flash size, fall back mode. - flash_size = 512 * 1024; - break; - } + case SIZE_2MBIT: + // 2Mbit, 256kByte + flash_size = 256 * 1024; + break; + case SIZE_4MBIT: + // 4Mbit, 512kByte + flash_size = 512 * 1024; + break; + case SIZE_8MBIT: + // 8Mbit, 1MByte + flash_size = 1 * 1024 * 1024; + break; + case SIZE_16MBIT: + // 16Mbit, 2MByte + flash_size = 2 * 1024 * 1024; + break; + case SIZE_32MBIT: + // 32Mbit, 4MByte + flash_size = 4 * 1024 * 1024; + break; + case SIZE_64MBIT: + // 64Mbit, 8MByte + flash_size = 8 * 1024 * 1024; + break; + case SIZE_128MBIT: + // 128Mbit, 16MByte + flash_size = 16 * 1024 * 1024; + break; + default: + // Unknown flash size, fall back mode. + flash_size = 512 * 1024; + break; } return flash_size; } @@ -149,21 +146,21 @@ bool flash_rom_set_size_type(uint8_t size) // Dangerous, here are dinosaur infested!!!!! // Reboot required!!! // If you don't know what you're doing, your nodemcu may turn into stone ... - NODE_DBG("\nBEGIN SET FLASH HEADER\n"); + FLASH_DEBUG("\nBEGIN SET FLASH HEADER\n"); uint8_t data[SPI_FLASH_SEC_SIZE] ICACHE_STORE_ATTR; if (SPI_FLASH_RESULT_OK == spi_flash_read(0, (uint32 *)data, SPI_FLASH_SEC_SIZE)) { ((SPIFlashInfo *)(&data[0]))->size = size; if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(0 * SPI_FLASH_SEC_SIZE)) { - NODE_DBG("\nERASE SUCCESS\n"); + FLASH_DEBUG("\nERASE SUCCESS\n"); } if (SPI_FLASH_RESULT_OK == spi_flash_write(0, (uint32 *)data, SPI_FLASH_SEC_SIZE)) { - NODE_DBG("\nWRITE SUCCESS, %u\n", size); + FLASH_DEBUG("\nWRITE SUCCESS, %u\n", size); } } - NODE_DBG("\nEND SET FLASH HEADER\n"); + FLASH_DEBUG("\nEND SET FLASH HEADER\n"); return true; } @@ -281,7 +278,7 @@ bool flash_rom_set_speed(uint32_t speed) // Dangerous, here are dinosaur infested!!!!! // Reboot required!!! // If you don't know what you're doing, your nodemcu may turn into stone ... - NODE_DBG("\nBEGIN SET FLASH HEADER\n"); + FLASH_DEBUG("\nBEGIN SET FLASH HEADER\n"); uint8_t data[SPI_FLASH_SEC_SIZE] ICACHE_STORE_ATTR; uint8_t speed_type = SPEED_40MHZ; if (speed < 26700000) @@ -305,14 +302,14 @@ bool flash_rom_set_speed(uint32_t speed) ((SPIFlashInfo *)(&data[0]))->speed = speed_type; if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(0 * SPI_FLASH_SEC_SIZE)) { - NODE_DBG("\nERASE SUCCESS\n"); + FLASH_DEBUG("\nERASE SUCCESS\n"); } if (SPI_FLASH_RESULT_OK == spi_flash_write(0, (uint32 *)data, SPI_FLASH_SEC_SIZE)) { - NODE_DBG("\nWRITE SUCCESS, %u\n", speed_type); + FLASH_DEBUG("\nWRITE SUCCESS, %u\n", speed_type); } } - NODE_DBG("\nEND SET FLASH HEADER\n"); + FLASH_DEBUG("\nEND SET FLASH HEADER\n"); return true; } @@ -393,7 +390,7 @@ uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index) { if ( (((uint32_t)aligned_array) % 4) != 0 ) { - NODE_DBG("aligned_array is not 4-byte aligned.\n"); + FLASH_DEBUG("aligned_array is not 4-byte aligned.\n"); return 0; } volatile uint32_t v = ((uint32_t *)aligned_array)[ index / 4 ]; @@ -405,7 +402,7 @@ uint16_t word_of_aligned_array(const uint16_t *aligned_array, uint32_t index) { if ( (((uint32_t)aligned_array) % 4) != 0 ) { - NODE_DBG("aligned_array is not 4-byte aligned.\n"); + FLASH_DEBUG("aligned_array is not 4-byte aligned.\n"); return 0; } volatile uint32_t v = ((uint32_t *)aligned_array)[ index / 2 ]; diff --git a/app/platform/flash_api.h b/app/platform/flash_api.h index 0063ee1c..7c09aeb0 100644 --- a/app/platform/flash_api.h +++ b/app/platform/flash_api.h @@ -1,8 +1,8 @@ #ifndef __FLASH_API_H__ #define __FLASH_API_H__ -#include "ets_sys.h" #include "user_config.h" -#include "cpu_esp8266.h" +#include "user_interface.h" +#include "spi_flash.h" #define FLASH_ADDRESS_START_MAP (INTERNAL_FLASH_START_ADDRESS) @@ -22,6 +22,8 @@ #define FLASH_SIZE_8MBYTE (FLASH_SIZE_64MBIT / 8) #define FLASH_SIZE_16MBYTE (FLASH_SIZE_128MBIT/ 8) +#define FLASH_DEBUG + #define FLASH_SAFEMODE_ENTER() \ do { \ extern SpiFlashChip * flashchip; \ @@ -85,7 +87,7 @@ typedef struct } size : 4; uint32_t entry_point; uint32_t memory_offset; - uint32_t segment_size; + uint32_t segment_size; } ICACHE_STORE_TYPEDEF_ATTR SPIFlashInfo; uint32_t flash_detect_size_byte(void); diff --git a/app/spiffs/spiffs.c b/app/spiffs/spiffs.c index 4d1ba0c4..c2c3ddc4 100644 --- a/app/spiffs/spiffs.c +++ b/app/spiffs/spiffs.c @@ -1,12 +1,10 @@ #include "c_stdio.h" #include "platform.h" #include "spiffs.h" -#undef NODE_DBG -#define NODE_DBG c_printf spiffs fs; -#define LOG_PAGE_SIZE 256 +#define LOG_PAGE_SIZE (256*2) static u8_t spiffs_work_buf[LOG_PAGE_SIZE*2]; static u8_t spiffs_fds[32*4]; @@ -51,9 +49,9 @@ void myspiffs_mount() { cfg.phys_addr &= 0xFFFFC000; // align to 4 sector. cfg.phys_size = INTERNAL_FLASH_SIZE - ( ( u32_t )cfg.phys_addr - INTERNAL_FLASH_START_ADDRESS ); cfg.phys_erase_block = INTERNAL_FLASH_SECTOR_SIZE; // according to datasheet - cfg.log_block_size = INTERNAL_FLASH_SECTOR_SIZE; // let us not complicate things + cfg.log_block_size = INTERNAL_FLASH_SECTOR_SIZE * 16; // let us not complicate things cfg.log_page_size = LOG_PAGE_SIZE; // as we said - NODE_DBG("fs.start:%x,max:%x\n",cfg.phys_addr,cfg.phys_size); + SPIFFS_DBG("fs.start:%x,max:%x\n",cfg.phys_addr,cfg.phys_size); cfg.hal_read_f = my_spiffs_read; cfg.hal_write_f = my_spiffs_write; @@ -68,7 +66,7 @@ void myspiffs_mount() { sizeof(spiffs_cache), // myspiffs_check_callback); 0); - NODE_DBG("mount res: %i\n", res); + SPIFFS_DBG("mount res: %i\n", res); } void myspiffs_unmount() { @@ -79,10 +77,13 @@ void myspiffs_unmount() { // Returns 1 if OK, 0 for error int myspiffs_format( void ) { -#if 0 - SPIFFS_unmount(&fs); +#if 1 + myspiffs_unmount(); + myspiffs_mount(); + myspiffs_unmount(); if(0 == SPIFFS_format(&fs)) { + myspiffs_mount(); return 1; } else @@ -97,7 +98,7 @@ int myspiffs_format( void ) sect_first = platform_flash_get_sector_of_address(sect_first); sect_last = INTERNAL_FLASH_SIZE + INTERNAL_FLASH_START_ADDRESS - 4; sect_last = platform_flash_get_sector_of_address(sect_last); - NODE_DBG("sect_first: %x, sect_last: %x\n", sect_first, sect_last); + SPIFFS_DBG("sect_first: %x, sect_last: %x\n", sect_first, sect_last); while( sect_first <= sect_last ) if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR ) return 0; @@ -116,7 +117,11 @@ int myspiffs_check( void ) } int myspiffs_open(const char *name, int flags){ - return (int)SPIFFS_open(&fs, (char *)name, (spiffs_flags)flags, 0); + int res = SPIFFS_open(&fs, (char *)name, (spiffs_flags)flags, 0); + if (res < 0) { + SPIFFS_DBG("open errno %i\n", SPIFFS_errno(&fs)); + } + return res; } int myspiffs_close( int fd ){ @@ -130,17 +135,17 @@ size_t myspiffs_write( int fd, const void* ptr, size_t len ){ return len; } #endif - int res = SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, (size_t)len); + int res = SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, len); if (res < 0) { - NODE_DBG("write errno %i\n", SPIFFS_errno(&fs)); + SPIFFS_DBG("write errno %i\n", SPIFFS_errno(&fs)); return 0; } return res; } size_t myspiffs_read( int fd, void* ptr, size_t len){ - int res = SPIFFS_read(&fs, (spiffs_file)fd, ptr, (size_t)len); + int res = SPIFFS_read(&fs, (spiffs_file)fd, ptr, len); if (res < 0) { - NODE_DBG("read errno %i\n", SPIFFS_errno(&fs)); + SPIFFS_DBG("read errno %i\n", SPIFFS_errno(&fs)); return 0; } return res; @@ -160,7 +165,7 @@ int myspiffs_getc( int fd ){ if(!myspiffs_eof(fd)){ res = SPIFFS_read(&fs, (spiffs_file)fd, &c, 1); if (res != 1) { - NODE_DBG("getc errno %i\n", SPIFFS_errno(&fs)); + SPIFFS_DBG("getc errno %i\n", SPIFFS_errno(&fs)); return (int)EOF; } else { return (int)c; @@ -193,13 +198,13 @@ void test_spiffs() { // Surely, I've mounted spiffs before entering here spiffs_file fd = SPIFFS_open(&fs, "my_file", SPIFFS_CREAT | SPIFFS_TRUNC | SPIFFS_RDWR, 0); - if (SPIFFS_write(&fs, fd, (u8_t *)"Hello world", 12) < 0) NODE_DBG("errno %i\n", SPIFFS_errno(&fs)); + if (SPIFFS_write(&fs, fd, (u8_t *)"Hello world", 12) < 0) SPIFFS_DBG("errno %i\n", SPIFFS_errno(&fs)); SPIFFS_close(&fs, fd); fd = SPIFFS_open(&fs, "my_file", SPIFFS_RDWR, 0); - if (SPIFFS_read(&fs, fd, (u8_t *)buf, 12) < 0) NODE_DBG("errno %i\n", SPIFFS_errno(&fs)); + if (SPIFFS_read(&fs, fd, (u8_t *)buf, 12) < 0) SPIFFS_DBG("errno %i\n", SPIFFS_errno(&fs)); SPIFFS_close(&fs, fd); - NODE_DBG("--> %s <--\n", buf); + SPIFFS_DBG("--> %s <--\n", buf); } #endif diff --git a/app/spiffs/spiffs.h b/app/spiffs/spiffs.h index d018e52c..6f9b4697 100644 --- a/app/spiffs/spiffs.h +++ b/app/spiffs/spiffs.h @@ -12,7 +12,7 @@ #if defined(__cplusplus) extern "C" { #endif - +#include "eagle_soc.h" #include "c_stdio.h" #include "spiffs_config.h" @@ -53,6 +53,7 @@ extern "C" { #define SPIFFS_ERR_TEST -10100 +#define SPIFFS_WDT_CLEAR(no_arg) WRITE_PERI_REG(0x60000914, 0x73) // spiffs file descriptor index type. must be signed typedef s16_t spiffs_file; diff --git a/app/spiffs/spiffs_config.h b/app/spiffs/spiffs_config.h index e91c784e..fef614bf 100644 --- a/app/spiffs/spiffs_config.h +++ b/app/spiffs/spiffs_config.h @@ -30,7 +30,7 @@ typedef uint8_t u8_t; // Set generic spiffs debug output call. #ifndef SPIFFS_DGB -#define SPIFFS_DBG(...) c_printf(__VA_ARGS__) +#define SPIFFS_DBG(...) //c_printf(__VA_ARGS__) #endif // Set spiffs debug output call for garbage collecting. #ifndef SPIFFS_GC_DGB @@ -124,7 +124,7 @@ typedef uint8_t u8_t; // not on mount point. If not, SPIFFS_format must be called prior to mounting // again. #ifndef SPIFFS_USE_MAGIC -#define SPIFFS_USE_MAGIC (0) +#define SPIFFS_USE_MAGIC (1) #endif // SPIFFS_LOCK and SPIFFS_UNLOCK protects spiffs from reentrancy on api level @@ -169,7 +169,7 @@ typedef uint8_t u8_t; // Enable this if your target needs aligned data for index tables #ifndef SPIFFS_ALIGNED_OBJECT_INDEX_TABLES -#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 0 +#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES 1 #endif // Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function diff --git a/app/spiffs/spiffs_hydrogen.c b/app/spiffs/spiffs_hydrogen.c index 2c6cdc31..b93c4fa8 100644 --- a/app/spiffs/spiffs_hydrogen.c +++ b/app/spiffs/spiffs_hydrogen.c @@ -936,6 +936,7 @@ s32_t SPIFFS_vis(spiffs *fs) { int cur_entry = 0; while (res == SPIFFS_OK && obj_lookup_page < (int)SPIFFS_OBJ_LOOKUP_PAGES(fs)) { + SPIFFS_WDT_CLEAR(); int entry_offset = obj_lookup_page * entries_per_page; res = _spiffs_rd(fs, SPIFFS_OP_T_OBJ_LU | SPIFFS_OP_C_READ, 0, bix * SPIFFS_CFG_LOG_BLOCK_SZ(fs) + SPIFFS_PAGE_TO_PADDR(fs, obj_lookup_page), SPIFFS_CFG_LOG_PAGE_SZ(fs), fs->lu_work); diff --git a/app/spiffs/spiffs_nucleus.c b/app/spiffs/spiffs_nucleus.c index e3de47d0..1036fcff 100644 --- a/app/spiffs/spiffs_nucleus.c +++ b/app/spiffs/spiffs_nucleus.c @@ -155,6 +155,7 @@ s32_t spiffs_obj_lu_find_entry_visitor( // check each block while (res == SPIFFS_OK && entry_count > 0) { int obj_lookup_page = cur_entry / entries_per_page; + SPIFFS_WDT_CLEAR(); // check each object lookup page while (res == SPIFFS_OK && obj_lookup_page < (int)SPIFFS_OBJ_LOOKUP_PAGES(fs)) { int entry_offset = obj_lookup_page * entries_per_page; @@ -165,6 +166,7 @@ s32_t spiffs_obj_lu_find_entry_visitor( cur_entry - entry_offset < entries_per_page && // for non-last obj lookup pages cur_entry < (int)SPIFFS_OBJ_LOOKUP_MAX_ENTRIES(fs)) // for last obj lookup page { + SPIFFS_WDT_CLEAR(); if ((flags & SPIFFS_VIS_CHECK_ID) == 0 || obj_lu_buf[cur_entry-entry_offset] == obj_id) { if (block_ix) *block_ix = cur_block; if (lu_entry) *lu_entry = cur_entry; @@ -301,6 +303,7 @@ s32_t spiffs_obj_lu_scan( spiffs_obj_id erase_count_min = SPIFFS_OBJ_ID_FREE; spiffs_obj_id erase_count_max = 0; while (bix < fs->block_count) { + SPIFFS_WDT_CLEAR(); #if SPIFFS_USE_MAGIC spiffs_obj_id magic; res = _spiffs_rd(fs, @@ -802,6 +805,7 @@ void spiffs_cb_object_event( u32_t i; spiffs_fd *fds = (spiffs_fd *)fs->fd_space; for (i = 0; i < fs->fd_count; i++) { + SPIFFS_WDT_CLEAR(); spiffs_fd *cur_fd = &fds[i]; if (cur_fd->file_nbr == 0 || (cur_fd->obj_id & ~SPIFFS_OBJ_ID_IX_FLAG) != obj_id) continue; if (spix == 0) { @@ -918,9 +922,9 @@ s32_t spiffs_object_append(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { // write all data while (res == SPIFFS_OK && written < len) { + SPIFFS_WDT_CLEAR(); // calculate object index page span index cur_objix_spix = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spix); - // handle storing and loading of object indices if (cur_objix_spix != prev_objix_spix) { // new object index page @@ -1150,6 +1154,7 @@ s32_t spiffs_object_modify(spiffs_fd *fd, u32_t offset, u8_t *data, u32_t len) { // write all data while (res == SPIFFS_OK && written < len) { + SPIFFS_WDT_CLEAR(); // calculate object index page span index cur_objix_spix = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spix); @@ -1627,6 +1632,7 @@ s32_t spiffs_object_read( spiffs_page_object_ix *objix = (spiffs_page_object_ix *)fs->work; while (cur_offset < offset + len) { + SPIFFS_WDT_CLEAR(); cur_objix_spix = SPIFFS_OBJ_IX_ENTRY_SPAN_IX(fs, data_spix); if (prev_objix_spix != cur_objix_spix) { // load current object index (header) page @@ -1775,6 +1781,7 @@ s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *co state.compaction = 0; state.conflicting_name = conflicting_name; while (res == SPIFFS_OK && free_obj_id == SPIFFS_OBJ_ID_FREE) { + SPIFFS_WDT_CLEAR(); if (state.max_obj_id - state.min_obj_id <= (spiffs_obj_id)SPIFFS_CFG_LOG_PAGE_SZ(fs)*8) { // possible to represent in bitmap u32_t i, j; @@ -1787,6 +1794,7 @@ s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *co SPIFFS_CHECK_RES(res); // traverse bitmask until found free obj_id for (i = 0; i < SPIFFS_CFG_LOG_PAGE_SZ(fs); i++) { + SPIFFS_WDT_CLEAR(); u8_t mask = fs->work[i]; if (mask == 0xff) { continue; @@ -1808,6 +1816,7 @@ s32_t spiffs_obj_lu_find_free_obj_id(spiffs *fs, spiffs_obj_id *obj_id, u8_t *co u8_t min_count = 0xff; for (i = 0; i < SPIFFS_CFG_LOG_PAGE_SZ(fs)/sizeof(u8_t); i++) { + SPIFFS_WDT_CLEAR(); if (map[i] < min_count) { min_count = map[i]; min_i = i; @@ -1860,6 +1869,7 @@ s32_t spiffs_fd_find_new(spiffs *fs, spiffs_fd **fd) { u32_t i; spiffs_fd *fds = (spiffs_fd *)fs->fd_space; for (i = 0; i < fs->fd_count; i++) { + SPIFFS_WDT_CLEAR(); spiffs_fd *cur_fd = &fds[i]; if (cur_fd->file_nbr == 0) { cur_fd->file_nbr = i+1; diff --git a/app/user/user_main.c b/app/user/user_main.c index 88938da8..a3ccc456 100644 --- a/app/user/user_main.c +++ b/app/user/user_main.c @@ -61,13 +61,15 @@ void nodemcu_init(void) #if defined(FLASH_SAFE_API) if( flash_safe_get_size_byte() != flash_rom_get_size_byte()) { - NODE_ERR("Self adjust flash size.\n"); + NODE_ERR("File system initialization ...\n"); + NODE_ERR("This will take a minute, don't power off.\n"); // Fit hardware real flash size. flash_rom_set_size_byte(flash_safe_get_size_byte()); // Flash init data at FLASHSIZE - 0x04000 Byte. flash_init_data_default(); // Flash blank data at FLASHSIZE - 0x02000 Byte. flash_init_data_blank(); + if( !fs_format() ) { NODE_ERR( "\ni*** ERROR ***: unable to format. FS might be compromised.\n" ); @@ -76,7 +78,8 @@ void nodemcu_init(void) else{ NODE_ERR( "format done.\n" ); } - fs_unmount(); // mounted by format. + // Unmount filesystem because mounted by format. + fs_unmount(); } #endif // defined(FLASH_SAFE_API) @@ -102,6 +105,22 @@ void nodemcu_init(void) // test_romfs(); #elif defined ( BUILD_SPIFFS ) fs_mount(); + if(SPIFFS_mounted == 0) + { + NODE_ERR("File system broken, formating ...\n"); + NODE_ERR("This will take a minute, don't power off.\n"); + if( !fs_format() ) + { + NODE_ERR( "\ni*** ERROR ***: unable to format. FS might be compromised.\n" ); + NODE_ERR( "It is advised to re-flash the NodeMCU image.\n" ); + } + else{ + NODE_ERR( "format done.\n" ); + } + // Ensure filesystem mounted. + fs_unmount(); + fs_mount(); + } // test_spiffs(); #endif // endpoint_setup();