scientifichackers / ampy

MicroPython Tool - Utility to interact with a MicroPython board over a serial connection.
MIT License
720 stars 157 forks source link

Add hard reset / boot #38

Closed BoKKeR closed 5 years ago

BoKKeR commented 6 years ago

The current reset command does not execute the boot.py script upon exiting the REPL. Would be nice to add hard reset that would automatically execute boot.py or add the execution of boot.py after entering the REPL.

This dirty hack makes the board the hard reset but it stops the executable from exiting. I am sure that there is a better way to do this.

def reset():
    """Perform soft reset/reboot of the board.

    Will connect to the board and perform a soft reset.  No arguments are
    necessary:

      ampy --port /board/serial/port reset
    """
    # Enter then exit the raw REPL, in the process the board will be soft reset
    # (part of enter raw REPL).
    _board.enter_raw_repl()
    _board.exec_('import machine')
    _board.exec_('machine.reset()') 
    _board.exit_raw_repl()
tannewt commented 6 years ago

Here is the CircuitPython equivalent: https://circuitpython.readthedocs.io/en/2.x/shared-bindings/microcontroller/__init__.html#microcontroller.reset

ladyada commented 5 years ago

Hiya! We are discontinuing support for ampy, and will no longer be maintaining it. We are leaving this repository available for continued use. If you would like to take over supporting it, please contact us on the Adafruit Discord server and we can transfer the repository to you. If you wish to continue developing it on your own, please fork the repository.