Why is uos.statvs() available block count so low?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
marvin
Posts: 1
Joined: Sun Nov 11, 2018 8:29 pm

Why is uos.statvs() available block count so low?

Post by marvin » Sun Nov 11, 2018 8:39 pm

I have the current micropython installed on a esp8266 board with 4MB flash.

On the flash I have three files:
>>> uos.listdir()
['boot.py', 'webrepl_cfg.py', 'test.mpy']
>>> uos.stat('/boot.py')
(32768, 0, 0, 0, 0, 0, 160, 22, 22, 22)
>>> uos.stat('/webrepl_cfg.py')
(32768, 0, 0, 0, 0, 0, 19, 20, 20, 20)
>>> uos.stat('/test.mpy')
(32768, 0, 0, 0, 0, 0, 10118, 40, 40, 40)

When I query the available space in the filesystem I get an answer I do not understand:
>>> uos.statvfs('/')
(4096, 4096, 860, 78, 78, 0, 0, 0, 0, 255)

If my filesystem has 860 blocks in total with each block 4096 bytes (~3.5 MB which makes sense for a 4MB flash chip), why are only 78 blocks available?

By my count the three files use the following amount of blocks:
boot.py: 1
webrepl_cfg.py: 1
test.mpy: 10118/4096 = 3
====================
total: 5

So why do I not have 860 - 5 = 855 blocks remaining available?

User avatar
Roberthh
Posts: 1114
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Why is uos.statvs() available block count so low?

Post by Roberthh » Mon Nov 12, 2018 5:58 pm

I cannot confirm that with my ESP8266. It shows reasonable values:

Code: Select all

>>> uos.statvfs("/flash")
(4096, 4096, 860, 847, 847, 0, 0, 0, 0, 255)
You could try to re-init the file system, using the code from _boot.py:

Code: Select all

import inisetup
inisetup.setup()
Of course that will wipe out any file.

Post Reply