[coreboot-gerrit] Patch set updated for coreboot: Exynos7: Revisit the checksum and header calculation
Stefan Reinauer (stefan.reinauer@coreboot.org)
gerrit at coreboot.org
Fri May 20 18:23:07 CEST 2016
Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14904
-gerrit
commit 681cab148d2ec1d554f59a7d1d0a8b3a1d329cab
Author: Alim Akhtar <alim.akhtar at samsung.com>
Date: Fri Sep 5 16:22:33 2014 +0530
Exynos7: Revisit the checksum and header calculation
Exynos7 BL1 checks the validity of BL2 by reading a 16 bytes
long header of the bl2. BL1 calculates and compares the checksum
of BL2 with the one mentioned in the BL2's header.
This patch modifies header populating script to update BL2 header
with the checksum as per BL1's requirement.
BUG=None
BRANCH=None
TEST=Compiled and booted Coreboot over Jazz mainboard
with this series
Change-Id: Iaf870070707f6f617bbabfc45dd9b87934b6266b
Signed-off-by: Alim Akhtar <alim.akhtar at samsung.com>
Signed-off-by: Vivek Gautam <gautam.vivek at samsung.com>
Signed-off-by: Akshay Saraswat <akshay.s at samsung.com>
---
util/exynos/variable_cksum.py | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/util/exynos/variable_cksum.py b/util/exynos/variable_cksum.py
index 541e06d..8d7cba2 100755
--- a/util/exynos/variable_cksum.py
+++ b/util/exynos/variable_cksum.py
@@ -29,16 +29,18 @@
This utility computes and fills Exynos ROM checksum (for BL1 or BL2).
(Algorithm from U-Boot: tools/mkexynosspl.c)
-Input: IN OUT <size_in_blocks>
+Input: IN OUT <size_in_blocks> <checksum-type>
Output:
Checksum header added to IN and written to OUT.
- Header: uint32_t size, checksum, reserved[2].
+ Header: uint32_t size, checksum, String "head", reserved[1].
"""
import struct
import sys
+import hashlib
+import binascii
# Get the number of byte needed to make _data_ 512 byte alinged
def alignpos(pos, alignbytes):
@@ -46,8 +48,8 @@ def alignpos(pos, alignbytes):
return (pos + mask) & ~mask
def main(argv):
- if len(argv) < 3 or len(argv) > 4:
- exit('usage: %s IN OUT <size_in_blocks>' % argv[0])
+ if len(argv) < 3 or len(argv) > 5:
+ exit('usage: %s IN OUT <size_in_blocks> <checksum-type>' % argv[0])
in_name, out_name = argv[1:3]
header_format = "<IIII"
@@ -63,12 +65,18 @@ def main(argv):
else:
size = (size / block_size)
- header = struct.pack(header_format,
- size,
- sum(map(ord, data)),
- 0, 0)
- out_file.write(header + data)
+ if "sha256" in argv:
+ hash_obj = hashlib.sha256(data)
+ hex_dig = hash_obj.hexdigest()[:8]
+ hex_dig_int = int(hex_dig, 16)
+ chk_be = binascii.hexlify(struct.pack('<I', hex_dig_int))
+ chk_be_int = int(chk_be, 16)
+ else:
+ chk_be_int = sum(map(ord, data))
+ header = struct.pack(header_format, size, chk_be_int,
+ int("head".encode("hex"), 16), 0)
+ out_file.write(header + data)
if __name__ == '__main__':
main(sys.argv)
More information about the coreboot-gerrit
mailing list