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

    Command for safe boot

    Scheduled Pinned Locked Moved MicroPython
    safe bootmicropythoncommand
    3 Posts 2 Posters 628 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.
    • A Offline
      alexpul
      last edited by alexpul

      Is it possible to do a safe boot (or a soft reboot) from the command line? I know that you can accomplish these with Ctrl+F and Ctrl+D, respectively, but I would like to include a safe boot in my script so I need a command line option. machine.reset() is a command line reset but it does a hard reset and I don't want main.py and boot.py to run.

      robert-hhR 2 Replies Last reply Reply Quote 1
      • robert-hhR Offline
        robert-hh @alexpul
        last edited by

        @alexpul No, but it would be easy to add something like machine.safe_boot(). It would more or less only consist of the name definition, and a function with a single statement, which just calls another function.

        1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @alexpul
          last edited by robert-hh

          @alexpul But if it's only about not executing boot.py and main.py on boot, you can do similar with python scripts:

          from machine import reset
          def safe_boot.py()
          # create a special main.py and reset
              f= open("no_main.py", "w")
              f.write('''import os\nos.remove("no_main.py")\n''') 
              f.close()
              reset()
          

          and then a specific boot.py, which checks for that special main.py:

          import machine
          import os
          try:
              f = open("no_main.py")
              f.close()
              machine.main("no_main.py")
          except OSError:
              # do the previous boot.py stuff here
          

          Or something similar in you regular boot.py and main.py, which just checks for the existence of a flag for bypassing.

          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