cros_bundle_firmware: Move firmware writing into write_firmware.py
This function should not be in cros_bundle_firmware - we move it into the
correct place so that it can be used with cros_write_firmware also.
BUG=chromium-os:17298
TEST=run cros_bundle_firmware -w and see that it still works
Change-Id: If1ab0c7ad1bc9f7bc424ba072c574a8ca8df1356
Reviewed-on: http://gerrit.chromium.org/gerrit/5591
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/write_firmware.py b/host/lib/write_firmware.py
index 00cd17f..0478b26 100644
--- a/host/lib/write_firmware.py
+++ b/host/lib/write_firmware.py
@@ -205,3 +205,24 @@
time.sleep(1)
return False
+
+def DoWriteFirmware(output, tools, fdt, flasher, bct_fname, image_fname):
+ """A simple function to write firmware to the board.
+
+ This creates a WriteFirmware object and uses it to write the firmware image
+ to the board.
+
+ Args:
+ output: cros_output object to use.
+ tools: Tools object to use.
+ fdt: Fdt object to use as our device tree.
+ flasher: U-Boot binary to use as the flasher.
+ bct_fname: Bct file to use for the flasher.
+ image_fname: Filename of image to write.
+ """
+ write = WriteFirmware(tools, fdt, output)
+ if write.FlashImage(flasher, bct_fname, image_fname):
+ output.Progress('Image uploaded - please wait for flashing to '
+ 'complete')
+ else:
+ raise CmdError('Image upload failed - please check board connection')