get free flash space

  • On the esp8266, I use a function to get the free file space:

    def df():
      s = os.statvfs('//')
      return ('{0} MB'.format((s[0]*s[3])/1048576))

    However on the wipy, os.statvfs is not available and os.stat() does not appear to return the block data to be able to calculate the free space:

    >>> os.stat('/flash')
    (16384, 0, 0, 0, 0, 0, 0, 959558400, 959558400, 959558400)

    So how can I create a similar function that returns the free space in MB ?

  • @robert-hh - Yes, thanks, I am using that on the esp8266 ( see my first code snippet df() ) and it works just fine, what I am asking is how can I get the freespace on the pycom port as statvfs() is not available ?

  • @crankshaft For exactly that purpose statvfs() was introduced. There was an attempt (by @deshipu?) using a tree search with adding up file sizes, but that is slow and error prone. If you look up that discussion in the micropython's board, you may find that code.
    No, that code was never written. The discussion is here:

Log in to reply

Pycom on Twitter