1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-05 14:59:44 +00:00
trezor-firmware/legacy/bootloader/firmware_align.py
2022-02-10 14:48:11 +01:00

19 lines
420 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
TOTALSIZE = 32768
MAXSIZE = TOTALSIZE - 32
infile = sys.argv[1]
outfile = sys.argv[2]
fs = os.stat(infile).st_size
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))