cros_bundle_firmware: Use servo to control board flashing
OK, I give up. Flashing the board by manually holding buttons is just too
painful. We have to cold reset the board, then hold fw-up and the power
button while starting the flash with the other hand, and then keep the
power button down until it has finished.
It seems that we are going to have to require servo for flashing Daisy for
now, so add this to cros_bundle_firmware.
BUG=chromium-os:19724
TEST=write cros_bundle_firmware; see that it controls servo and flashes
successfully
Change-Id: I61c8baeb31d99cd19abf1a4333bdb2870f6d771b
Reviewed-on: https://gerrit.chromium.org/gerrit/18867
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/write_firmware.py b/host/lib/write_firmware.py
index fcd1dba..3ba37ef 100644
--- a/host/lib/write_firmware.py
+++ b/host/lib/write_firmware.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import binascii
+import glob
import os
import re
import time
@@ -291,21 +292,19 @@
True if the device was found, False if we timed out.
"""
self._out.Progress('Waiting for board to appear on USB bus')
- for tries in range(timeout):
+ for tries in range(timeout * 2):
try:
args = ['-d', '%04x:%04x' % (vendor_id, product_id)]
self._tools.Run('lsusb', args, sudo=True)
- self._out.Notice('Flasher downloaded - please see serial output '
- 'for progress.')
+ self._out.Progress('Found %s board' % name)
return True
except CmdError as err:
pass
- time.sleep(1)
+ time.sleep(.5)
- self._out.Progress('Found %s board' % name)
- return True
+ return False
def _ExynosFlashImage(self, uboot, bl1, bl2, payload):
"""Flash the image to SPI flash.
@@ -327,9 +326,16 @@
vendor_id = 0x04e8
product_id = 0x1234
- if not self._WaitForUSBDevice('exynos', vendor_id, product_id):
- raise CmdError('Could not find USB device %04x:%04x' % (vendor_id,
- product_id))
+
+ self._out.Progress('Reseting board via servo')
+ args = ['warm_reset:on', 'fw_up:on', 'pwr_button:press', 'sleep:.1',
+ 'warm_reset:off']
+ # TODO(sjg) If the board is bricked a reset does not seem to bring it
+ # back to life.
+ # BUG=chromium-os:28229
+ args = ['cold_reset:on', 'sleep:.2', 'cold_reset:off'] + args
+ self._tools.Run('dut-control', args)
+ time.sleep(2)
self._out.Progress('Uploading flasher image')
download_list = [
@@ -337,20 +343,28 @@
['bl2', 0x02023400, bl2],
['u-boot', 0x43e00000, flasher]
]
- for item in download_list:
- print item
- args = ['-a', '%#x' % item[1], '-f', item[2]]
- bad = False
- try:
+ first = True
+ try:
+ for item in download_list:
+ if not self._WaitForUSBDevice('exynos', vendor_id, product_id, 4):
+ if first:
+ raise CmdError('Could not find Exynos board on USB port')
+ raise CmdError("Stage '%s' did not complete" % item[0])
+ args = ['-a', '%#x' % item[1], '-f', item[2]]
+ first = False
+ self._out.Notice(item[2])
self._out.Progress("Uploading stage '%s'" % item[0])
+
+ # TODO(sjg): Remove this delay, once the need for it is understood.
+ time.sleep(1)
self._tools.Run('smdk-usbdl', args, sudo=True)
- except CmdError as err:
- bad = True
- if bad or not self._WaitForUSBDevice('exynos', vendor_id, product_id, 1):
- raise CmdError("Stage '%s' did not complete" % item[0])
- time.sleep(.7)
+ finally:
+ args = ['fw_up:off', 'pwr_button:release']
+ self._tools.Run('dut-control', args)
+ self._out.Notice('Flasher downloaded - please see serial output '
+ 'for progress.')
return True
def DoWriteFirmware(output, tools, fdt, flasher, file_list, image_fname,