[U-Boot] [PATCH 3/6] test/py: limit outstanding TX data
Stephen Warren
swarren at wwwdotorg.org
Wed Nov 18 04:20:01 CET 2015
U-Boot echoes back all characters it receives on the console. At best,
with zero overhead, it could keep up with the incoming data stream.
However, in practice there's always some delay between receiving a
character from the RX side of the console and handing it off to the TX
side of the console, which means the TX patch cannot keep up with the RX
path. This is particularly true due to U-Boot's unbuffered polling IO
model. This is exacerbated when the target performs slow operations for
each character, such as drawing on the LCD.
When sending large command-lines, larger than the UART HW's RX FIFO size,
this issue can lead to dropped characters, and hence test failures.
To work around this, modify the test scripts to that they limit the number
of outstanding characters, i.e. those sent to the target but not yet
echo'd back. This avoids
Signed-off-by: Stephen Warren <swarren at wwwdotorg.org>
---
test/py/uboot_console_base.py | 27 ++++++++++++---------------
test/py/uboot_console_exec_attach.py | 6 +++++-
test/py/uboot_console_sandbox.py | 2 +-
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/test/py/uboot_console_base.py b/test/py/uboot_console_base.py
index dfd986860e75..4bf9e8303633 100644
--- a/test/py/uboot_console_base.py
+++ b/test/py/uboot_console_base.py
@@ -21,9 +21,10 @@ class ConsoleDisableCheck(object):
self.console.disable_check_count[self.check_type] -= 1
class ConsoleBase(object):
- def __init__(self, log, config):
+ def __init__(self, log, config, max_fifo_fill):
self.log = log
self.config = config
+ self.max_fifo_fill = max_fifo_fill
self.logstream = self.log.get_stream("console", sys.stdout)
@@ -63,22 +64,19 @@ class ConsoleBase(object):
bad_patterns.append(pattern_error_notification)
bad_pattern_ids.append("Error notification")
try:
- if cmd:
- self.p.send(cmd)
- try:
- m = self.p.expect([re.escape(cmd)] + bad_patterns)
- if m != 0:
- self.at_prompt = False
- raise Exception("Bad pattern found on console: " +
- bad_pattern_ids[m - 1])
- except Exception as ex:
+ self.at_prompt = False
+ while cmd:
+ # Limit max outstanding data, so UART FIFOs don't overflow
+ chunk = cmd[:self.max_fifo_fill]
+ cmd = cmd[self.max_fifo_fill:]
+ self.p.send(chunk)
+ m = self.p.expect([re.escape(chunk)] + bad_patterns)
+ if m != 0:
self.at_prompt = False
- print cmd
- self.logstream.write(cmd, implicit=True)
- raise
+ raise Exception("Bad pattern found on console: " +
+ bad_pattern_ids[m - 1])
self.p.send("\n")
if not wait_for_prompt:
- self.at_prompt = False
return
m = self.p.expect([self.prompt_escaped] + bad_patterns)
if m != 0:
@@ -88,7 +86,6 @@ class ConsoleBase(object):
self.at_prompt = True
return self.p.before.strip()
except Exception as ex:
- self.at_prompt = False
self.log.error(str(ex))
self.cleanup_spawn()
raise
diff --git a/test/py/uboot_console_exec_attach.py b/test/py/uboot_console_exec_attach.py
index 7960d66107c3..0beaa4fe7102 100644
--- a/test/py/uboot_console_exec_attach.py
+++ b/test/py/uboot_console_exec_attach.py
@@ -7,7 +7,11 @@ def cmdline(app, args):
class ConsoleExecAttach(ConsoleBase):
def __init__(self, log, config):
- super(ConsoleExecAttach, self).__init__(log, config)
+ # The max_fifo_fill value might need tweaking per-board/-SoC?
+ # 1 would be safe anywhere, but is very slow (a pexpect issue?).
+ # 16 is a common FIFO size.
+ # HW flow control would mean this could be infinite.
+ super(ConsoleExecAttach, self).__init__(log, config, max_fifo_fill=16)
self.log.action("Flashing U-Boot")
cmd = ["uboot-test-flash", config.board_type, config.board_identity]
diff --git a/test/py/uboot_console_sandbox.py b/test/py/uboot_console_sandbox.py
index c3aae3862ca9..ed3ffa5b90b1 100644
--- a/test/py/uboot_console_sandbox.py
+++ b/test/py/uboot_console_sandbox.py
@@ -4,7 +4,7 @@ from uboot_console_base import ConsoleBase
class ConsoleSandbox(ConsoleBase):
def __init__(self, log, config):
- super(ConsoleSandbox, self).__init__(log, config)
+ super(ConsoleSandbox, self).__init__(log, config, max_fifo_fill=1024)
def get_spawn(self):
return pexpect.spawn(self.config.build_dir + "/u-boot")
--
1.9.1
More information about the U-Boot
mailing list