mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
build: don't convert from png in build_vendorheader, remove vendorheader.bin from vcs
This commit is contained in:
parent
5c227a4a47
commit
1eff07f84d
@ -10,6 +10,8 @@ install:
|
|||||||
- sudo apt-get install -y build-essential gcc-multilib gcc-arm-embedded
|
- sudo apt-get install -y build-essential gcc-multilib gcc-arm-embedded
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- make vendorheader
|
||||||
|
|
||||||
- make build_cross
|
- make build_cross
|
||||||
|
|
||||||
- make build_bootloader
|
- make build_bootloader
|
||||||
|
4
Makefile
4
Makefile
@ -24,8 +24,8 @@ vendor: ## update git submodules
|
|||||||
res: ## update resources
|
res: ## update resources
|
||||||
./tools/res_collect
|
./tools/res_collect
|
||||||
|
|
||||||
vendorheader: ## contruct default vendor header
|
vendorheader: ## construct default vendor header
|
||||||
./tools/build_vendorheader '0000000000000000000000000000000000000000000000000000000000000000,0000000000000000000000000000000000000000000000000000000000000000,0000000000000000000000000000000000000000000000000000000000000000' 2 1.1 SatoshiLabs assets/satoshilabs_120.png micropython/firmware/vendorheader.bin
|
./tools/build_vendorheader '0000000000000000000000000000000000000000000000000000000000000000:0000000000000000000000000000000000000000000000000000000000000000:0000000000000000000000000000000000000000000000000000000000000000' 2 1.1 SatoshiLabs assets/satoshilabs_120.toif micropython/firmware/vendorheader.bin
|
||||||
|
|
||||||
## emulator commands:
|
## emulator commands:
|
||||||
|
|
||||||
|
Binary file not shown.
1
micropython/firmware/.gitignore
vendored
1
micropython/firmware/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
build/
|
build/
|
||||||
|
vendorheader.bin
|
||||||
|
@ -1,45 +1,40 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import struct
|
import struct
|
||||||
import re
|
|
||||||
import binascii
|
import binascii
|
||||||
import os
|
|
||||||
import imp
|
|
||||||
|
|
||||||
png2toi = imp.load_source('png2toi', os.path.dirname(__file__) + '/png2toi')
|
|
||||||
|
|
||||||
# encode vendor name, add length byte and padding to multiple of 4
|
# encode vendor name, add length byte and padding to multiple of 4
|
||||||
def encodevendor(vname):
|
def encode_vendor(vname):
|
||||||
vbin = vname.encode('utf-8')
|
vbin = vname.encode('utf-8')
|
||||||
vbin = struct.pack('<B',len(vbin)) + vbin
|
vbin = struct.pack('<B', len(vbin)) + vbin
|
||||||
vbin += b'\0' * (-len(vbin) & 3)
|
vbin += b'\0' * (-len(vbin) & 3)
|
||||||
return vbin
|
return vbin
|
||||||
|
|
||||||
def encodekey(key):
|
def encode_pubkey(pubkey):
|
||||||
if len(key) != 64:
|
if len(pubkey) != 64:
|
||||||
raise Exception("Wrong key length")
|
raise Exception('Wrong public key length')
|
||||||
return binascii.unhexlify(key)
|
return binascii.unhexlify(pubkey)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 7:
|
if len(sys.argv) < 7:
|
||||||
print('Usage build_vendorheader key1hex,... m version vendorname vendorimage.png vendorimage.bin')
|
print('Usage build_vendorheader "pubkey1hex:pubkey2hex:..." m version vendorname vendorimage.toif vendorheader.bin')
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
keys = [encodekey(x) for x in sys.argv[1].split(',')]
|
keys = [encode_pubkey(x) for x in sys.argv[1].split(':')]
|
||||||
m = int(sys.argv[2])
|
m = int(sys.argv[2])
|
||||||
(vmajor, vminor) = [int(x) for x in sys.argv[3].split('.')]
|
(vmajor, vminor) = [int(x) for x in sys.argv[3].split('.')]
|
||||||
vname = sys.argv[4]
|
vname = sys.argv[4]
|
||||||
ifn = sys.argv[5]
|
ifn = sys.argv[5]
|
||||||
ofn = sys.argv[6]
|
ofn = sys.argv[6]
|
||||||
if not ifn.endswith('.png'):
|
if not ifn.endswith('.toif'):
|
||||||
print('Must provide PNG file')
|
print('Must provide TOIF file')
|
||||||
return 2
|
return 2
|
||||||
|
|
||||||
expiry = 0
|
expiry = 0
|
||||||
vheader = b'TRZV' + struct.pack('<IIBBBB', 0, expiry, vmajor, vminor, m, len(keys))
|
vheader = b'TRZV' + struct.pack('<IIBBBB', 0, expiry, vmajor, vminor, m, len(keys))
|
||||||
for k in keys:
|
for k in keys:
|
||||||
vheader += k
|
vheader += k
|
||||||
vheader += encodevendor(vname) + png2toi.process_image(ifn)
|
vheader += encode_vendor(vname) + open(ifn, 'rb').read()
|
||||||
padding = 65 + (-len(vheader) - 65) & 511
|
padding = 65 + (-len(vheader) - 65) & 511
|
||||||
vheader += b'\0' * padding
|
vheader += b'\0' * padding
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user