1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

tools: small formatting change to binctl

This commit is contained in:
Pavol Rusnak 2017-04-06 16:58:16 +02:00
parent 76705dde5b
commit 364bcedb04
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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':