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

    Program is erased from internal memory

    Scheduled Pinned Locked Moved LoPy
    lopyinternal flash
    4 Posts 3 Posters 1.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.
    • joeriJ Offline
      joeri
      last edited by

      I've made a lora sensor node using the Lopy +PyTrack and I'm seeing some weird behaviour which I'm wondering is expected.

      The program itself reads a file from the internal memory, does some sensing, transmits some parameters over LoRa, saves a file again and goes into deep sleep using the pytrack library.

      I think that every time my battery runs out somehow the internal memory is erased/corrupted because when I connect the LoPy over USB the blue LED starts flashing and my boot/main.py and the data folder are gone. After I sync through Atom everything is fine again.

      What could be going on here? The internal flash should be non volatile right?

      I'm writing to the file using

      import json
      
      with open('/data/state.json') as stateFile:
        stateFile.write(json.dumps(state))
      

      And going into deep sleep with

      import pytrack
      
      pytrack.setup_sleep(10)
      pytrack.go_to_sleep()
      
      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @joeri
        last edited by livius

        @joeri
        If you look into history
        you can find same posts as yours.

        I do not know what is the check rule - but if partition is broken in some way it is automatically formated during boot. Then you goot fresh boot.py and main.py

        better is saving to SD card

        think about people first, then computers

        1 Reply Last reply Reply Quote 0
        • joeriJ Offline
          joeri
          last edited by

          Allright. I'll use the SD card. That will increase the power consumption a bit though.

          It has happened a few times already, I can't believe the battery runs out exactly while I'm saving the state (which is just a few bytes)

          1 Reply Last reply Reply Quote 0
          • S Offline
            ssmith
            last edited by

            You need to close the file as soon as the write is complete. If the unit shuts down while the file is open there's a good chance to corrupt the flash. This will erase the flash when it reboots.

            1 Reply Last reply Reply Quote 1

            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