File system issue

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
emtee
Posts: 6
Joined: Thu Jun 14, 2018 4:55 pm
Location: Alberta, Canada

File system issue

Post by emtee » Wed Mar 06, 2019 6:11 pm

Hi All,

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('/')
Here is a partial excerpt of the log:
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)
>>>
Please note that the system ran flawlessly as a data collection and reporting node prior to the last update and reset this morning.

I have highlighted in RED the:
  • f_bfree – number of free blocks
  • f_bavail – number of free blocks for unpriviliged users
from the os.statvfs('/') command after a fresh flash, after loading my modules and finally after the ESP8266 fell over.

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.

cefn
Posts: 225
Joined: Tue Aug 09, 2016 10:58 am

Re: File system issue

Post by cefn » Sat Mar 23, 2019 10:15 pm

I previously encountered this kind of behaviour when running with a very noisy USB power supply. Do you trust the power supply you are using? Can you try the same setup with a higher-quality (typically expensive,branded) USB power source? In the past I've used Apple USB chargers or laptop USB ports to try and get nice stable supply.

User avatar
emtee
Posts: 6
Joined: Thu Jun 14, 2018 4:55 pm
Location: Alberta, Canada

Re: File system issue

Post by emtee » Sun Mar 24, 2019 3:57 am

@cefn thanks for the reply. The board is plugged into my laptop as I am continuing to do development. Good thought about using a good quality power supply.

Post Reply