[PATCH 39/42] test: Avoid double echo when starting up

Simon Glass sjg at chromium.org
Tue Jun 11 22:01:53 CEST 2024


There is a very annoying bug at present where the terminal echos part
of the first command sent to the board. This happens because the
terminal is still set to echo for a period until Labgrid starts up and
can change this.

Fix this by disabling echo (and other terminal features) as soon as the
spawn happens.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 test/py/u_boot_spawn.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index 62eb4118731..261bdf62e15 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -12,6 +12,7 @@ import pytest
 import signal
 import select
 import sys
+import termios
 import time
 import traceback
 
@@ -118,10 +119,19 @@ class Spawn:
                 os._exit(255)
 
         try:
+            new = termios.tcgetattr(self.fd)
+            old = new
+            new[3] = new[3] & ~(termios.ICANON | termios.ISIG)
+            new[3] = new[3] & ~termios.ECHO
+            new[6][termios.VMIN] = 0
+            new[6][termios.VTIME] = 0
+            termios.tcsetattr(self.fd, termios.TCSANOW, new)
+
             self.poll = select.poll()
             self.poll.register(self.fd, select.POLLIN | select.POLLPRI | select.POLLERR |
                                select.POLLHUP | select.POLLNVAL)
         except:
+            termios.tcsetattr(self.fd, termios.TCSANOW, old)
             self.close()
             raise
 
-- 
2.34.1



More information about the U-Boot mailing list