tools/pyboard.py: Add "soft_reset" option to Pyboard.enter_raw_repl().
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
4982d0920e
commit
e4ba57c5cd
@ -322,7 +322,7 @@ class Pyboard:
|
||||
time.sleep(0.01)
|
||||
return data
|
||||
|
||||
def enter_raw_repl(self):
|
||||
def enter_raw_repl(self, soft_reset=True):
|
||||
self.serial.write(b"\r\x03\x03") # ctrl-C twice: interrupt any running program
|
||||
|
||||
# flush input (without relying on serial.flushInput())
|
||||
@ -332,18 +332,23 @@ class Pyboard:
|
||||
n = self.serial.inWaiting()
|
||||
|
||||
self.serial.write(b"\r\x01") # ctrl-A: enter raw REPL
|
||||
data = self.read_until(1, b"raw REPL; CTRL-B to exit\r\n>")
|
||||
if not data.endswith(b"raw REPL; CTRL-B to exit\r\n>"):
|
||||
print(data)
|
||||
raise PyboardError("could not enter raw repl")
|
||||
|
||||
self.serial.write(b"\x04") # ctrl-D: soft reset
|
||||
data = self.read_until(1, b"soft reboot\r\n")
|
||||
if not data.endswith(b"soft reboot\r\n"):
|
||||
print(data)
|
||||
raise PyboardError("could not enter raw repl")
|
||||
# By splitting this into 2 reads, it allows boot.py to print stuff,
|
||||
# which will show up after the soft reboot and before the raw REPL.
|
||||
if soft_reset:
|
||||
data = self.read_until(1, b"raw REPL; CTRL-B to exit\r\n>")
|
||||
if not data.endswith(b"raw REPL; CTRL-B to exit\r\n>"):
|
||||
print(data)
|
||||
raise PyboardError("could not enter raw repl")
|
||||
|
||||
self.serial.write(b"\x04") # ctrl-D: soft reset
|
||||
|
||||
# Waiting for "soft reboot" independently to "raw REPL" (done below)
|
||||
# allows boot.py to print, which will show up after "soft reboot"
|
||||
# and before "raw REPL".
|
||||
data = self.read_until(1, b"soft reboot\r\n")
|
||||
if not data.endswith(b"soft reboot\r\n"):
|
||||
print(data)
|
||||
raise PyboardError("could not enter raw repl")
|
||||
|
||||
data = self.read_until(1, b"raw REPL; CTRL-B to exit\r\n")
|
||||
if not data.endswith(b"raw REPL; CTRL-B to exit\r\n"):
|
||||
print(data)
|
||||
|
Loading…
Reference in New Issue
Block a user