mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-20 21:38:26 +00:00
25 lines
478 B
Plaintext
25 lines
478 B
Plaintext
|
#!/usr/bin/env python3
|
||
|
import sys
|
||
|
|
||
|
def pairwise(iterable):
|
||
|
a = iter(iterable)
|
||
|
return zip(a, a)
|
||
|
|
||
|
files = sys.argv[1:]
|
||
|
files = list(pairwise(files))
|
||
|
|
||
|
offset = int(files[0][0], 16)
|
||
|
|
||
|
out = bytearray()
|
||
|
|
||
|
for addr, fn in files:
|
||
|
addr = int(addr, 16) - offset
|
||
|
data = open(fn, 'rb').read()
|
||
|
if len(out) < addr:
|
||
|
out += b'\x00' * (addr - len(out))
|
||
|
if len(out) != addr:
|
||
|
raise Exception('Alignment failed')
|
||
|
out += data
|
||
|
|
||
|
sys.stdout.buffer.write(out)
|