cros_bundle_firmware: Use python code to chop up image
Rather than running dd, use Python code to chop the image. Also keep
a copy of the full 8MB image, in case we want to run cbfstool to check
or extract its contents.
BUG=chrome-os-partner:13961
BRANCH=none
TEST=manual
$ cros_bundle_firmware -b link -O out
Check that out/coreboot-8mb.rom exists
$ cbfstool out/coreboot-8mb.rom print
See that the correct output is obtained.
Change-Id: Ia9b973aac3a408cf94c6228d9c0c9c0c49290507
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/39876
Reviewed-by: Randall Spangler <rspangler@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index cb675e5..30773d6 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -1050,10 +1050,10 @@
'-l', '0x1110000', '-e', '0x1110008'])
self._tools.Run('cbfstool', [bootstub, 'add', '-f', fdt.fname,
'-n', 'u-boot.dtb', '-t', '0xac'])
- bootstub_tmp = bootstub + '.tmp'
- self._tools.Run('dd', ['if=' + bootstub, 'of=' + bootstub_tmp,
- 'bs=1M', 'skip=7'])
- shutil.move(bootstub_tmp, bootstub)
+ data = self._tools.ReadFile(bootstub)
+ bootstub_copy = os.path.join(self._tools.outdir, 'coreboot-8mb.rom')
+ self._tools.WriteFile(bootstub_copy, data)
+ self._tools.WriteFile(bootstub, data[0x700000:])
image = os.path.join(self._tools.outdir, 'image.bin')
pack.PackImage(self._tools.outdir, image)