diff options
author | Gabor Kertesz <gabor.kertesz@arm.com> | 2018-09-12 15:38:41 +0200 |
---|---|---|
committer | Gabor Kertesz <gabor.kertesz@arm.com> | 2018-09-24 13:37:20 +0200 |
commit | 33e9b2397d18568882f21445d98a4dc8e825588d (patch) | |
tree | f1b49ab2601e871d529bb084f9eae059a393ad46 | |
parent | fab0ff7b272c124618183a34149e41086a73d372 (diff) | |
download | trusted-firmware-m-33e9b2397d18568882f21445d98a4dc8e825588d.tar.gz |
Boot: Add Python2.7 support for post build steps
These minor changes make Python 3 and Python 2.7 verions supported by
the post build scripts, even integrating them as modules.
Change-Id: I0d7a6d95764db082bbec02b0af01da4cf03fd98d
Signed-off-by: Gabor Kertesz <gabor.kertesz@arm.com>
-rw-r--r-- | bl2/ext/mcuboot/scripts/assemble.py | 1 | ||||
-rw-r--r-- | bl2/ext/mcuboot/scripts/imgtool.py | 7 | ||||
-rw-r--r-- | bl2/ext/mcuboot/scripts/imgtool_lib/__init__.py (renamed from bl2/ext/mcuboot/scripts/imgtool/__init__.py) | 0 | ||||
-rw-r--r-- | bl2/ext/mcuboot/scripts/imgtool_lib/image.py (renamed from bl2/ext/mcuboot/scripts/imgtool/image.py) | 4 | ||||
-rw-r--r-- | bl2/ext/mcuboot/scripts/imgtool_lib/keys.py (renamed from bl2/ext/mcuboot/scripts/imgtool/keys.py) | 3 | ||||
-rw-r--r-- | bl2/ext/mcuboot/scripts/imgtool_lib/version.py (renamed from bl2/ext/mcuboot/scripts/imgtool/version.py) | 0 |
6 files changed, 9 insertions, 6 deletions
diff --git a/bl2/ext/mcuboot/scripts/assemble.py b/bl2/ext/mcuboot/scripts/assemble.py index b8b60ebab2..9c48092714 100644 --- a/bl2/ext/mcuboot/scripts/assemble.py +++ b/bl2/ext/mcuboot/scripts/assemble.py @@ -67,6 +67,7 @@ class Assembly(): def add_image(self, source, partition): with open(self.output, 'ab') as ofd: + ofd.seek(0, os.SEEK_END) pos = ofd.tell() if pos > self.offsets[partition]: raise Exception("Partitions not in order, unsupported") diff --git a/bl2/ext/mcuboot/scripts/imgtool.py b/bl2/ext/mcuboot/scripts/imgtool.py index 4b62d3b12d..80009c8615 100644 --- a/bl2/ext/mcuboot/scripts/imgtool.py +++ b/bl2/ext/mcuboot/scripts/imgtool.py @@ -15,12 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import os import re import argparse -from imgtool import keys -from imgtool import image -from imgtool import version +from imgtool_lib import keys +from imgtool_lib import image +from imgtool_lib import version import sys def find_load_address(args): diff --git a/bl2/ext/mcuboot/scripts/imgtool/__init__.py b/bl2/ext/mcuboot/scripts/imgtool_lib/__init__.py index fd240440dc..fd240440dc 100644 --- a/bl2/ext/mcuboot/scripts/imgtool/__init__.py +++ b/bl2/ext/mcuboot/scripts/imgtool_lib/__init__.py diff --git a/bl2/ext/mcuboot/scripts/imgtool/image.py b/bl2/ext/mcuboot/scripts/imgtool_lib/image.py index b3915e046a..67425d4ba3 100644 --- a/bl2/ext/mcuboot/scripts/imgtool/image.py +++ b/bl2/ext/mcuboot/scripts/imgtool_lib/image.py @@ -43,7 +43,7 @@ trailer_sizes = { for write_size in [1, 2, 4, 8] } -boot_magic = bytes([ +boot_magic = bytearray([ 0x77, 0xc2, 0x95, 0xf3, 0x60, 0xd2, 0xef, 0x7f, 0x35, 0x52, 0x50, 0x0f, @@ -100,7 +100,7 @@ class Image(): # If there is a header requested, make sure that the image # starts with all zeros. if self.header_size > 0: - if any(v != 0 for v in self.payload[0:self.header_size]): + if any(v != 0 and v != b'\000' for v in self.payload[0:self.header_size]): raise Exception("Padding requested, but image does not start with zeros") def sign(self, key, ramLoadAddress): diff --git a/bl2/ext/mcuboot/scripts/imgtool/keys.py b/bl2/ext/mcuboot/scripts/imgtool_lib/keys.py index 9728cd064e..fda3ed6710 100644 --- a/bl2/ext/mcuboot/scripts/imgtool/keys.py +++ b/bl2/ext/mcuboot/scripts/imgtool_lib/keys.py @@ -1,5 +1,5 @@ # Copyright 2017 Linaro Limited -# Copyright (c) 2017, Arm Limited. +# Copyright (c) 2017-2018, Arm Limited. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,6 +17,7 @@ Cryptographic key management for imgtool. """ +from __future__ import print_function from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA from Crypto.Signature import PKCS1_v1_5, PKCS1_PSS diff --git a/bl2/ext/mcuboot/scripts/imgtool/version.py b/bl2/ext/mcuboot/scripts/imgtool_lib/version.py index d1d45f0385..d1d45f0385 100644 --- a/bl2/ext/mcuboot/scripts/imgtool/version.py +++ b/bl2/ext/mcuboot/scripts/imgtool_lib/version.py |