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

    What is the size limitation of the nvm storage in module pycom?

    Scheduled Pinned Locked Moved Enhancements
    featpycomnvs
    3 Posts 2 Posters 1.4k Views 2 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.
    • R Offline
      rolandvs
      last edited by

      What is the size limitation of the nvs function?

      Is it not possible to return the amount that is still free?

      pycom.nvs_set(key, value)
      pycom.nvs_get(key)

      1 Reply Last reply Reply Quote 2
      • R Offline
        rolandvs
        last edited by

        Well no answer since 3 months. I have tried it myself and filled the lopy by running:

        import pycom
        
        pycom.nvs_erase_all()
        
        ii=0
        while True:
            try:
                print(ii)
                pycom.nvs_set('loc'+str(ii), ii)
                ii+=1
            except: OSErr as err:
                print(err, ii-1)
                break
        

        It will run and exit with "No space available 613", so locations 0-613 can be used. Every location is filled with its "index number".

        pycom.nvs_get('loc614') will return None
        pycom.nvs_get('loc613') will return 613
        pycom.nvs_get('loc612') will return 612, etc.
        

        UPDATING any location:

        pycom.nvs_set('loc612', 0x55aa) gives an error:
        

        Will return an error: "OSError no space available"

        Removing a single entry:

        pycom.nvs_erase('loc613')
        

        If it does not exist the error "KeyError: key not found" is returned

        Then when you store the value again:

        pycom.nvs_set('loc613', 0x55aa)
        

        But when doing it again you end up with the "OSError: no space available"

        So there are 614 locations available where you can store a 32bit value.

        There seem to be a BUG when UPDATING an EXISTING parameter when it is filled to the maximum. So there is possible a wrong offset (range) that only is visible when all of the memory is used.

        It would be a nice feature to know the begin and end of the flash "NVM" storage space to calculate a checksum to see if there is no corruption of the flash.

        Also a function to get a list of all the names of the parameters would be nice.

        1 Reply Last reply Reply Quote 3
        • bmarkusB Offline
          bmarkus
          last edited by

          I do not know but it may depend on fw version. Also no idea whether stored data survives fw update or not. I'm missing methods

          • get number of total/used indexes
          • get list of keys

          Also there are some smaller issues with retrieving data with non existing keys, etc.

          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