1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 19:38:09 +00:00
trezor-firmware/bootloader/firmware_align.py

15 lines
322 B
Python
Raw Normal View History

#!/usr/bin/env python3
2014-10-23 16:09:41 +00:00
import sys
import os
2019-02-21 14:18:00 +00:00
TOTALSIZE = 32768
MAXSIZE = TOTALSIZE - 32
2014-10-23 16:09:41 +00:00
fn = sys.argv[1]
fs = os.stat(fn).st_size
2019-02-21 14:18:00 +00:00
if fs > MAXSIZE:
raise Exception('bootloader has to be smaller than %d bytes (current size is %d)' % (MAXSIZE, fs))
2014-10-23 16:09:41 +00:00
with open(fn, 'ab') as f:
2019-02-21 14:18:00 +00:00
f.write(b'\x00' * (TOTALSIZE - fs))
2014-10-23 16:09:41 +00:00
f.close()