[PATCH] board.linux: make linux login more robust

Heiko Schocher hs at denx.de
Mon Mar 30 07:56:24 CEST 2020


There is already the login_delay parameter, which
helps to make login more robust if console is
flooded on boot up time.

tbot waits for the string "login: " and expects that
there are no more characters after it. But in case the
console get flooded with characters on boot up time,
it can happen that there are characters in the same line
after "login: ".

Currently, read_until_prompt waits endless, when trying
to get "login: " and so tbot never login into linux.

rework this part, so read_until_prompt waits "login_delay"
seconds, and after that, trigger a new login prompt.

Signed-off-by: Heiko Schocher <hs at denx.de>
---

 tbot/machine/board/linux.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/tbot/machine/board/linux.py b/tbot/machine/board/linux.py
index 1e76b28..942cee5 100644
--- a/tbot/machine/board/linux.py
+++ b/tbot/machine/board/linux.py
@@ -105,17 +105,18 @@ class LinuxBootLogin(machine.Initializer, LinuxBoot):
             ev = cx.enter_context(self._linux_boot_event())
             cx.enter_context(self.ch.with_stream(ev))
 
-            self.ch.read_until_prompt(prompt=self.login_prompt)
-
             # On purpose do not login immediately as we may get some
             # console flooding from upper SW layers (and tbot's console
             # setup may get broken)
             if self.login_delay != 0:
-                try:
-                    self.ch.read(timeout=self.login_delay)
-                except TimeoutError:
-                    pass
-                self.ch.sendline("")
+                while 1:
+                    try:
+                        self.ch.read_until_prompt(prompt=self.login_prompt, timeout=self.login_delay)
+                        break
+                    except TimeoutError:
+                        self.ch.sendline("")
+                        pass
+            else:
                 self.ch.read_until_prompt(prompt=self.login_prompt)
 
             self.ch.sendline(self.username)
-- 
2.24.1



More information about the tbot mailing list