summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2022-12-06 14:53:05 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-12-07 18:39:36 +0000
commit17ee25c1f2b064e54fa8bc2a548682705fe8d017 (patch)
tree7eea5dd7349cd3db2cd622fb2b1333d20f35282a
parent58030fc4988316f27411d5fd5a5b6c0826b89aa5 (diff)
downloadchrome-ec-17ee25c1f2b064e54fa8bc2a548682705fe8d017.tar.gz
flash_cr50: remove cros_build_lib dependency
Labstation images don't have cros_build_lib, so flash_cr50 can't run on them. Replace cros_build_lib, so flash_cr50 can run on labstations. BUG=none TEST=run on labstation Change-Id: I6cab324952ef1b2f4a87b22ebd55f5a9cbaf7798 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4083152 Reviewed-by: Andrew Luo <aluo@chromium.org>
-rwxr-xr-xutil/flash_cr50.py34
1 files changed, 13 insertions, 21 deletions
diff --git a/util/flash_cr50.py b/util/flash_cr50.py
index 266cca7035..694188b2ff 100755
--- a/util/flash_cr50.py
+++ b/util/flash_cr50.py
@@ -29,8 +29,8 @@ import time
import serial
-from chromite.lib import cros_build_lib
-
+# No GSC updaters take anywhere close to 2 minutes to run.
+CMD_TIMEOUT = 120
CR50_FIRMWARE_BASE = '/opt/google/cr50/firmware/cr50.bin.'
UPDATERS = [ 'gsctool', 'cr50-rescue', 'brescue' ]
RELEASE_PATHS = {
@@ -88,22 +88,15 @@ def run_command(cmd, check_error=True):
Raises:
The command error if the command fails and check_error is True.
"""
- try:
- result = cros_build_lib.run(cmd,
- check=check_error,
- print_cmd=True,
- capture_output=True,
- encoding='utf-8',
- stderr=subprocess.STDOUT,
- debug_level=logging.DEBUG,
- log_output=True)
- except cros_build_lib.RunCommandError as cmd_error:
- if check_error:
- raise
- # OSErrors are handled differently. They're raised even if check is
- # False. Return the errno and message for OS errors.
- return cmd_error.exception.errno, cmd_error.msg
- return result.returncode, result.stdout.strip()
+ result = subprocess.run(cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ encoding='utf-8',
+ timeout=CMD_TIMEOUT,
+ check=check_error)
+ msg = result.stdout or ''
+ logging.debug('%r result %d:\n%s', ' '.join(cmd), result.returncode, msg)
+ return result.returncode, msg.strip()
class Cr50Image(object):
@@ -639,7 +632,7 @@ class Cr50RescueUpdater(FlashCr50):
PACKAGE = 'cr50-utils'
DEFAULT_UPDATER = '/usr/bin/cr50-rescue'
- WAIT_FOR_UPDATE = 120
+ WAIT_FOR_UPDATE = CMD_TIMEOUT
RESCUE_RESET_DELAY = 5
def __init__(self, cmd, port, reset_type):
@@ -711,8 +704,7 @@ class Cr50RescueUpdater(FlashCr50):
pty = self._servo.get_raw_cr50_pty()
rescue_cmd = self._get_rescue_cmd(pty)
- logging.info('Starting cr50-rescue: %s',
- cros_build_lib.CmdToStr(rescue_cmd))
+ logging.info('Starting cr50-rescue: %s', ' '.join(rescue_cmd))
self._rescue_process = subprocess.Popen(rescue_cmd)
self._rescue_process.communicate()