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