diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-06-08 15:13:37 -0500 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-09 17:53:09 +0000 |
commit | e9399b9b4e00f3ab1ab09eeee62e3044725e5980 (patch) | |
tree | 8720e5714fd41d3f62edb3e703d7b9aca37b50f8 | |
parent | cd8c9a3e940edc52144691bc4e0488dd0c8ef527 (diff) | |
download | chrome-ec-stabilize-14026.B-cr50_stab.tar.gz |
flash_cr50: add support to reboot with the consolestabilize-14026.B-cr50_stab
If cr50 is open, flash_cr50 can just run 'reboot' on the cr50 console to
reboot cr50. Add support for doing that.
BUG=none
TEST=flash_cr50.py -p 9999 -i $IMG -c cr50-rescue -r console_reboot
Change-Id: Ibe0d7f98c64faf7f0ac35b04dfad89ad58333cac
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2945957
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Commit-Queue: Namyoon Woo <namyoon@chromium.org>
-rwxr-xr-x | util/flash_cr50.py | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/util/flash_cr50.py b/util/flash_cr50.py index d94ef7fb6e..5af6f0ac14 100755 --- a/util/flash_cr50.py +++ b/util/flash_cr50.py @@ -26,6 +26,8 @@ import tempfile import threading import time +import serial + from chromite.lib import cros_build_lib from chromite.lib import cros_logging as logging @@ -58,6 +60,7 @@ REQUIRED_CONTROLS = { # Supported methods to resetting cr50. SUPPORTED_RESETS = ( 'battery_cutoff', + 'console_reboot', 'cr50_reset_odl', 'manual_reset', ) @@ -468,6 +471,30 @@ class ManualReset(Cr50Reset): logging.warning('User input timeout: assuming cr50 reset') +class ConsoleReboot(Cr50Reset): + """Class for using a manual reset to reset Cr50.""" + + REQUIRED_SETUP = ( + # Rescue is done through Cr50 uart. It requires a flex cable not ccd. + 'flex', + # Cr50 rescue is done through cr50 uart. + 'cr50_uart', + ) + REBOOT_CMD = '\n\nreboot\n\n' + + def run_reset(self): + """Nothing to do.""" + pass + + def recover_from_reset(self): + """Run reboot on the cr50 console.""" + # EC3PO is disconnected. Send reboot to the raw pty. + raw_pty = self._servo.dut_control('raw_cr50_uart_pty')[1] + logging.info('Sending cr50 reboot command %r', self.REBOOT_CMD) + with serial.Serial(raw_pty, timeout=1) as ser: + ser.write(self.REBOOT_CMD.encode('utf-8')) + + class FlashCr50(object): """Class for updating cr50.""" @@ -553,17 +580,17 @@ class GsctoolUpdater(FlashCr50): '0xc': 'Board id mismatch', } - def __init__(self, cmd, serial=None): + def __init__(self, cmd, usb_ser=None): """Generate the gsctool command. Args: cmd: gsctool updater command. - serial: The serial number of the CCD device being updated. + usb_ser: The usb_ser number of the CCD device being updated. """ super(GsctoolUpdater, self).__init__(cmd) self._gsctool_cmd = [self._updater] - if serial: - self._gsctool_cmd.extend(['-n', serial]) + if usb_ser: + self._gsctool_cmd.extend(['-n', usb_ser]) def update(self, image): """Use gsctool to update cr50. @@ -629,6 +656,8 @@ class Cr50RescueUpdater(FlashCr50): assert reset_type in SUPPORTED_RESETS, '%s is unsupported.' % reset_type if reset_type == 'battery_cutoff': return BatteryCutoffReset(self._servo, reset_type) + elif reset_type == 'console_reboot': + return ConsoleReboot(self._servo, reset_type) elif reset_type == 'cr50_reset_odl': return Cr50ResetODLReset(self._servo, reset_type) return ManualReset(self._servo, reset_type) |