-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Introduce machine.soft_reset() #2508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's not that easy to implement. Simplest thing would be to do what was previously done with SystemExit: machine.soft_reset() would set a special flag saying that there should be a soft reset, and then it would raise SystemExit. Assuming the script does not intercept the exception, it would propagate to the pyexec function, which needs to then return another special value (like it did before) to indicate to the caller that SystemExit was raised. Then finally the caller would check the soft reset flag and do a soft reset. |
So, do we want to leave this for after 1.8.5? |
I'd rather not have this feature missing (at least for pyboard/stmhal) in a release. I'll try to add something that at least works, and we can have further discussion later if needed. |
It isn't clear to me what the desired sys.exit() behaviour should be (aside from what it currently is) for something like the pyboard. I think that under unix, it should quit the app. |
Same for any other port. |
which is what exactly? There are 2 different classes of machines here, one where you have the ability to exit the process (i.e. unix) and one where you don't (i.e. the pyboard doesn't have the notion of a process). |
Actually, under linux, sys.exit() doesn't "drop to command line" unless the caller happens to be a shell. And since there is no command line on the pyboard what exactly does "drop to the command line" mean? |
It means the behavior of the current micropython master. |
Now I'm totally confused. You want to change the behaviour of sys.exit() to be what it currently is? |
The point is that sys.exit() (and hence raise SystemExit) should just "stop the running code" / "quit the app", and shouldn't lead to extra behaviour like restarting the board and rerunning start-up scripts, for example. This distinction was not really a problem with pyboard, but with the esp8266 it can't properly handle a soft reset, and soft-resetting in WebREPL doesn't work at all (because the start-up scripts initialise the WebREPL). As such, we need to make the behaviour of SystemExit more fine-grained / decomposed: the exiting of the script/app should be independent to an actual soft reset. So SystemExit will now just finish the script (and drop to a REPL on bare-metal, since there's not much else it can do). See ad3724e and 57226a2 for implementation of machine.soft_reset() in stmhal. We can factor that out to all ports when we agree on the behaviour (and keep this ticket open until then). |
Agree to introduce soft_reset for esp32. 👍 Thanks, |
As discussed in #2495
The text was updated successfully, but these errors were encountered: