When installing recovery image, detecting the USB dev path if usb_dev is None.
This change first renames the argument usb_mount_point to usb_dev since it
is not a mount point actually. If this argument is None, it detects the USB
dev path by emulating USB plug/unplug.
BUG=chromium-os:22339
TEST=run_remote_tests.sh --remote=$REMOTE_IP -a "xml_config=$OVERLAY_XML \
servo_vid=0x18d1 servo_pid=0x5001 image=$RECOVERY_IMAGE" \
platform_InstallRecoveryImage
Change-Id: I6a3041c8c1b6d6354a3eb8711fdf1f4ddcf36762
Reviewed-on: https://gerrit.chromium.org/gerrit/13863
Reviewed-by: Todd Broch <tbroch@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/servo.py b/server/cros/servo.py
index aca9a4b..42ab51e 100644
--- a/server/cros/servo.py
+++ b/server/cros/servo.py
@@ -326,19 +326,20 @@
return None
- def install_recovery_image(self, image_path=None, usb_mount_point=None,
+ def install_recovery_image(self, image_path=None, usb_dev=None,
wait_for_completion=True):
"""Install the recovery image specied by the path onto the DUT.
This method uses google recovery mode to install a recovery image
onto a DUT through the use of a USB stick that is mounted on a servo
- board specified by the usb_mount_point. If no image path is specified
+ board specified by the usb_dev. If no image path is specified
we use the recovery image already on the usb image.
Args:
image_path: Path on the host to the recovery image.
- usb_mount_point: When servo_sees_usbkey is enabled, which dev
- e.g. /dev/sdb will the usb key show up as.
+ usb_dev: When servo_sees_usbkey is enabled, which dev
+ e.g. /dev/sdb will the usb key show up as.
+ If None, detects it automatically.
wait_for_completion: Whether to wait for completion of the
factory install and disable the USB hub
before returning. Currently this is just
@@ -348,16 +349,18 @@
# Set up Servo's usb mux.
self.set('prtctl4_pwren', 'on')
self.enable_usb_hub(host=True)
- if image_path and usb_mount_point:
- logging.info('Installing recovery image onto usb stick. '
- 'This takes a while ...')
- client_utils.poll_for_condition(
- lambda: os.path.exists(usb_mount_point),
- timeout=Servo.USB_DETECTION_DELAY,
- desc="%s exists" % usb_mount_point)
- utils.system(' '.join(
- ['sudo', 'dd', 'if=%s' % image_path,
- 'of=%s' % usb_mount_point, 'bs=4M']))
+ if image_path:
+ if not usb_dev:
+ usb_dev = self.probe_host_usb_dev()
+ logging.info('Installing image onto usb stick. '
+ 'This takes a while...')
+ client_utils.poll_for_condition(
+ lambda: os.path.exists(usb_dev),
+ timeout=Servo.USB_DETECTION_DELAY,
+ desc="%s exists" % usb_dev)
+ utils.system(' '.join(
+ ['sudo', 'dd', 'if=%s' % image_path,
+ 'of=%s' % usb_dev, 'bs=4M']))
# Turn the device off.
self.power_normal_press()