Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,7 @@ Arguments:
- boot_commands (dict, default={}): boot commands by name for LinuxBootProtocol boot command
- login_timeout (int, default=30): timeout for login prompt detection in seconds
- boot_timeout (int, default=30): timeout for initial Linux Kernel version detection
- strip_timestamp (bool, default=False): strip timestamps prepended to console when present

SmallUBootDriver
~~~~~~~~~~~~~~~~
Expand Down
11 changes: 10 additions & 1 deletion labgrid/driver/ubootdriver.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""The U-Boot Module contains the UBootDriver"""
import re
import attr
from pexpect import TIMEOUT

from ..factory import target_factory
from ..protocol import CommandProtocol, ConsoleProtocol, LinuxBootProtocol
from ..util import gen_marker, Timeout, re_vt100
from ..util import gen_marker, re_vt100, Timeout
from ..step import step
from .common import Driver
from .commandmixin import CommandMixin

re_uboot_timestamp = re.compile(r"^\[\s+\d+\.\d+\]\s*")

@target_factory.reg_driver
@attr.s(eq=False)
Expand All @@ -28,6 +30,7 @@ class UBootDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
boot_command (str): optional boot command to boot target
login_timeout (int): optional, timeout for login prompt detection
boot_timeout (int): optional, timeout for initial Linux Kernel version detection
strip_timestamp (bool, default=False): strip timestamps prepended to console when present

"""
bindings = {"console": ConsoleProtocol, }
Expand All @@ -43,6 +46,7 @@ class UBootDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
boot_commands = attr.ib(default=attr.Factory(dict), validator=attr.validators.instance_of(dict))
login_timeout = attr.ib(default=30, validator=attr.validators.instance_of(int))
boot_timeout = attr.ib(default=30, validator=attr.validators.instance_of(int))
strip_timestamp = attr.ib(default=False, validator=attr.validators.instance_of(bool))

def __attrs_post_init__(self):
super().__attrs_post_init__()
Expand Down Expand Up @@ -79,6 +83,11 @@ def _run(self, cmd: str, *, timeout: int = 30, codec: str = "utf-8", decodeerror
data = re_vt100.sub(
'', before.decode('utf-8'), count=1000000
).replace("\r", "").split("\n")

# Strip possible U-Boot timestamps from the line
if self.strip_timestamp:
data = [re_uboot_timestamp.sub('', line) for line in data]

self.logger.debug("Received Data: %s", data)
# Remove first element, the invoked cmd
data = data[data.index(marker) + 1:]
Expand Down
Loading