8000 Add a way to do a reload from code · Issue #184 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Add a way to do a reload from code #184

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

Closed
deshipu opened this issue Aug 8, 2017 · 10 comments
Closed

Add a way to do a reload from code #184

deshipu opened this issue Aug 8, 2017 · 10 comments

Comments

@deshipu
Copy link
deshipu commented Aug 8, 2017

Sometimes the code might need to do a reset, for example, as a way of recovering from an unexpected exception in a long-running program, or as a way of clearing the state of the device to load a new subprogram.

@tannewt tannewt modified the milestone: 3.0 Aug 14, 2017
@mmabey
Copy link
mmabey commented Sep 18, 2017

@deshipu I don't know if these are the kind of solutions you're looking for, but MicroPython has a reset() function as well as something called a watchdog timer. Perhaps @tannewt can comment on the likelihood that one or both of these could be ported over to CP.

@Andon-A
Copy link
Andon-A commented Nov 27, 2017

This would be super-useful in a few of the examples that I am planning for #345

@tannewt
Copy link
Member
tannewt commented Dec 5, 2017

You mean to reload the program right? A reset would do a fully reinitialization of the microcontroller and stop USB when available.

@deshipu
Copy link
Author
deshipu commented Dec 5, 2017

I mean the same thing that ctrl+d does in REPL.

@tannewt tannewt changed the title Add a way to do a reset from code Add a way to do a reload from code Dec 5, 2017
@tannewt
Copy link
Member
tannewt commented Dec 5, 2017

OK, I call that reload.

The tricky part here is that we want to exit the existing code and immediately re-run it. Normally, we'd go into our wait state with the status led fading in and out.

@caternuson
Copy link

It'd also be useful if a file to run on reset could be specified. This would let people use this in main.py to specify a different file to run and eliminate the need to rename. Or it could be used in a more complex way like a menu system to allow selecting one of the other .py files to be run programmatically.

@deshipu
Copy link
Author
deshipu commented Apr 2, 2018

So here is a stupid idea, but maybe it has something useful in it. A lot of people have problems with how the CircuitPython starts and what gets run when and so on — there is a lot of hidden stuff with the boot.py and main.py and all the other details. What if we simplified this by making it visible instead?

We could auto-create the boot.py file, and by default have the USB setup and filesystem-mounting commands in it, and also the "reset and run" command. This way people can actually see this, and experiment with it, without having to read about it in the tutorial. In the worst case, they at least have some keywords to look for in the documentation. The boot.py file could be re-created from the template each time it is deleted and the board is powered on — so that people can easily fix it if they "break" it.

@tannewt
Copy link
Member
tannewt commented Apr 2, 2018

@deshipu thats a great idea! Mind filing a separate issue for it?

@rhooper
Copy link
rhooper commented May 14, 2018

I'm going to have a look at this.

@tannewt
Copy link
Member
tannewt commented May 16, 2018

Fixed by @rhooper in #838. Thank you!

@tannewt tannewt closed this as completed May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
0