From ad1750d53ab6f287d5587a241be09e470c012a7b Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Wed, 18 May 2022 12:08:56 -0700 Subject: ap_ro_hash: use dump_fmap flashrom format Use the dump_fmap flashrom output to calculate the offset and size. All of the information is included on one line. BUG=none TEST=ap_ro_hash.py -v GBB True Change-Id: I160173caaaf540c20786e892d244ee8a941833b6 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3654254 Reviewed-by: Vadim Bendebury --- util/ap_ro_hash.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/util/ap_ro_hash.py b/util/ap_ro_hash.py index f43493d902..1cc016c4cf 100755 --- a/util/ap_ro_hash.py +++ b/util/ap_ro_hash.py @@ -382,23 +382,21 @@ def read_fmap(tmpd): """ fmap_file = os.path.join(tmpd, 'fmap.bin') run('flashrom -i FMAP -r %s' % fmap_file, ignore_error=False) - fmap_text = run('dump_fmap ' + fmap_file, ignore_error=False)[0] + fmap_text = run('dump_fmap -F ' + fmap_file, ignore_error=False)[0] fmap = {} offset = 0 size = 0 for line in fmap_text.splitlines(): - tokens = line.split() - if tokens[0] == 'area_offset:': - offset = int(tokens[1], 16) - continue - if tokens[0] == 'area_size:': - size = int(tokens[1], 16) - continue - if tokens[0] == 'area_name:': - fmap[tokens[1]] = (offset, size) - LOG.log('%20s: %08x:%08x' % (tokens[1], offset, offset + size - 1)) - continue + # line format + # start_offset:end_offset secton_name + r, name = line.split() + start, end = r.split(':') + offset = int(start, 16) + end_offset = int(end, 16) + size = end_offset - offset + 1 + fmap[name] = (offset, size) + LOG.log('%20s 0x%08x:0x%08x %s' % (name, offset, size, r)) return fmap -- cgit v1.2.1