summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2022-05-16 10:04:13 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-19 14:29:46 +0000
commitfae3eadee0f68caab5671a1125d6ac8d46c2bc92 (patch)
treeb31205c3f44cd61037fc94a41ac25cf4c85a0124
parentb965c08f7098d8e91e347c6bfabdf92fe43a14d1 (diff)
downloadchrome-ec-fae3eadee0f68caab5671a1125d6ac8d46c2bc92.tar.gz
ap_ro_hash: break up ranges into 4M blocks
If a range is too big, break it up into smaller blocks that GSC can handle. BUG=none TEST=run `ap_ro_hash.py COREBOOT` on volteer. Change-Id: I094c2eb725af07e21b3e249336cb7b556761b50c Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3644691 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rwxr-xr-xutil/ap_ro_hash.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/util/ap_ro_hash.py b/util/ap_ro_hash.py
index 8520200c66..f43493d902 100755
--- a/util/ap_ro_hash.py
+++ b/util/ap_ro_hash.py
@@ -68,6 +68,7 @@ VENDOR_RC_NO_SUCH_COMMAND_ERROR = 0x57f
# The tag and format are the same for command and response.
TPM_TAG = 0x8001
HEADER_FMT = '>H2LH'
+MAX_BLOCK_SIZE = (4 * 1024 * 1024)
class Logger(object):
"""A class to support printing into a log and on the console when required.
@@ -536,17 +537,28 @@ def main(args):
for arg in rest:
- if ':' in arg:
+ if arg in fmap:
+ offset, size = fmap[arg]
+ LOG.log('Using %r range from fmap %08x:%08x' %
+ (arg, offset, size))
+ elif ':' in arg:
try:
- ranges.append(([int('%s' % x, 16) for
- x in arg.split(':', 1)]),)
+ offset_str, size_str = arg.split(':', 1)
+ offset = int(offset_str, 16)
+ size = int(size_str, 16)
except ValueError:
bad_ranges.append(arg)
- continue
- if arg not in fmap:
+ continue
+ else:
bad_section_names.append(arg)
continue
- ranges.append(fmap[arg])
+
+ while size:
+ chunk = min(size, MAX_BLOCK_SIZE)
+ LOG.log('Add range - %08x:%08x' % (offset, chunk))
+ ranges.append((offset, chunk))
+ size -= chunk
+ offset += chunk
error_msg = ''
if bad_ranges:
@@ -558,6 +570,7 @@ def main(args):
if ranges:
# Make sure the list is sorted by the first element.
ranges.sort(key=lambda x: x[0])
+ LOG.log('Ranges: %r' % ranges)
# Make sure ranges do not overlap and fall into the WP_RO section.
error_msg += verify_ranges(ranges, fmap['WP_RO'])