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
4fd11fdf
Commit
4fd11fdf
authored
Feb 16, 2015
by
devsaurus
Browse files
Merge remote-tracking branch 'upstream/dev' into dev
parents
bf1969e5
378398d4
Changes
5
Show whitespace changes
Inline
Side-by-side
app/lua/lauxlib.c
View file @
4fd11fdf
...
@@ -652,8 +652,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
...
@@ -652,8 +652,7 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
typedef
struct
LoadFSF
{
typedef
struct
LoadFSF
{
int
extraline
;
int
extraline
;
int
f
;
int
f
;
char
*
buff
;
char
buff
[
LUAL_BUFFERSIZE
];
int
len
;
}
LoadFSF
;
}
LoadFSF
;
...
@@ -666,7 +665,7 @@ static const char *getFSF (lua_State *L, void *ud, size_t *size) {
...
@@ -666,7 +665,7 @@ static const char *getFSF (lua_State *L, void *ud, size_t *size) {
return
"
\n
"
;
return
"
\n
"
;
}
}
if
(
fs_eof
(
lf
->
f
))
return
NULL
;
if
(
fs_eof
(
lf
->
f
))
return
NULL
;
*
size
=
fs_read
(
lf
->
f
,
lf
->
buff
,
(
lf
->
len
));
*
size
=
fs_read
(
lf
->
f
,
lf
->
buff
,
sizeof
(
lf
->
buff
));
return
(
*
size
>
0
)
?
lf
->
buff
:
NULL
;
return
(
*
size
>
0
)
?
lf
->
buff
:
NULL
;
}
}
...
@@ -685,9 +684,6 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
...
@@ -685,9 +684,6 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
int
c
;
int
c
;
int
fnameindex
=
lua_gettop
(
L
)
+
1
;
/* index of filename on the stack */
int
fnameindex
=
lua_gettop
(
L
)
+
1
;
/* index of filename on the stack */
lf
.
extraline
=
0
;
lf
.
extraline
=
0
;
// lf.len = LUAL_BUFFERSIZE;
lf
.
len
=
0
;
lf
.
buff
=
NULL
;
if
(
filename
==
NULL
)
{
if
(
filename
==
NULL
)
{
return
luaL_error
(
L
,
"filename is NULL"
);
return
luaL_error
(
L
,
"filename is NULL"
);
}
}
...
@@ -696,10 +692,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
...
@@ -696,10 +692,8 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
lf
.
f
=
fs_open
(
filename
,
FS_RDONLY
);
lf
.
f
=
fs_open
(
filename
,
FS_RDONLY
);
if
(
lf
.
f
<
FS_OPEN_OK
)
return
errfsfile
(
L
,
"open"
,
fnameindex
);
if
(
lf
.
f
<
FS_OPEN_OK
)
return
errfsfile
(
L
,
"open"
,
fnameindex
);
}
}
lf
.
len
=
fs_size
(
lf
.
f
)
+
32
;
// if(fs_size(lf.f)>LUAL_BUFFERSIZE)
lf
.
buff
=
c_zalloc
(
lf
.
len
);
// return luaL_error(L, "file is too big");
if
(
!
lf
.
buff
)
return
LUA_ERRMEM
;
c
=
fs_getc
(
lf
.
f
);
c
=
fs_getc
(
lf
.
f
);
if
(
c
==
'#'
)
{
/* Unix exec. file? */
if
(
c
==
'#'
)
{
/* Unix exec. file? */
lf
.
extraline
=
1
;
lf
.
extraline
=
1
;
...
@@ -709,13 +703,7 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
...
@@ -709,13 +703,7 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
if
(
c
==
LUA_SIGNATURE
[
0
]
&&
filename
)
{
/* binary file? */
if
(
c
==
LUA_SIGNATURE
[
0
]
&&
filename
)
{
/* binary file? */
fs_close
(
lf
.
f
);
fs_close
(
lf
.
f
);
lf
.
f
=
fs_open
(
filename
,
FS_RDONLY
);
/* reopen in binary mode */
lf
.
f
=
fs_open
(
filename
,
FS_RDONLY
);
/* reopen in binary mode */
if
(
lf
.
f
<
FS_OPEN_OK
){
if
(
lf
.
f
<
FS_OPEN_OK
)
return
errfsfile
(
L
,
"reopen"
,
fnameindex
);
if
(
lf
.
buff
)
c_free
(
lf
.
buff
);
lf
.
buff
=
NULL
;
lf
.
len
=
0
;
return
errfsfile
(
L
,
"reopen"
,
fnameindex
);
}
/* skip eventual `#!...' */
/* skip eventual `#!...' */
while
((
c
=
fs_getc
(
lf
.
f
))
!=
EOF
&&
c
!=
LUA_SIGNATURE
[
0
])
;
while
((
c
=
fs_getc
(
lf
.
f
))
!=
EOF
&&
c
!=
LUA_SIGNATURE
[
0
])
;
lf
.
extraline
=
0
;
lf
.
extraline
=
0
;
...
@@ -725,9 +713,6 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
...
@@ -725,9 +713,6 @@ LUALIB_API int luaL_loadfsfile (lua_State *L, const char *filename) {
if
(
filename
)
fs_close
(
lf
.
f
);
/* close file (even in case of errors) */
if
(
filename
)
fs_close
(
lf
.
f
);
/* close file (even in case of errors) */
lua_remove
(
L
,
fnameindex
);
lua_remove
(
L
,
fnameindex
);
if
(
lf
.
buff
)
c_free
(
lf
.
buff
);
lf
.
buff
=
NULL
;
return
status
;
return
status
;
}
}
...
...
app/lua/luaconf.h
View file @
4fd11fdf
...
@@ -542,7 +542,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
...
@@ -542,7 +542,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
/*
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
*/
#define LUAL_BUFFERSIZE BUFSIZ
#define LUAL_BUFFERSIZE
((
BUFSIZ
)*4)
/* }================================================================== */
/* }================================================================== */
...
...
app/platform/flash_api.c
View file @
4fd11fdf
...
@@ -24,6 +24,7 @@ SPIFlashInfo flash_get_info(void)
...
@@ -24,6 +24,7 @@ SPIFlashInfo flash_get_info(void)
{
{
volatile
SPIFlashInfo
spi_flash_info
ICACHE_STORE_ATTR
;
volatile
SPIFlashInfo
spi_flash_info
ICACHE_STORE_ATTR
;
spi_flash_info
=
*
((
SPIFlashInfo
*
)(
FLASH_MAP_START_ADDRESS
));
spi_flash_info
=
*
((
SPIFlashInfo
*
)(
FLASH_MAP_START_ADDRESS
));
// spi_flash_read(0, (uint32 *)(& spi_flash_info), sizeof(spi_flash_info));
return
spi_flash_info
;
return
spi_flash_info
;
}
}
...
@@ -56,9 +57,11 @@ uint32_t flash_get_size_byte(void)
...
@@ -56,9 +57,11 @@ uint32_t flash_get_size_byte(void)
case
SIZE_32MBIT
:
case
SIZE_32MBIT
:
// 32Mbit, 4MByte
// 32Mbit, 4MByte
flash_size
=
4
*
1024
*
1024
;
flash_size
=
4
*
1024
*
1024
;
break
;
case
SIZE_64MBIT
:
case
SIZE_64MBIT
:
// 64Mbit, 8MByte
// 64Mbit, 8MByte
flash_size
=
8
*
1024
*
1024
;
flash_size
=
8
*
1024
*
1024
;
break
;
case
SIZE_128MBIT
:
case
SIZE_128MBIT
:
// 128Mbit, 16MByte
// 128Mbit, 16MByte
flash_size
=
16
*
1024
*
1024
;
flash_size
=
16
*
1024
*
1024
;
...
@@ -131,7 +134,15 @@ bool flash_set_size_byte(uint32_t size)
...
@@ -131,7 +134,15 @@ bool flash_set_size_byte(uint32_t size)
uint16_t
flash_get_sec_num
(
void
)
uint16_t
flash_get_sec_num
(
void
)
{
{
return
flash_get_size_byte
()
/
SPI_FLASH_SEC_SIZE
;
//static uint16_t sec_num = 0;
// return flash_get_size_byte() / (SPI_FLASH_SEC_SIZE);
// c_printf("\nflash_get_size_byte()=%d\n", ( flash_get_size_byte() / (SPI_FLASH_SEC_SIZE) ));
// if( sec_num == 0 )
//{
// sec_num = 4 * 1024 * 1024 / (SPI_FLASH_SEC_SIZE);
//}
//return sec_num;
return
(
flash_get_size_byte
()
/
(
SPI_FLASH_SEC_SIZE
)
);
}
}
uint8_t
flash_get_mode
(
void
)
uint8_t
flash_get_mode
(
void
)
...
@@ -232,13 +243,14 @@ bool flash_self_destruct(void)
...
@@ -232,13 +243,14 @@ bool flash_self_destruct(void)
return
true
;
return
true
;
}
}
uint8_t
byte_of_aligned_array
(
const
uint8_t
*
aligned_array
,
uint32_t
index
)
uint8_t
byte_of_aligned_array
(
const
uint8_t
*
aligned_array
,
uint32_t
index
)
{
{
if
(
(((
uint32_t
)
aligned_array
)
%
4
)
!=
0
){
if
(
(((
uint32_t
)
aligned_array
)
%
4
)
!=
0
)
{
NODE_DBG
(
"aligned_array is not 4-byte aligned.
\n
"
);
NODE_DBG
(
"aligned_array is not 4-byte aligned.
\n
"
);
return
0
;
return
0
;
}
}
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
4
];
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
4
];
uint8_t
*
p
=
(
uint8_t
*
)
(
&
v
);
uint8_t
*
p
=
(
uint8_t
*
)
(
&
v
);
return
p
[
(
index
%
4
)
];
return
p
[
(
index
%
4
)
];
}
}
app/platform/flash_api.h
View file @
4fd11fdf
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "ets_sys.h"
#include "ets_sys.h"
#include "user_config.h"
#include "user_config.h"
#include "cpu_esp8266.h"
#include "cpu_esp8266.h"
#define FLASH_MAP_START_ADDRESS (INTERNAL_FLASH_START_ADDRESS)
#define FLASH_MAP_START_ADDRESS (INTERNAL_FLASH_START_ADDRESS)
/******************************************************************************
/******************************************************************************
...
...
app/spiffs/spiffs.h
View file @
4fd11fdf
...
@@ -466,5 +466,6 @@ int myspiffs_error( int fd );
...
@@ -466,5 +466,6 @@ int myspiffs_error( int fd );
void
myspiffs_clearerr
(
int
fd
);
void
myspiffs_clearerr
(
int
fd
);
int
myspiffs_check
(
void
);
int
myspiffs_check
(
void
);
int
myspiffs_rename
(
const
char
*
old
,
const
char
*
newname
);
int
myspiffs_rename
(
const
char
*
old
,
const
char
*
newname
);
size_t
myspiffs_size
(
int
fd
);
#endif
/* SPIFFS_H_ */
#endif
/* SPIFFS_H_ */
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