diff --git a/Makefile b/Makefile index a21e185cc..8ff927f22 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ res: ## update resources vendorheader: ## construct default vendor header ./tools/build_vendorheader 'db995fe25169d141cab9bbba92baa01f9f2e1ece7df4cb2ac05190f37fcc1f9d:2152f8d19b791d24453242e15f2eab6cb7cffa7b6a5ed30097960e069881db12:22fc297792f0b6ffc0bfcfdb7edb0c0aa14e025a365ec0e342e86e3829cb74b6' 1 0.0 SatoshiLabs assets/satoshilabs_120.toif micropython/firmware/vendorheader.bin + ./tools/binctl micropython/firmware/vendorheader.bin -s binctl: ./tools/binctl micropython/loader/build/loader.bin diff --git a/tools/binctl b/tools/binctl index 18374dcb2..66af5181b 100755 --- a/tools/binctl +++ b/tools/binctl @@ -53,8 +53,10 @@ class BinImage: def print(self): if self.magic == b'TRZF': print('TREZOR Firmware Image') + total_len = self.vhdrlen + self.hdrlen + self.codelen elif self.magic == b'TRZL': print('TREZOR Loader Image') + total_len = self.hdrlen + self.codelen else: print('TREZOR Unknown Image') print(' * magic :', self.magic.decode('ascii')) @@ -64,6 +66,8 @@ class BinImage: print(' * version : %d.%d.%d.%d' % (self.vmajor, self.vminor, self.vpatch, self.vbuild)) print(' * sigmask :', self.sigmask) print(' * sig :', binascii.hexlify(self.sig).decode('ascii')) + print(' * total : %d bytes' % total_len) + print() def serialize_header(self, sig=True): header = struct.pack('<4sIIIBBBB427s', \ @@ -93,7 +97,8 @@ class FirmwareImage(BinImage): def __init__(self, data, vhdrlen): super().__init__(data[vhdrlen:], magic=b'TRZF', max_size=7*128*1024) - self.vheader = data[0:vhdrlen] + self.vhdrlen = vhdrlen + self.vheader = data[:vhdrlen] def write(self, filename): with open(filename, 'wb') as f: @@ -185,9 +190,6 @@ class VendorHeader: def binopen(filename): - print() - print('Opening file', filename) - print() data = open(filename, 'rb').read() magic = data[:4] if magic == b'TRZL':