Command for safe boot
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
robert-hh 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.
robert-hh 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.