cros_bundle_firmware: Support textbase in new upstream tegra release
Upstream tegra has added an SPL feature, with a 16KB header on the
front of U-Boot. So when searching for the text base, we need to
skip this header. Make this automatic for now.
BUG=chromium-os:32468
TEST=manual
Checkout upstream U-Boot from tegra/next, which includes Allen Martin's
SPL series:
44fd742 tegra20: Remove armv4t build flags
Use ''cros_bundle_firmware -w usb -u u-boot-dtb-tegra.bin' to write
U-Boot to the board, and see that it detects the text base correctly,
downloads and boots.
Change-Id: I886126affae74d6b91ab9bb70a2f82363bec2e08
Reviewed-on: https://gerrit.chromium.org/gerrit/27979
Reviewed-by: Tom Wai-Hong Tam <waihong@chromium.org>
Commit-Ready: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
diff --git a/host/lib/bundle_firmware.py b/host/lib/bundle_firmware.py
index e8038ca..ed281bd 100644
--- a/host/lib/bundle_firmware.py
+++ b/host/lib/bundle_firmware.py
@@ -422,6 +422,10 @@
from the image with some certainty. We check only the first 40 words
since the header should be within that region.
+ Since upstream Tegra has moved to having a 16KB SPL region at the start,
+ and currently this does holds the U-Boot text base (e.g. 0x10c000) instead
+ of the SPL one (e.g. 0x108000), we search in the U-Boot part as well.
+
Args:
data: U-Boot binary data
@@ -429,15 +433,16 @@
Text base (integer) or None if none was found
"""
found = False
- for i in range(0, 160, 4):
- word = data[i:i + 4]
+ for start in (0, 0x4000):
+ for i in range(start, start + 160, 4):
+ word = data[i:i + 4]
- # TODO(sjg): This does not cope with a big-endian target
- value = struct.unpack('<I', word)[0]
- if found:
- return value
- if value == 0x12345678:
- found = True
+ # TODO(sjg): This does not cope with a big-endian target
+ value = struct.unpack('<I', word)[0]
+ if found:
+ return value - start
+ if value == 0x12345678:
+ found = True
return None
@@ -455,8 +460,9 @@
data = self._tools.ReadFile(fname)
fdt_text_base = fdt.GetInt('/chromeos-config', 'textbase', 0)
text_base = self.DecodeTextBase(data)
- self._out.Info('TEXT_BASE: fdt says %#x, %s says %#x' % (fdt_text_base,
- fname, text_base))
+ text_base_str = '%#x' % text_base if text_base else 'None'
+ self._out.Info('TEXT_BASE: fdt says %#x, %s says %s' % (fdt_text_base,
+ fname, text_base_str))
# If they are different, issue a warning and switch over.
if text_base and text_base != fdt_text_base: