Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    get free flash space

    Scheduled Pinned Locked Moved WiPy 2&3
    flash
    3 Posts 2 Posters 2.3k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C Offline
      crankshaft
      last edited by crankshaft

      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-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @crankshaft
        last edited by robert-hh

        @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:
        https://forum.micropython.org/viewtopic.php?f=16&t=2361&hilit=statvfs

        C 1 Reply Last reply Reply Quote 0
        • C Offline
          crankshaft @robert-hh
          last edited by

          @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 ?

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom