1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-10-18 05:49:11 +00:00
trezor-firmware/legacy/bootloader/firmware_align.py

20 lines
481 B
Python
Raw Normal View History

#!/usr/bin/env python3
2014-10-23 16:09:41 +00:00
import os
import sys
2014-10-23 16:09:41 +00:00
2019-02-21 14:18:00 +00:00
TOTALSIZE = 32768
MAXSIZE = TOTALSIZE - 32
infile = sys.argv[1]
outfile = sys.argv[2]
fs = os.stat(infile).st_size
print(f"Current bootloader size before align is {fs} bytes")
2019-02-21 14:18:00 +00:00
if fs > MAXSIZE:
raise Exception(
f"bootloader has to be smaller than {MAXSIZE} bytes (current size is {fs})"
)
with open(outfile, "wb") as f:
with open(infile, "rb") as i:
f.write(i.read())
f.write(b"\x00" * (TOTALSIZE - fs))