Skip to content

ubootdriver: optionally strip timestamps#1816

Merged
jluebbe merged 2 commits intolabgrid-project:masterfrom
threexc:tgamblin/strip-uboot-timestamps
Feb 6, 2026
Merged

ubootdriver: optionally strip timestamps#1816
jluebbe merged 2 commits intolabgrid-project:masterfrom
threexc:tgamblin/strip-uboot-timestamps

Conversation

@threexc
Copy link
Copy Markdown
Contributor

@threexc threexc commented Feb 3, 2026

Some U-Boot configurations may prepend timestamps to the beginning of every line during early boot, and at the prompt, e.g.:

|[ 2.397] Failed to get fastboot key config: -19
|[ 2.402] sdh@d4280000: 74 clk wait timeout(100)
|[ 2.405] MMC: no card present
|[ 2.408] mmc_init: -123, time 7
|[ 2.412] Net: RGMII interface
|[ 2.414] eth0: ethernet@cac80000
|[ 2.420] Autoboot in 5 seconds
|=>
|=> [ 4.878]
|=> [ 5.920]
|=> [ 503.743] d
|=> [ 505.712]

Unfortunately, this means that strategies may not behave as expected when trying to run commands, as labgrid's console.expect() function will always find the timestamp in addition to the check strings it sends. Handle this by adding the strip_timestamps boolean option for UBootDriver, which (if enabled) strips any timestamps found prepended to output lines.

Test results with tox:

================================================================================================== 363 passed, 41 skipped, 231 warnings in 195.01s (0:03:15) ==================================================================================================
py39: SKIP (0.17 seconds)
py310: SKIP (0.01 seconds)
py311: SKIP (0.01 seconds)
py312: SKIP (0.01 seconds)
py313: SKIP (0.36 seconds)
py314: OK (211.12=setup[15.06]+cmd[196.06] seconds)
congratulations :) (211.71 seconds)

Checklist

  • Documentation for the feature
  • Tests for the feature
  • The arguments and description in doc/configuration.rst have been updated
  • Add a section on how to use the feature to doc/usage.rst
  • Add a section on how to use the feature to doc/development.rst
  • PR has been tested - tested by proving it works with a known broken setup on my OrangePi RV2

@threexc threexc force-pushed the tgamblin/strip-uboot-timestamps branch from 7aa5d98 to 4ae5d55 Compare February 3, 2026 20:27
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.2%. Comparing base (38d41d5) to head (cde25ad).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/ubootdriver.py 66.6% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1816   +/-   ##
======================================
  Coverage    45.2%   45.2%           
======================================
  Files         174     174           
  Lines       13747   13752    +5     
======================================
+ Hits         6221    6224    +3     
- Misses       7526    7528    +2     
Flag Coverage Δ
3.10 45.2% <66.6%> (+<0.1%) ⬆️
3.11 45.2% <66.6%> (+<0.1%) ⬆️
3.12 45.2% <66.6%> (+<0.1%) ⬆️
3.13 45.2% <66.6%> (+<0.1%) ⬆️
3.14 45.2% <66.6%> (+<0.1%) ⬆️
3.9 45.3% <66.6%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@khilman
Copy link
Copy Markdown
Contributor

khilman commented Feb 3, 2026

Tested this on a MusePi-Pro board, with SpacemiT K1 SoC that has vendor u-boot that spits out u-boot timestamps in unpredictable ways. This series fixes the problem for me. Thanks!

Tested-by: Kevin Hilman khilman@baylibre.com

Copy link
Copy Markdown
Member

@jluebbe jluebbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good otherwise.

Comment thread labgrid/util/helper.py Outdated
@threexc threexc force-pushed the tgamblin/strip-uboot-timestamps branch 2 times, most recently from 05c35cf to 7e15c72 Compare February 6, 2026 17:09
@threexc
Copy link
Copy Markdown
Contributor Author

threexc commented Feb 6, 2026

@jluebbe thanks, should be good to go now.

I guess I still have my alphabetized import change in there, even though the regex has been moved. Would you like me to fix that?

Some U-Boot configurations may prepend timestamps to the beginning of
every line during early boot, and at the prompt, e.g.:

|[   2.397] Failed to get fastboot key config: -19
|[   2.402] sdh@d4280000: 74 clk wait timeout(100)
|[   2.405] MMC: no card present
|[   2.408] mmc_init: -123, time 7
|[   2.412] Net:   RGMII interface
|[   2.414] eth0: ethernet@cac80000
|[   2.420] Autoboot in 5 seconds
|=>
|=> [   4.878] <INTERRUPT>
|=> [   5.920] <INTERRUPT>
|=> [ 503.743] d<INTERRUPT>
|=> [ 505.712]  <INTERRUPT>

Unfortunately, this means that strategies may not behave as expected
when trying to run commands, as labgrid's console.expect() function will
always find the timestamp in addition to the check strings it sends.
Handle this by adding a strip_timestamp boolean option to the
UBootDriver, which if enabled strips timestamps from received lines when
found.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
@threexc threexc force-pushed the tgamblin/strip-uboot-timestamps branch from 7e15c72 to cde25ad Compare February 6, 2026 17:36
@threexc
Copy link
Copy Markdown
Contributor Author

threexc commented Feb 6, 2026

I've pushed one more time, because the commit message for the UBootDriver had strip_timestamp pluralized when the actual setting and docs weren't.

@jluebbe jluebbe merged commit 228e2e0 into labgrid-project:master Feb 6, 2026
12 checks passed
@threexc
Copy link
Copy Markdown
Contributor Author

threexc commented Feb 9, 2026

Thanks for merging this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants