From 058e4a59de0fbaf528b2f12bdb34448543b2c4c8 Mon Sep 17 00:00:00 2001 From: Steven Koo Date: Tue, 5 Jul 2022 21:01:28 -0500 Subject: ci: call powerbtn multiple times to power on Signed-off-by: Steven Koo --- .ci/utils/mutex_hardware.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.ci/utils/mutex_hardware.py b/.ci/utils/mutex_hardware.py index e9c102469..485f0fcbd 100644 --- a/.ci/utils/mutex_hardware.py +++ b/.ci/utils/mutex_hardware.py @@ -56,9 +56,11 @@ def flash_sdimage(dev_model, sdimage_path, labgrid_device_yaml, mgmt_addr, sfp_a env = labgrid.Environment(labgrid_device_yaml) target = env.get_target() + cp_scu = target.get_driver(labgrid.protocol.ConsoleProtocol, name="scu_serial_driver") + cp_linux = target.get_driver(labgrid.protocol.ConsoleProtocol, name="linux_serial_driver") + print("Powering down DUT", flush=True) - cp = target.get_driver(labgrid.protocol.ConsoleProtocol, name="scu_serial_driver") - cp.write("\napshutdown\n".encode()) + cp_scu.write("\napshutdown\n".encode()) print("Switching SDMux to Host", flush=True) sdmux = target.get_driver(labgrid.driver.USBSDMuxDriver) @@ -78,10 +80,19 @@ def flash_sdimage(dev_model, sdimage_path, labgrid_device_yaml, mgmt_addr, sfp_a time.sleep(30) print("Powering on DUT", flush=True) - cp.write("\npowerbtn\n".encode()) + cp_scu.write("\npowerbtn\n".encode()) + + try: + cp_linux.expect("Enter 'noautoboot' to enter prompt without timeout", timeout=5) + except Exception: + # Sometimes it requires multiple powerbtn calls to turn on device + print("Device didn't power on with first attempt. Trying again...") + cp_scu.write("\npowerbtn\n".encode()) + cp_linux.expect("Enter 'noautoboot' to enter prompt without timeout", timeout=5) print("Waiting 2 minutes for device to boot", flush=True) time.sleep(120) + cp_linux.expect("login:", timeout=5) known_hosts_path = os.path.expanduser("~/.ssh/known_hosts") subprocess.run(shlex.split(f"ssh-keygen -f \"{known_hosts_path}\" -R \"{mgmt_addr}\"")) -- cgit v1.2.3