write_firmware: provide a parameter to override text_base
We want to pass in the text base to override the default setting from
the fdt. This change makes it an optional parameter.
BUG=chromium-os:19724
TEST=emerge chromeos-bootimage on Seaboard and Alex
Change-Id: I85b5829b96f950b618c041b7ef7cb7b17e8b77c3
Reviewed-on: https://gerrit.chromium.org/gerrit/11743
Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
Reviewed-by: Randall Spangler <rspangler@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 dd37d5a..ac05550 100644
--- a/host/lib/write_firmware.py
+++ b/host/lib/write_firmware.py
@@ -45,7 +45,7 @@
self._tools = tools
self._fdt = fdt
self._out = output
- self._text_base = self._fdt.GetInt('/chromeos-config/textbase');
+ self.text_base = self._fdt.GetInt('/chromeos-config/textbase');
# For speed, use the 'update' algorithm and don't verify
self.update = True
@@ -166,7 +166,7 @@
alignment = 0x1000
payload_offset = (payload_offset + alignment - 1) & ~(alignment-1)
- load_address = self._text_base + payload_offset,
+ load_address = self.text_base + payload_offset,
new_str = '%08x' % load_address
if len(replace_me) is not len(new_str):
raise ValueError("Internal error: replacement string '%s' length does "
@@ -215,7 +215,7 @@
'--setbct',
'--bl', flasher,
'--go',
- '--setentry', "%#x" % self._text_base, "%#x" % self._text_base
+ '--setentry', "%#x" % self.text_base, "%#x" % self.text_base
]
# TODO(sjg): Check for existence of board - but chroot has no lsusb!
@@ -248,7 +248,7 @@
return False
def DoWriteFirmware(output, tools, fdt, flasher, bct_fname, image_fname,
- update=True, verify=False):
+ text_base=None, update=True, verify=False):
"""A simple function to write firmware to the board.
This creates a WriteFirmware object and uses it to write the firmware image
@@ -261,10 +261,13 @@
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.
- update: Use faster update algorithm rather then full device erase
- verify: Verify the write by doing a readback and CRC
+ text_base: U-Boot text base (base of executable image), None for default.
+ update: Use faster update algorithm rather then full device erase.
+ verify: Verify the write by doing a readback and CRC.
"""
write = WriteFirmware(tools, fdt, output)
+ if text_base:
+ write.text_base = text_base
write.update = update
write.verify = verify
if write.FlashImage(flasher, bct_fname, image_fname):