From 519cef813eff8a44d8f112cce5bcb07008ddbc98 Mon Sep 17 00:00:00 2001
From: Dave Hylands <dhylands@gmail.com>
Date: Thu, 3 Dec 2015 16:05:53 -0800
Subject: [PATCH] tools: Allow pyboard.py to work when boot.py prints things.

---
 tools/pyboard.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/pyboard.py b/tools/pyboard.py
index 92c8d939a..510f61be6 100755
--- a/tools/pyboard.py
+++ b/tools/pyboard.py
@@ -165,8 +165,14 @@ class Pyboard:
             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\nraw REPL; CTRL-B to exit\r\n')
-        if not data.endswith(b'soft reboot\r\nraw REPL; CTRL-B to exit\r\n'):
+        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.
+        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')
 
-- 
GitLab