Skip to content

Commit 3347a37

Browse files
golowanowabhinavnxp
authored andcommitted
twister: Enable 'flash-before' mode on serial-pty
Enable `flash-before` mode for devices connected via serial-pty the same way, as for physical serial. This mode allows Twister to start reading from the DUT's serial connection only after the flashing stage has been completed, thus excluding an early part of the log stream not directly related to the current test. It can help in situations, when the device is connected via some serial-over-network harness which is still transferring device logs or keeping in its buffer a tail with different RunID etc. from the previous test image run. Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
1 parent 637cdc5 commit 3347a37

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

scripts/pylib/twister/twisterlib/environment.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
222222
help="""Flash device before attaching to serial port.
223223
This is useful for devices that share the same port for programming
224224
and serial console, or use soft-USB, where flash must come first.
225+
Also, it skips reading remaining logs from the old image run.
225226
""")
226227

227228
test_or_build.add_argument(
@@ -971,10 +972,6 @@ def parse_arguments(
971972
logger.error("--device-flash-with-test does not apply when --flash-before is used")
972973
sys.exit(1)
973974

974-
if options.flash_before and options.device_serial_pty:
975-
logger.error("--device-serial-pty cannot be used when --flash-before is set (for now)")
976-
sys.exit(1)
977-
978975
if options.shuffle_tests and options.subset is None:
979976
logger.error("--shuffle-tests requires --subset")
980977
sys.exit(1)

scripts/pylib/twister/twisterlib/hardwaremap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def discover(self):
212212
True,
213213
flash_timeout=self.options.device_flash_timeout,
214214
flash_with_test=self.options.device_flash_with_test,
215-
flash_before=False,
215+
flash_before=self.options.flash_before,
216216
)
217217

218218
# the fixtures given by twister command explicitly should be assigned to each DUT
@@ -275,7 +275,7 @@ def load(self, map_file):
275275
serial_pty = dut.get('serial_pty')
276276
flash_before = dut.get('flash_before')
277277
if flash_before is None:
278-
flash_before = self.options.flash_before and (not (flash_with_test or serial_pty))
278+
flash_before = self.options.flash_before and (not flash_with_test)
279279
platform = dut.get('platform')
280280
if isinstance(platform, str):
281281
platforms = platform.split()

0 commit comments

Comments
 (0)