8000 Add pyb.soft_reset() and pyb.hard_reset() commands. by dhylands · Pull Request #826 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

Add pyb.soft_reset() and pyb.hard_reset() commands. #826

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
wants to merge 1 commit into from

Conversation

dhylands
Copy link
Contributor

These will also be useful for code which performs updates (over wireless or serial for example) and the code then want to simuate a hard or soft reset to execute the new code.

@dhylands
Copy link
Contributor Author

Here's my sample coe (requires #828)
https://github.com/dhylands/upy-examples/blob/master/sd_check.py

You can press and hold RETURN to abort the script. It will stop by itself (well it will run boot.py & main.py from internal flash) if it doesn't detect the sdcard.

@dhylands
Copy link
Contributor Author

I had this in my /sd/boot.py:

import pyb

uart = pyb.UART(6,115200)
pyb.repl_uart(uart)

and copied sd_check.py to /sd/main.py

Then do a Control-D or hard-reset to start

@s-hell
Copy link
s-hell commented Oct 19, 2014

Yeah, that would be great!

@dpgeorge
Copy link
Member

Sorry, I'll get to this eventually :)

@dpgeorge
Copy link
Member

@dhylands now that the SD card issue is (hopefully) fixed, do you still think adding soft_reset and hard_reset is useful?

For soft_reset, it might be cleaner to implement it using the SystemExit exception. Then you can do sys.exit() for a soft reset (or raise SystemExit). Then it doesn't need a global variable.

@dhylands
Copy link
Contributor Author

I still think that the soft/hard reset is useful from the perspective of
having tools that install source code on the pyboard.

After installing the new software, then a soft or hard reset can be
performed to get things running with the newly updated code. This will be
especially useful when you're talking over some wireless link to the
pyboard and may not be in the proximity of the physical board.

I don't mind reworking the soft-reset to use the SystemExit exception.

I think that means that we need a nlr_push/pop in main.c around the call to
boot.py and around these lines:
https://github.com/micropython/micropython/blob/master/stmhal/main.c#L510-L538
and parse_compile_execute needs to pass along the SystemExit and not just
consume it (which is what it does now).

On Tue, Oct 21, 2014 at 2:53 PM, Damien George notifications@github.com
wrote:

@dhylands https://github.com/dhylands now that the SD card issue is
(hopefully) fixed, do you still think adding soft_reset and hard_reset is
useful?

For soft_reset, it might be cleaner to implement it using the SystemExit
exception. Then you can do sys.exit() for a soft reset (or raise
SystemExit). Then it doesn't need a global variable.


Reply to this email directly or view it on GitHub
#826 (comment)
.

Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com

@dpgeorge
Copy link
Member

No need to add any more nlr push/pop. Just rework parse_compile_execute so that it returns 1 of 3 states: ok, exit, other-exception. Then anyone who calls parse_compile_execute must deal with that return value correctly (this is easy, it's already set up for this).

@dpgeorge
Copy link
Member

See unix/main.c for how it checks for and deals with SystemExit.

@dpgeorge
Copy link
Member

Superseded by #924.

@dpgeorge dpgeorge closed this Oct 22, 2014
@dhylands dhylands deleted the hard-soft-reset branch November 8, 2015 02:41
tannewt added a commit to tannewt/circuitpython that referenced this pull request May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0