I am having a strange problem with the onboard file system. It seems that after a number of operations on a newly flashed system, the file system is suddenly scrambled.
A bit of background first: I have developed a number of modules complete with a main.py that turns the ESP8266 into a temperature and humidity reporting node. I am using a DHT22 and a 128x64 OLED display attached to the ESP8266. Data reporting is done using MQTT with mosquitto on a Raspberry Pi 3. Visualization (HMI) is done using Node-RED on the Raspberry and a web browser. Data collection is performed on a periodic basis on the ESP using Timer. Time updates on the ESP also uses a Timer and NTP to update the onboard clock approximately once an hour.
I first noticed this problem in that after an update of a file on the ESP8266 and a reset, modules that previously worked would not break with an exception in random locations.
Over the last couple of days, I have kept a log of my changes to the ESP starting with an initial flash using micropython version 1.10.0 on a NodeMCU ESP8266 board. I kept track of the file system using the results of:
Code: Select all
os.statvfs('/')
Please note that the system ran flawlessly as a data collection and reporting node prior to the last update and reset this morning.Mar 5, 2019
After flash:
>>> os.statvfs('/')
(4096, 4096, 860, 859, 859, 0, 0, 0, 0, 255)
>>>
After load_mod.bat:
(loads all of the .mpy and .py modules for DAQ)
>>> os.statvfs('/')
(4096, 4096, 860, 837, 837, 0, 0, 0, 0, 255)
>>>
Begin run: 11:57:01
Log:
12:05 - update my_main.py
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import os
=== os.statvfs('/')
(4096, 4096, 860, 837, 837, 0, 0, 0, 0, 255)
>>> os.remove('state.json')
>>> os.statvfs('/')
(4096, 4096, 860, 838, 838, 0, 0, 0, 0, 255)
>>>
----
.
. - a number of module updates and downloads, reset ESP8266 after the downloads
. ESP resumes data collection and reporting
Mar 6, 2019
.
. - a number of module updates and downloads, reset ESP8266 after the downloads
. ESP resumes data collection and reporting
----
10:24 - reset
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "my_main.py", line 39, in <module>
File "cls_display.py", line 111
SyntaxError: invalid syntax
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>>
PYB: soft reboot
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "my_main.py", line 39, in <module>
File "cls_display.py", line 111
SyntaxError: invalid syntax
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import os
=== os.statvfs('/')
(4096, 4096, 860, 0, 0, 0, 0, 0, 0, 255)
>>>
----
10:24 - cycle power by removing USB connection, plugging in USB after 30 seconds
Traceback (most recent call last):
File "main.py", line 1, in <module>
File "my_main.py", line 39, in <module>
File "cls_display.py", line 111
SyntaxError: invalid syntax
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
>>>
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import os
=== os.statvfs('/')
(4096, 4096, 860, 0, 0, 0, 0, 0, 0, 255)
>>>
I have highlighted in RED the:
- f_bfree – number of free blocks
- f_bavail – number of free blocks for unpriviliged users
Has any one else encountered this or a similar problem?
P.S. The only recovery I have found so far is to reflash the ESP8266 and reload my modules.