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



  • 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)



  • 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.



  • 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.


 

Pycom on Twitter