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

    How to store data in flash

    Scheduled Pinned Locked Moved LoPy
    lopyflash
    4 Posts 4 Posters 1.6k Views 4 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.
    • T Offline
      tushar44
      last edited by

      I am modifying the certain parameters at run time via Bluetooth which need to be stored permanently into Lopy module. Please provide method to store data in to flash.

      1 Reply Last reply Reply Quote 0
      • D Offline
        danielm
        last edited by

        I use JSON file for this. In my application class instance the config is a dictionary. You can call json.dumps() on it and write the result into a file.

        Later you can read the string from the file and call json.loads() on the result to "create" config dictionary.

        Consider NVS if storing integers is all you need.

        1 Reply Last reply Reply Quote 0
        • sebS Offline
          seb
          last edited by

          You can access files on the device's flash just like you would any other file in python:

          with open("/flash/my_config.json", 'w') as conf_file:
              conf_file.write(json.dumps(my_config_dict))
          
          with open("/flash/my_config.json", 'r') as conf_file:
              my_config_dict =  json.loads(conf_file.read())
          
          Marco Moraes 0M 1 Reply Last reply Reply Quote 0
          • Marco Moraes 0M Offline
            Marco Moraes 0 @seb
            last edited by Marco Moraes 0

            @seb Is it possible to use this method with encrypted flash? I mean, is application capable of writing/modifying the json file if the flash is encrypted? And if so, does these changes count for those 3 FW flashs overs USB?

            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