summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2019-12-18 18:01:10 -0700
committerCommit Bot <commit-bot@chromium.org>2019-12-19 22:50:22 +0000
commit2e6cdb08533197da6a33c2f3bb2f64e6f87f9853 (patch)
treecda51a22f4103b659ba2844e9fa48d465ac37440
parentecdd04ca412ce7cea496397f89ccdce85c2242d0 (diff)
downloadchrome-ec-2e6cdb08533197da6a33c2f3bb2f64e6f87f9853.tar.gz
ish: convert pack_ec.py script to Python 3
Misc changes to get working in Python 3, mostly to do with handling bytes/strings differently. BUG=chromium:1031705 BRANCH=none TEST=make BOARD=arcada_ish Change-Id: I3fe4adbf8d8dcb07401515ddf8a02aec9c3d0b05 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1975094 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rwxr-xr-xchip/ish/util/pack_ec.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/chip/ish/util/pack_ec.py b/chip/ish/util/pack_ec.py
index 71a63dd42f..f1ce28539e 100755
--- a/chip/ish/util/pack_ec.py
+++ b/chip/ish/util/pack_ec.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-"
# Copyright 2019 The Chromium OS Authors. All rights reserved.
@@ -17,7 +17,6 @@ image with a manifest header, ISH shim loader will parse this header and load
each binaries into right memory location.
"""
-from __future__ import print_function
import argparse
import struct
@@ -70,40 +69,40 @@ def main():
print(" Packing EC image file for ISH")
with open(args.output, 'wb') as f:
- print(" kernel binary size: %i" % args.kernel_size)
+ print(" kernel binary size:", args.kernel_size)
kern_rdup_pg_size = roundup_page(args.kernel_size)
# Add manifest for main ISH binary
- f.write(gen_manifest('ISHM', 'ISH_KERN', HEADER_SIZE, kern_rdup_pg_size))
+ f.write(gen_manifest(b'ISHM', b'ISH_KERN', HEADER_SIZE, kern_rdup_pg_size))
if args.aon is not None:
- print(" AON binary size: %i" % args.aon_size)
+ print(" AON binary size: ", args.aon_size)
aon_rdup_pg_size = roundup_page(args.aon_size)
# Add manifest for aontask binary
- f.write(gen_manifest('ISHM', 'AON_TASK',
+ f.write(gen_manifest(b'ISHM', b'AON_TASK',
(HEADER_SIZE + kern_rdup_pg_size * PAGE_SIZE -
MANIFEST_ENTRY_SIZE), aon_rdup_pg_size))
# Add manifest that signals end of manifests
- f.write(gen_manifest('ISHE', '', 0, 0))
+ f.write(gen_manifest(b'ISHE', b'', 0, 0))
# Pad the remaining HEADER with 0s
if args.aon is not None:
- f.write('\x00' * (HEADER_SIZE - (MANIFEST_ENTRY_SIZE * 3)))
+ f.write(b'\x00' * (HEADER_SIZE - (MANIFEST_ENTRY_SIZE * 3)))
else:
- f.write('\x00' * (HEADER_SIZE - (MANIFEST_ENTRY_SIZE * 2)))
+ f.write(b'\x00' * (HEADER_SIZE - (MANIFEST_ENTRY_SIZE * 2)))
# Append original kernel image
with open(args.kernel, 'rb') as in_file:
f.write(in_file.read())
# Filling padings due to size round up as pages
- f.write('\x00' * (kern_rdup_pg_size * PAGE_SIZE - args.kernel_size))
+ f.write(b'\x00' * (kern_rdup_pg_size * PAGE_SIZE - args.kernel_size))
if args.aon is not None:
# Append original aon image
with open(args.aon, 'rb') as in_file:
f.write(in_file.read())
# Filling padings due to size round up as pages
- f.write('\x00' * (aon_rdup_pg_size * PAGE_SIZE - args.aon_size))
+ f.write(b'\x00' * (aon_rdup_pg_size * PAGE_SIZE - args.aon_size))
if __name__ == '__main__':
main()