-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
twister: support segger real-time-transfer (rtt) for serial_pty via west #81837
Conversation
f0f5565
to
f71d4f1
Compare
@topisani - it would be great if you could try this out as well. |
Oh wow - the bot made a lot of review requests 😅 |
f71d4f1
to
04de997
Compare
It would be good to also parse the |
04de997
to
9d346ad
Compare
|
Add support for the --rtt-quiet argument, which prevents subprocesses from printing to stdout and stderr, so that rtt messages are the only items printed to standard output. This almnost completely silences the 'west rtt' command with the exception of '-- west rtt: using runner openocd' bring printed on the first line of the output. In order to silence that line from west, the top-level '--quiet' argument must be passed to west. E.g. west -qqqq rtt --rtt-quiet ... Signed-off-by: Chris Friedt <[email protected]>
Add support for the --rtt-quiet argument, which prevents subprocesses from printing to stdout and stderr, so that rtt messages are the only items printed to standard output. This almnost completely silences the 'west rtt' command with the exception of '-- west rtt: using runner openocd' bring printed on the first line of the output. In order to silence that line from west, the top-level '--quiet' argument must be passed to west. E.g. west -qqqq rtt --rtt-quiet ... Signed-off-by: Chris Friedt <[email protected]>
Ensure that --device-serial-pty may be used with --flash-before in order to support capturing test results via RTT console. This is required (at least) for openocd, since the flash (or debug or rtt or any other operation) will fail if an existing process is already in control of the USB device in question. Signed-off-by: Chris Friedt <[email protected]>
Support RTT (Segger Real-time Transfer) for reading console messages with twister when testing with hardware. Tested with: twister -p nucleo_l496zg --device-testing --flash-before \ --west-runner openocd --west-flash --device-serial-pty rtt \ -T samples/hello_world cat twister-out/nucleo_l496zg_stm32l496xx/samples/hello_world/\ sample.basic.helloworld/handler.log *** Booting Zephyr OS build v4.0.0-749-gc9e567da3747 *** Hello World! nucleo_l496zg/stm32l496xx Signed-off-by: Chris Friedt <[email protected]>
9d346ad
to
5e91f54
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update document for this?
@@ -873,6 +873,18 @@ def parse_arguments( | |||
logger.error("west-flash requires device-testing to be enabled") | |||
sys.exit(1) | |||
|
|||
if options.device_serial_pty and options.device_serial_pty == "rtt": | |||
if options.west_flash is None: | |||
logger.error("--device-serial-pty rtt requires --west-flash") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--device-serial-pty
accept a script name, can be anything, here you assume that the script name (is this a script?) is always going to be rtt, or asking that if someone want to use this, they have to call their script rtt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, in this case rtt is a keyword, and twister simply re-uses west's rtt integration.
Normally, the argument for device-serial-pty is a script through, so that hasn't changed.
sys.exit(1) | ||
|
||
# add the following options | ||
options.extra_args += ['CONFIG_USE_SEGGER_RTT=y', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a fan of injecting HW related kconfigs into twister like this, this should be done on the platform/hardware map/ or test level, not in twister. Using a snippet for example is an option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found actually that this works better with a snippet specified in testcase.yml.
I think this can be removed.
@@ -706,6 +707,23 @@ def _get_serial_device(self, serial_pty, hardware_serial): | |||
|
|||
return serial_device, ser_pty_process | |||
|
|||
def _create_serial_pty_script(self, runner): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, so you are creating the pty script on the fly, if I understand this correctly, it is an abuse of the --device-serial-pty
option, we probably need something else to cover this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"abuse" is probably a strong term.
I prefer "reuse" - we're simply reusing west's rtt integration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
device.add_argument("--device-serial-pty",
help="""Script for controlling pseudoterminal.
Twister believes that it interacts with a terminal
when it actually interacts with the script.
E.g "twister --device-testing
--device-serial-pty <script>
Not using a script here is wrong usage. If you want to use a built-in rtt support you are adding, you need to find another way, maybe yet another option that deals with keywords
why close? |
Add initial support for RTT (Segger Real-time Transfer) for reading console messages with
twister
viawest
when testing with hardware.Note
This support should be considered experimental as transfer speed, buffering, buffer size, and buffer count are all tuneable parameters that can vary per-platform and debug adapter. Physical UARTs or other higher-speed I/O interfaces are certainly still the primary means of capturing test output from twister when connected to hardware.
Tested with:
This change set also includes updates to
jlink
andopenocd
west runners to add an--rtt-quiet
option. The new option suppresses thestdout
andstderr
of subprocesses (e.g.JLinkRTTLogger
oropenocd
), which is the expectation for--device-serial-pty
scripts. By suppressing unnecessary output, we can leveragewest rtt
in an automatically generated shell script (as opposed to importing or duplicating more python code intwister
).Currently, the only other RTT-capable west runner is
pyocd
.Additionally, the
DeviceHandler.handle()
method ofhandler.py
is a bit tricky to work with; I was unsuccessful in making separate methods for_do_flash()
and_do_serial()
portions of the operation. That would have simplified the--flash-before
logic. Python was throwing exceptions claiming that code was attempting to adjust objects shared between processes without synchronization. At some point, thehandle()
method should probably be refactored, but it was considered beyond what was necessary for the first draft of this PR.