Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various minor enhancements for the 'console' command #1571

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

sjg20
Copy link
Contributor

@sjg20 sjg20 commented Jan 20, 2025

Provides an internal console and a way to automatically select a final state

The internal console avoids the problem of losing output when labgrid closes the serial port and re-opens it in the switch from to microcom.

The final state can be used to ensure that the board is off after use, without needing to run labgrid-client again. It is similar to the initial state in that sense.

Together, this PR allows 'labgrid client' to function as a console device suitable for use with U-Boot's test.py, for example

See here for how this is used in a real lab:

https://ci.u-boot.org/u-boot/u-boot/-/jobs/19119

Checklist

  • [] Documentation for the feature
  • Tests for the feature
  • Add a section on how to use the feature to doc/usage.rst
  • PR has been tested
  • Man pages have been regenerated

sjg20 added 10 commits January 20, 2025 15:13
It is common to acquire a place and then use it to access the console.
Add a -a option to support this, to avoid running labgrid-client twice,
which takes longer and makes error handling harder.

If the place is acquired, it is released on exit.

Signed-off-by: Simon Glass <sjg@chromium.org>
Some messages are printed regardless of the logging level. Convert them
to logging statements so they can be suppressed.

Signed-off-by: Simon Glass <sjg@chromium.org>
When a command fails in labgrid-client it just shows the return code.
This makes it very hard to see what actually went wrong. Handle this
exception explicitly, showing the output of the tool which failed. This
allows easy debugging of the problem.

This is particularly important with things like USB loaders.

Signed-off-by: Simon Glass <sjg@chromium.org>
When a target may or may not be acquired, it is useful to be able to
release it without checking first. Add an option for this, so that it
is not necessary to check first.

Signed-off-by: Simon Glass <sjg@chromium.org>
Use logging rather than print so that this output can be controlled.

Signed-off-by: Simon Glass <sjg@chromium.org>
At present if a console device is used by a strategy driver it is then
removed by the client immediately afterwards. If the 'console' command
is used, this means that any console data is lost.

This is done so that the console device is release for microcom, so
move the logic in with the microcom logic. With the forthcoming internal
terminal, it will not be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
Put this code into a function to reduce the size of the _get_target()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
It is possible to set the initial state of a strategy, but not the final
state. In many cases we want to power the board off and otherwise clean
things up at the end. Provide a -e option to accomplish this.

Signed-off-by: Simon Glass <sjg@chromium.org>
There is quite a lot of code here, so move the terminal function into
its own file. This will make it easier to extend it later.

Signed-off-by: Simon Glass <sjg@chromium.org>
At present Labgrid uses microcom as its console. This has some
limitations:

- console output is lost between when the board is reset and microcom
  connects
- txdelay cannot be handled in microcom, meaning that boards may fail
  to receive expected output
- the console may echo a few characters back to the caller in the time
  between when 'labgrid-client console' is executed and when microcom
  starts (which causes failures with U-Boot test system)

For many use cases, microcom is more than is needed, so provide a simple
internal terminal which resolved the above problems.

It is enabled by a '-i' option to the 'console' command, as well as an
environment variable, so that it can be adjustly without updating a lot
of scripts.

To exit, press Ctrl-] twice, quickly.

Series-changes: 4
- Get internal console working with qemu
- Show a prompt when starting, to indicate it is waiting for the board

Signed-off-by: Simon Glass <sjg@chromium.org>
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.

1 participant