diff --git a/examples/storage/fatfsgen/pytest_fatfsgen_example.py b/examples/storage/fatfsgen/pytest_fatfsgen_example.py index 44feb2bcbe9..7aae306e62b 100644 --- a/examples/storage/fatfsgen/pytest_fatfsgen_example.py +++ b/examples/storage/fatfsgen/pytest_fatfsgen_example.py @@ -6,6 +6,7 @@ import shutil import sys import typing as t from datetime import datetime +from subprocess import CalledProcessError from subprocess import run from subprocess import STDOUT from time import sleep @@ -202,8 +203,18 @@ def test_examples_fatfsgen(config: str, dut: Dut) -> None: dut.serial.close() sleep(1) - target = ParttoolTarget(dut.serial.port, 1843200) - target.read_partition(PartitionName('storage'), 'temp.img') + # Host read-flash after closing the test UART can fail at very high baud (e.g. exit code 2 on + # multi-Mbit reads). Use the same order of magnitude as post-stub flash programming (921600). + read_baud = 921600 + for attempt in range(3): + try: + target = ParttoolTarget(dut.serial.port, read_baud) + target.read_partition(PartitionName('storage'), 'temp.img') + break + except CalledProcessError: + if attempt == 2: + raise + sleep(2) if config_long_names: run(['python', fatfs_parser_path, '--long-name-support', 'temp.img'], stderr=STDOUT) else: