Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
b65fb02c
Commit
b65fb02c
authored
Jan 07, 2015
by
funshine
Browse files
add file.format() to rebuild fs system, get more ram back
parent
acd9d0dc
Changes
9
Show whitespace changes
Inline
Side-by-side
README.md
View file @
b65fb02c
...
...
@@ -26,6 +26,12 @@ Tencent QQ group QQ群: 309957875<br />
-
add coap module
# Change log
2015-01-07
<br
/>
retrive more ram back.
<br
/>
add api file.format() to rebuild file system.
<br
/>
rename "NodeMcu" to "NodeMCU" in firmware.
<br
/>
add some check for file system op.
2015-01-06
<br
/>
update sdk to 0.9.5.
<br
/>
pre_build bin now compiled by gcc toolchain.
<br
/>
...
...
@@ -33,13 +39,6 @@ memory/heap usage optimized.<br />
add support for multiple platform and toolchain include eclipse.
<br
/>
combine firmware for 512K, 1M, 2M, 4M flash to one. flash size auto-detected.
2014-12-30
<br
/>
modify uart.on api, when run_input set to 0, uart.on now can read raw data from uart.
<br
/>
serial input now accept non-ascii chars.
<br
/>
fix dev-kit gpio map.
<br
/>
add setip, setmac, sleeptype api to wifi module.
<br
/>
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
)
<br
/>
[
更多变更日志
](
https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_cn#change_log
)
...
...
@@ -147,6 +146,7 @@ eagle.app.v6.irom0text.bin: 0x10000<br />
esp_init_data_default.bin: 0x7c000
<br
/>
blank.bin: 0x7e000
<br
/>
*Better run file.format() after flash*
#Connect the hardware in serial
baudrate:9600
...
...
app/include/user_config.h
View file @
b65fb02c
...
...
@@ -6,7 +6,7 @@
#define NODE_VERSION_REVISION 5U
#define NODE_VERSION_INTERNAL 0U
#define NODE_VERSION "NodeM
cu
0.9.5"
#define NODE_VERSION "NodeM
CU
0.9.5"
#define BUILD_DATE "build 20150107"
// #define FLASH_512K
...
...
app/lua/lua.c
View file @
b65fb02c
...
...
@@ -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
);
}
...
...
app/modules/file.c
View file @
b65fb02c
...
...
@@ -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,21 +48,6 @@ static int file_close( lua_State* L )
return
0
;
}
#if defined(BUILD_WOFS)
// Lua: list()
static
int
file_list
(
lua_State
*
L
)
{
uint32_t
start
=
0
;
size_t
act_len
=
0
;
char
fsname
[
FS_NAME_MAX_LENGTH
+
1
];
lua_newtable
(
L
);
while
(
FS_FILE_OK
==
wofs_next
(
&
start
,
fsname
,
FS_NAME_MAX_LENGTH
,
&
act_len
)
){
lua_pushinteger
(
L
,
act_len
);
lua_setfield
(
L
,
-
2
,
fsname
);
}
return
1
;
}
// Lua: format()
static
int
file_format
(
lua_State
*
L
)
{
...
...
@@ -71,7 +56,7 @@ static int file_format( lua_State* L )
if
(
!
fs_format
()
)
{
NODE_ERR
(
"
\n
i*** ERROR ***: unable to format. FS might be compromised.
\n
"
);
NODE_ERR
(
"It is advised to re-flash the
n
odeM
cu
image.
\n
"
);
NODE_ERR
(
"It is advised to re-flash the
N
odeM
CU
image.
\n
"
);
}
else
{
NODE_ERR
(
"format done.
\n
"
);
...
...
@@ -79,6 +64,21 @@ static int file_format( lua_State* L )
return
0
;
}
#if defined(BUILD_WOFS)
// Lua: list()
static
int
file_list
(
lua_State
*
L
)
{
uint32_t
start
=
0
;
size_t
act_len
=
0
;
char
fsname
[
FS_NAME_MAX_LENGTH
+
1
];
lua_newtable
(
L
);
while
(
FS_FILE_OK
==
wofs_next
(
&
start
,
fsname
,
FS_NAME_MAX_LENGTH
,
&
act_len
)
){
lua_pushinteger
(
L
,
act_len
);
lua_setfield
(
L
,
-
2
,
fsname
);
}
return
1
;
}
#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
)
},
...
...
app/spiffs/spiffs.c
View file @
b65fb02c
...
...
@@ -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
;
}
...
...
examples/fragment.lua
View file @
b65fb02c
...
...
@@ -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
pre_build/0.9.5/nodemcu_latest.bin
View file @
b65fb02c
No preview for this file type
pre_build/latest/nodemcu_512k_latest.bin
View file @
b65fb02c
No preview for this file type
pre_build/latest/nodemcu_latest.bin
View file @
b65fb02c
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment