summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-07-08 14:22:19 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-13 17:06:03 +0000
commit331ea002e16c1209e1eddf57c01400b7ff4ac02e (patch)
tree0dc3933e35417500dc9b92cfc722058df17f859e /chip
parentb330c438eed93c2dddecfe767a1bacfca4883227 (diff)
downloadchrome-ec-331ea002e16c1209e1eddf57c01400b7ff4ac02e.tar.gz
ec: Fix some bad formatting and warnings
The black formatting revealed some odd formatting. Fixed all errors from cros lint. find . \( -path ./private -prune \) -o -name '*.py' -print | \ xargs cros lint -v |& grep ": E" BRANCH=None BUG=b:238434058 TEST=None Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ia1d2e9cfb0cd2b7000d15b3b918d24881987673e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3749249 Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'chip')
-rwxr-xr-xchip/ish/util/pack_ec.py10
-rwxr-xr-xchip/mchp/util/pack_ec.py4
-rwxr-xr-xchip/mchp/util/pack_ec_mec152x.py26
-rwxr-xr-xchip/mchp/util/pack_ec_mec172x.py42
-rwxr-xr-xchip/mec1322/util/pack_ec.py4
5 files changed, 16 insertions, 70 deletions
diff --git a/chip/ish/util/pack_ec.py b/chip/ish/util/pack_ec.py
index 8dde6ab6a9..e7bb0ce74b 100755
--- a/chip/ish/util/pack_ec.py
+++ b/chip/ish/util/pack_ec.py
@@ -4,10 +4,6 @@
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# A script to pack EC binary with manifest header according to
# Based on 607297_Host_ISH_Firmware_Load_Chrome_OS_SAS_Rev0p5.pdf,
@@ -34,8 +30,7 @@ def parseargs():
parser.add_argument(
"-k",
"--kernel",
- help="EC kernel binary to pack, \
- usually ec.RW.bin or ec.RW.flat.",
+ help="EC kernel binary to pack, usually ec.RW.bin or ec.RW.flat.",
required=True,
)
parser.add_argument(
@@ -44,8 +39,7 @@ def parseargs():
parser.add_argument(
"-a",
"--aon",
- help="EC aontask binary to pack, \
- usually ish_aontask.bin.",
+ help="EC aontask binary to pack, usually ish_aontask.bin.",
required=False,
)
parser.add_argument(
diff --git a/chip/mchp/util/pack_ec.py b/chip/mchp/util/pack_ec.py
index 15be16c0d4..85aad94bd6 100755
--- a/chip/mchp/util/pack_ec.py
+++ b/chip/mchp/util/pack_ec.py
@@ -3,10 +3,6 @@
# Copyright 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# A script to pack EC binary into SPI flash image for MEC17xx
# Based on MEC170x_ROM_Description.pdf DS00002225C (07-28-17).
diff --git a/chip/mchp/util/pack_ec_mec152x.py b/chip/mchp/util/pack_ec_mec152x.py
index 89f90f5394..8ef7b3992c 100755
--- a/chip/mchp/util/pack_ec_mec152x.py
+++ b/chip/mchp/util/pack_ec_mec152x.py
@@ -3,10 +3,6 @@
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# A script to pack EC binary into SPI flash image for MEC152x
# Based on MEC1521/MEC1523_ROM_Description.pdf
@@ -218,13 +214,6 @@ def PadZeroTo(data, size):
#
-# Boot-ROM SPI image encryption not used with Chromebooks
-#
-def EncryptPayload(args, chip_dict, payload):
- return None
-
-
-#
# Build SPI image header for MEC152x
# MEC152x image header size = 320(0x140) bytes
#
@@ -508,9 +497,6 @@ def gen_test_ecrw(pldrw):
def parseargs():
- # TODO I commented this out. Why?
- rpath = os.path.dirname(os.path.relpath(__file__))
-
parser = argparse.ArgumentParser()
parser.add_argument(
"-i",
@@ -778,21 +764,13 @@ def main():
header = BuildHeader2(args, chip_dict, lfw_ecro_len, LOAD_ADDR, lfw_ecro_entry)
printByteArrayAsHex(header, "Header(lfw_ecro)")
- # If payload encryption used then encrypt payload and
- # generate Payload Key Header. If encryption not used
- # payload is not modified and the method returns None
- encryption_key_header = EncryptPayload(args, chip_dict, lfw_ecro)
- printByteArrayAsHex(encryption_key_header, "LFW + EC_RO encryption_key_header")
-
ec_info_block = GenEcInfoBlock(args, chip_dict)
printByteArrayAsHex(ec_info_block, "EC Info Block")
cosignature = GenCoSignature(args, chip_dict, lfw_ecro)
printByteArrayAsHex(cosignature, "LFW + EC_RO cosignature")
- trailer = GenTrailer(
- args, chip_dict, lfw_ecro, encryption_key_header, ec_info_block, cosignature
- )
+ trailer = GenTrailer(args, chip_dict, lfw_ecro, None, ec_info_block, cosignature)
printByteArrayAsHex(trailer, "LFW + EC_RO trailer")
@@ -883,7 +861,7 @@ def main():
assert rw_offset >= offset, print(
"""Offset of EC_RW at {0:08x} overlaps end
- of EC_RO at {0:08x}""".format(
+ of EC_RO at {1:08x}""".format(
rw_offset, offset
)
)
diff --git a/chip/mchp/util/pack_ec_mec172x.py b/chip/mchp/util/pack_ec_mec172x.py
index bd5ff6edba..25a4cb7ed1 100755
--- a/chip/mchp/util/pack_ec_mec172x.py
+++ b/chip/mchp/util/pack_ec_mec172x.py
@@ -3,10 +3,6 @@
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# A script to pack EC binary into SPI flash image for MEC172x
# Based on MEC172x_ROM_Description.pdf revision 6/8/2020
@@ -121,8 +117,9 @@ def GetEntryPoint(payload_file):
return int.from_bytes(s, byteorder="little")
-def GetPayloadFromOffset(payload_file, offset, padsize):
- """Read payload and pad it to padsize."""
+def GetPayloadFromOffset(payload_file, offset, chip_dict):
+ """Read payload and pad it to chip_dict["PAD_SIZE"]."""
+ padsize = chip_dict["PAD_SIZE"]
with open(payload_file, "rb") as f:
f.seek(offset)
payload = bytearray(f.read())
@@ -134,15 +131,15 @@ def GetPayloadFromOffset(payload_file, offset, padsize):
)
if rem_len:
- payload += PAYLOAD_PAD_BYTE * (padsize - rem_len)
+ payload += chip_dict["PAYLOAD_PAD_BYTE"] * (padsize - rem_len)
debug_print("GetPayload: Added {0} padding bytes".format(padsize - rem_len))
return payload
-def GetPayload(payload_file, padsize):
- """Read payload and pad it to padsize"""
- return GetPayloadFromOffset(payload_file, 0, padsize)
+def GetPayload(payload_file, chip_dict):
+ """Read payload and pad it to chip_dict["PAD_SIZE"]"""
+ return GetPayloadFromOffset(payload_file, 0, chip_dict)
def GetPublicKey(pem_file):
@@ -226,13 +223,6 @@ def PadZeroTo(data, size):
#
-# Boot-ROM SPI image encryption not used with Chromebooks
-#
-def EncryptPayload(args, chip_dict, payload):
- return None
-
-
-#
# Build SPI image header for MEC172x
# MEC172x image header size = 320(0x140) bytes
#
@@ -797,16 +787,16 @@ def main():
rorofile = PacklfwRoImage(args.input, args.loader_file, args.image_size)
debug_print("Temporary file containing LFW + EC_RO is ", rorofile)
- lfw_ecro = GetPayload(rorofile, chip_dict["PAD_SIZE"])
+ lfw_ecro = GetPayload(rorofile, chip_dict)
lfw_ecro_len = len(lfw_ecro)
debug_print("Padded LFW + EC_RO length = ", hex(lfw_ecro_len))
# SPI test mode compute CRC32 of EC_RO and store in last 4 bytes
if args.test_spi:
- crc32_ecro = zlib.crc32(bytes(lfw_ecro[LFW_SIZE:-4]))
+ crc32_ecro = zlib.crc32(bytes(lfw_ecro[args.lfw_size : -4]))
crc32_ecro_bytes = crc32_ecro.to_bytes(4, byteorder="little")
lfw_ecro[-4:] = crc32_ecro_bytes
- debug_print("ecro len = ", hex(len(lfw_ecro) - LFW_SIZE))
+ debug_print("ecro len = ", hex(len(lfw_ecro) - args.lfw_size))
debug_print("CRC32(ecro-4) = ", hex(crc32_ecro))
# Reads entry point from offset 4 of file.
@@ -825,21 +815,13 @@ def main():
header = BuildHeader2(args, chip_dict, lfw_ecro_len, args.load_addr, lfw_ecro_entry)
printByteArrayAsHex(header, "Header(lfw_ecro)")
- # If payload encryption used then encrypt payload and
- # generate Payload Key Header. If encryption not used
- # payload is not modified and the method returns None
- encryption_key_header = EncryptPayload(args, chip_dict, lfw_ecro)
- printByteArrayAsHex(encryption_key_header, "LFW + EC_RO encryption_key_header")
-
ec_info_block = GenEcInfoBlock(args, chip_dict)
printByteArrayAsHex(ec_info_block, "EC Info Block")
cosignature = GenCoSignature(args, chip_dict, lfw_ecro)
printByteArrayAsHex(cosignature, "LFW + EC_RO cosignature")
- trailer = GenTrailer(
- args, chip_dict, lfw_ecro, encryption_key_header, ec_info_block, cosignature
- )
+ trailer = GenTrailer(args, chip_dict, lfw_ecro, None, ec_info_block, cosignature)
printByteArrayAsHex(trailer, "LFW + EC_RO trailer")
@@ -851,7 +833,7 @@ def main():
debug_print("args.input = ", args.input)
debug_print("args.image_size = ", hex(args.image_size))
- ecrw = GetPayloadFromOffset(args.input, args.image_size, chip_dict["PAD_SIZE"])
+ ecrw = GetPayloadFromOffset(args.input, args.image_size, chip_dict)
debug_print("type(ecrw) is ", type(ecrw))
debug_print("len(ecrw) is ", hex(len(ecrw)))
diff --git a/chip/mec1322/util/pack_ec.py b/chip/mec1322/util/pack_ec.py
index 736f9efcac..44ba6e7854 100755
--- a/chip/mec1322/util/pack_ec.py
+++ b/chip/mec1322/util/pack_ec.py
@@ -3,10 +3,6 @@
# Copyright 2013 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
# A script to pack EC binary into SPI flash image for MEC1322
# Based on MEC1322_ROM_Doc_Rev0.5.pdf.