diff --git a/README.md b/README.md index b0809465..716d3581 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ Tencent QQ group QQ群: 309957875
- add coap module # Change log +2015-01-07
+retrive more ram back.
+add api file.format() to rebuild file system.
+rename "NodeMcu" to "NodeMCU" in firmware.
+add some check for file system op. + 2015-01-06
update sdk to 0.9.5.
pre_build bin now compiled by gcc toolchain.
@@ -33,13 +39,6 @@ memory/heap usage optimized.
add support for multiple platform and toolchain include eclipse.
combine firmware for 512K, 1M, 2M, 4M flash to one. flash size auto-detected. -2014-12-30
-modify uart.on api, when run_input set to 0, uart.on now can read raw data from uart.
-serial input now accept non-ascii chars.
-fix dev-kit gpio map.
-add setip, setmac, sleeptype api to wifi module.
-add tmr.time() api to get rtc time and calibration. - [more change log](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#change_log)
[更多变更日志](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_cn#change_log) @@ -147,6 +146,7 @@ eagle.app.v6.irom0text.bin: 0x10000
esp_init_data_default.bin: 0x7c000
blank.bin: 0x7e000
+*Better run file.format() after flash* #Connect the hardware in serial baudrate:9600 diff --git a/app/include/user_config.h b/app/include/user_config.h index aae2c1b1..8e784520 100644 --- a/app/include/user_config.h +++ b/app/include/user_config.h @@ -6,7 +6,7 @@ #define NODE_VERSION_REVISION 5U #define NODE_VERSION_INTERNAL 0U -#define NODE_VERSION "NodeMcu 0.9.5" +#define NODE_VERSION "NodeMCU 0.9.5" #define BUILD_DATE "build 20150107" // #define FLASH_512K diff --git a/app/lua/lua.c b/app/lua/lua.c index 43325550..ef9113f4 100644 --- a/app/lua/lua.c +++ b/app/lua/lua.c @@ -133,7 +133,7 @@ static int docall (lua_State *L, int narg, int clear) { static void print_version (void) { // l_message(NULL, LUA_RELEASE " " LUA_COPYRIGHT); - l_message(NULL, NODE_VERSION " " BUILD_DATE " powered by " LUA_RELEASE); + l_message(NULL, "\n" NODE_VERSION " " BUILD_DATE " powered by " LUA_RELEASE); } diff --git a/app/modules/file.c b/app/modules/file.c index 22782de3..fa7628d3 100644 --- a/app/modules/file.c +++ b/app/modules/file.c @@ -11,7 +11,7 @@ #include "flash_fs.h" #include "c_string.h" -static int file_fd = FS_OPEN_OK - 1; +static volatile int file_fd = FS_OPEN_OK - 1; // Lua: open(filename, mode) static int file_open( lua_State* L ) @@ -48,6 +48,22 @@ static int file_close( lua_State* L ) return 0; } +// Lua: format() +static int file_format( lua_State* L ) +{ + size_t len; + file_close(L); + 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" ); + } + return 0; +} + #if defined(BUILD_WOFS) // Lua: list() static int file_list( lua_State* L ) @@ -63,22 +79,6 @@ static int file_list( lua_State* L ) return 1; } -// Lua: format() -static int file_format( lua_State* L ) -{ - size_t len; - file_close(L); - 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" ); - } - return 0; -} - #elif defined(BUILD_SPIFFS) extern spiffs fs; @@ -275,8 +275,8 @@ const LUA_REG_TYPE file_map[] = { LSTRKEY( "writeline" ), LFUNCVAL( file_writeline ) }, { LSTRKEY( "read" ), LFUNCVAL( file_read ) }, { LSTRKEY( "readline" ), LFUNCVAL( file_readline ) }, -#if defined(BUILD_WOFS) { LSTRKEY( "format" ), LFUNCVAL( file_format ) }, +#if defined(BUILD_WOFS) #elif defined(BUILD_SPIFFS) { LSTRKEY( "remove" ), LFUNCVAL( file_remove ) }, { LSTRKEY( "seek" ), LFUNCVAL( file_seek ) }, diff --git a/app/spiffs/spiffs.c b/app/spiffs/spiffs.c index 005dab1a..84d57008 100644 --- a/app/spiffs/spiffs.c +++ b/app/spiffs/spiffs.c @@ -81,6 +81,7 @@ int myspiffs_format( void ) while( sect_first <= sect_last ) if( platform_flash_erase_sector( sect_first ++ ) == PLATFORM_ERR ) return 0; + spiffs_mount(); return 1; } @@ -107,10 +108,20 @@ size_t myspiffs_write( int fd, const void* ptr, size_t len ){ return len; } #endif - return SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, len); + int res = SPIFFS_write(&fs, (spiffs_file)fd, (void *)ptr, len); + if (res < 0) { + NODE_DBG("write errno %i\n", SPIFFS_errno(&fs)); + return 0; + } + return res; } size_t myspiffs_read( int fd, void* ptr, size_t len){ - return SPIFFS_read(&fs, (spiffs_file)fd, ptr, len); + int res = SPIFFS_read(&fs, (spiffs_file)fd, ptr, len); + if (res < 0) { + NODE_DBG("read errno %i\n", SPIFFS_errno(&fs)); + return 0; + } + return res; } int myspiffs_lseek( int fd, int off, int whence ){ return SPIFFS_lseek(&fs, (spiffs_file)fd, off, whence); @@ -123,8 +134,13 @@ int myspiffs_tell( int fd ){ } int myspiffs_getc( int fd ){ char c = EOF; + int res; if(!myspiffs_eof(fd)){ - SPIFFS_read(&fs, (spiffs_file)fd, &c, 1); + res = SPIFFS_read(&fs, (spiffs_file)fd, &c, 1); + if (res != 1) { + NODE_DBG("getc errno %i\n", SPIFFS_errno(&fs)); + return (int)EOF; + } } return (int)c; } diff --git a/examples/fragment.lua b/examples/fragment.lua index f4f8b11d..0699df4e 100644 --- a/examples/fragment.lua +++ b/examples/fragment.lua @@ -310,3 +310,5 @@ uart.on("data", 5 ,function(input) if input=="quit\r" then uart.on("data") else uart.on("data", 0 ,function(input) if input=="q" then uart.on("data") else print(input) end end, 0) uart.on("data","\r",function(input) if input=="quit" then uart.on("data") else print(input) end end, 1) + +for k, v in pairs(file.list()) do print('file:'..k..' len:'..v) end diff --git a/pre_build/0.9.5/nodemcu_latest.bin b/pre_build/0.9.5/nodemcu_latest.bin index 7b13f9cd..04f4dc31 100644 Binary files a/pre_build/0.9.5/nodemcu_latest.bin and b/pre_build/0.9.5/nodemcu_latest.bin differ diff --git a/pre_build/latest/nodemcu_512k_latest.bin b/pre_build/latest/nodemcu_512k_latest.bin index 7b13f9cd..04f4dc31 100644 Binary files a/pre_build/latest/nodemcu_512k_latest.bin and b/pre_build/latest/nodemcu_512k_latest.bin differ diff --git a/pre_build/latest/nodemcu_latest.bin b/pre_build/latest/nodemcu_latest.bin index 7b13f9cd..04f4dc31 100644 Binary files a/pre_build/latest/nodemcu_latest.bin and b/pre_build/latest/nodemcu_latest.bin differ