Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
1f798dab
Commit
1f798dab
authored
May 28, 2015
by
dnc40085
Browse files
Revert "Update spiffs to latest."
parent
f7a61838
Changes
8
Hide whitespace changes
Inline
Side-by-side
app/platform/flash_api.c
View file @
1f798dab
...
...
@@ -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,40 +103,43 @@ uint8_t flash_rom_get_size_type(void)
uint32_t
flash_rom_get_size_byte
(
void
)
{
static
uint32_t
flash_size
=
0
;
switch
(
flash_
rom_getinfo
().
size
)
if
(
flash_
size
==
0
)
{
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
;
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
;
}
}
return
flash_size
;
}
...
...
@@ -146,21 +149,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 ...
FLASH_DEBU
G
(
"
\n
BEGIN SET FLASH HEADER
\n
"
);
NODE_DB
G
(
"
\n
BEGIN 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
))
{
FLASH_DEBU
G
(
"
\n
ERASE SUCCESS
\n
"
);
NODE_DB
G
(
"
\n
ERASE SUCCESS
\n
"
);
}
if
(
SPI_FLASH_RESULT_OK
==
spi_flash_write
(
0
,
(
uint32
*
)
data
,
SPI_FLASH_SEC_SIZE
))
{
FLASH_DEBU
G
(
"
\n
WRITE SUCCESS, %u
\n
"
,
size
);
NODE_DB
G
(
"
\n
WRITE SUCCESS, %u
\n
"
,
size
);
}
}
FLASH_DEBU
G
(
"
\n
END SET FLASH HEADER
\n
"
);
NODE_DB
G
(
"
\n
END SET FLASH HEADER
\n
"
);
return
true
;
}
...
...
@@ -278,7 +281,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 ...
FLASH_DEBU
G
(
"
\n
BEGIN SET FLASH HEADER
\n
"
);
NODE_DB
G
(
"
\n
BEGIN SET FLASH HEADER
\n
"
);
uint8_t
data
[
SPI_FLASH_SEC_SIZE
]
ICACHE_STORE_ATTR
;
uint8_t
speed_type
=
SPEED_40MHZ
;
if
(
speed
<
26700000
)
...
...
@@ -302,14 +305,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
))
{
FLASH_DEBU
G
(
"
\n
ERASE SUCCESS
\n
"
);
NODE_DB
G
(
"
\n
ERASE SUCCESS
\n
"
);
}
if
(
SPI_FLASH_RESULT_OK
==
spi_flash_write
(
0
,
(
uint32
*
)
data
,
SPI_FLASH_SEC_SIZE
))
{
FLASH_DEBU
G
(
"
\n
WRITE SUCCESS, %u
\n
"
,
speed_type
);
NODE_DB
G
(
"
\n
WRITE SUCCESS, %u
\n
"
,
speed_type
);
}
}
FLASH_DEBU
G
(
"
\n
END SET FLASH HEADER
\n
"
);
NODE_DB
G
(
"
\n
END SET FLASH HEADER
\n
"
);
return
true
;
}
...
...
@@ -390,7 +393,7 @@ uint8_t byte_of_aligned_array(const uint8_t *aligned_array, uint32_t index)
{
if
(
(((
uint32_t
)
aligned_array
)
%
4
)
!=
0
)
{
FLASH_DEBU
G
(
"aligned_array is not 4-byte aligned.
\n
"
);
NODE_DB
G
(
"aligned_array is not 4-byte aligned.
\n
"
);
return
0
;
}
volatile
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
4
];
...
...
@@ -402,7 +405,7 @@ uint16_t word_of_aligned_array(const uint16_t *aligned_array, uint32_t index)
{
if
(
(((
uint32_t
)
aligned_array
)
%
4
)
!=
0
)
{
FLASH_DEBU
G
(
"aligned_array is not 4-byte aligned.
\n
"
);
NODE_DB
G
(
"aligned_array is not 4-byte aligned.
\n
"
);
return
0
;
}
volatile
uint32_t
v
=
((
uint32_t
*
)
aligned_array
)[
index
/
2
];
...
...
app/platform/flash_api.h
View file @
1f798dab
#ifndef __FLASH_API_H__
#define __FLASH_API_H__
#include "ets_sys.h"
#include "user_config.h"
#include "user_interface.h"
#include "spi_flash.h"
#include "cpu_esp8266.h"
#define FLASH_ADDRESS_START_MAP (INTERNAL_FLASH_START_ADDRESS)
...
...
@@ -22,8 +22,6 @@
#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; \
...
...
@@ -87,7 +85,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
);
...
...
app/spiffs/spiffs.c
View file @
1f798dab
#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
*2)
#define LOG_PAGE_SIZE 256
static
u8_t
spiffs_work_buf
[
LOG_PAGE_SIZE
*
2
];
static
u8_t
spiffs_fds
[
32
*
4
];
...
...
@@ -49,9 +51,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
*
16
;
// let us not complicate things
cfg
.
log_block_size
=
INTERNAL_FLASH_SECTOR_SIZE
;
// let us not complicate things
cfg
.
log_page_size
=
LOG_PAGE_SIZE
;
// as we said
SPIFFS
_DBG
(
"fs.start:%x,max:%x
\n
"
,
cfg
.
phys_addr
,
cfg
.
phys_size
);
NODE
_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
;
...
...
@@ -66,7 +68,7 @@ void myspiffs_mount() {
sizeof
(
spiffs_cache
),
// myspiffs_check_callback);
0
);
SPIFFS
_DBG
(
"mount res: %i
\n
"
,
res
);
NODE
_DBG
(
"mount res: %i
\n
"
,
res
);
}
void
myspiffs_unmount
()
{
...
...
@@ -77,13 +79,10 @@ void myspiffs_unmount() {
// Returns 1 if OK, 0 for error
int
myspiffs_format
(
void
)
{
#if 1
myspiffs_unmount
();
myspiffs_mount
();
myspiffs_unmount
();
#if 0
SPIFFS_unmount(&fs);
if(0 == SPIFFS_format(&fs))
{
myspiffs_mount
();
return 1;
}
else
...
...
@@ -98,7 +97,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
);
SPIFFS
_DBG
(
"sect_first: %x, sect_last: %x
\n
"
,
sect_first
,
sect_last
);
NODE
_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
;
...
...
@@ -117,11 +116,7 @@ int myspiffs_check( void )
}
int
myspiffs_open
(
const
char
*
name
,
int
flags
){
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
;
return
(
int
)
SPIFFS_open
(
&
fs
,
(
char
*
)
name
,
(
spiffs_flags
)
flags
,
0
);
}
int
myspiffs_close
(
int
fd
){
...
...
@@ -135,17 +130,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
,
len
);
int
res
=
SPIFFS_write
(
&
fs
,
(
spiffs_file
)
fd
,
(
void
*
)
ptr
,
(
size_t
)
len
);
if
(
res
<
0
)
{
SPIFFS
_DBG
(
"write errno %i
\n
"
,
SPIFFS_errno
(
&
fs
));
NODE
_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
,
len
);
int
res
=
SPIFFS_read
(
&
fs
,
(
spiffs_file
)
fd
,
ptr
,
(
size_t
)
len
);
if
(
res
<
0
)
{
SPIFFS
_DBG
(
"read errno %i
\n
"
,
SPIFFS_errno
(
&
fs
));
NODE
_DBG
(
"read errno %i
\n
"
,
SPIFFS_errno
(
&
fs
));
return
0
;
}
return
res
;
...
...
@@ -165,7 +160,7 @@ int myspiffs_getc( int fd ){
if
(
!
myspiffs_eof
(
fd
)){
res
=
SPIFFS_read
(
&
fs
,
(
spiffs_file
)
fd
,
&
c
,
1
);
if
(
res
!=
1
)
{
SPIFFS
_DBG
(
"getc errno %i
\n
"
,
SPIFFS_errno
(
&
fs
));
NODE
_DBG
(
"getc errno %i
\n
"
,
SPIFFS_errno
(
&
fs
));
return
(
int
)
EOF
;
}
else
{
return
(
int
)
c
;
...
...
@@ -198,13 +193,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)
SPIFFS
_DBG("errno %i\n", SPIFFS_errno(&fs));
if (SPIFFS_write(&fs, fd, (u8_t *)"Hello world", 12) < 0)
NODE
_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)
SPIFFS
_DBG("errno %i\n", SPIFFS_errno(&fs));
if (SPIFFS_read(&fs, fd, (u8_t *)buf, 12) < 0)
NODE
_DBG("errno %i\n", SPIFFS_errno(&fs));
SPIFFS_close(&fs, fd);
SPIFFS
_DBG("--> %s <--\n", buf);
NODE
_DBG("--> %s <--\n", buf);
}
#endif
app/spiffs/spiffs.h
View file @
1f798dab
...
...
@@ -12,7 +12,7 @@
#if defined(__cplusplus)
extern
"C"
{
#endif
#include "eagle_soc.h"
#include "c_stdio.h"
#include "spiffs_config.h"
...
...
@@ -53,7 +53,6 @@ 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
;
...
...
app/spiffs/spiffs_config.h
View file @
1f798dab
...
...
@@ -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 (
1
)
#define SPIFFS_USE_MAGIC (
0
)
#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
1
#define SPIFFS_ALIGNED_OBJECT_INDEX_TABLES
0
#endif
// Set SPIFFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
...
...
app/spiffs/spiffs_hydrogen.c
View file @
1f798dab
...
...
@@ -936,7 +936,6 @@ 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
);
...
...
app/spiffs/spiffs_nucleus.c
View file @
1f798dab
...
...
@@ -155,7 +155,6 @@ 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
;
...
...
@@ -166,7 +165,6 @@ 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
;
...
...
@@ -303,7 +301,6 @@ 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
,
...
...
@@ -805,7 +802,6 @@ 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
)
{
...
...
@@ -922,9 +918,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
...
...
@@ -1154,7 +1150,6 @@ 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
);
...
...
@@ -1632,7 +1627,6 @@ 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
...
...
@@ -1781,7 +1775,6 @@ 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
;
...
...
@@ -1794,7 +1787,6 @@ 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
;
...
...
@@ -1816,7 +1808,6 @@ 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
;
...
...
@@ -1869,7 +1860,6 @@ 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
;
...
...
app/user/user_main.c
View file @
1f798dab
...
...
@@ -61,15 +61,13 @@ void nodemcu_init(void)
#if defined(FLASH_SAFE_API)
if
(
flash_safe_get_size_byte
()
!=
flash_rom_get_size_byte
())
{
NODE_ERR
(
"File system initialization ...
\n
"
);
NODE_ERR
(
"This will take a minute, don't power off.
\n
"
);
NODE_ERR
(
"Self adjust flash size.
\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
(
"
\n
i*** ERROR ***: unable to format. FS might be compromised.
\n
"
);
...
...
@@ -78,8 +76,7 @@ void nodemcu_init(void)
else
{
NODE_ERR
(
"format done.
\n
"
);
}
// Unmount filesystem because mounted by format.
fs_unmount
();
fs_unmount
();
// mounted by format.
}
#endif // defined(FLASH_SAFE_API)
...
...
@@ -105,22 +102,6 @@ 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
(
"
\n
i*** 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();
...
...
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