build(legacy): make bootloader_align target repeatable

[no changelog]
mmilata/tt-pin-keyboard
matejcik 2 years ago committed by matejcik
parent e81bb0f856
commit 825ccd9df5

@ -1,4 +1,4 @@
NAME = bootloader NAME = bootloader-unaligned
OBJS += bootloader.o OBJS += bootloader.o
OBJS += signatures.o OBJS += signatures.o
@ -44,5 +44,7 @@ include ../Makefile.include
# Remove libtrezor from linking since we specified the small versions # Remove libtrezor from linking since we specified the small versions
LDLIBS := $(filter-out -ltrezor,$(LDLIBS)) LDLIBS := $(filter-out -ltrezor,$(LDLIBS))
align: $(NAME).bin bootloader.bin: $(NAME).bin
./firmware_align.py $(NAME).bin ./firmware_align.py $< $@
all: bootloader.bin

@ -5,12 +5,14 @@ import sys
TOTALSIZE = 32768 TOTALSIZE = 32768
MAXSIZE = TOTALSIZE - 32 MAXSIZE = TOTALSIZE - 32
fn = sys.argv[1] infile = sys.argv[1]
fs = os.stat(fn).st_size outfile = sys.argv[2]
fs = os.stat(infile).st_size
if fs > MAXSIZE: if fs > MAXSIZE:
raise Exception( raise Exception(
f"bootloader has to be smaller than {MAXSIZE} bytes (current size is {fs})" f"bootloader has to be smaller than {MAXSIZE} bytes (current size is {fs})"
) )
with open(fn, "ab") as f: with open(outfile, "wb") as f:
with open(infile, "rb") as i:
f.write(i.read())
f.write(b"\x00" * (TOTALSIZE - fs)) f.write(b"\x00" * (TOTALSIZE - fs))
f.close()

@ -16,7 +16,7 @@ fi
make make
if [ "$EMULATOR" != 1 ]; then if [ "$EMULATOR" != 1 ]; then
make -C bootloader align make -C bootloader
fi fi
# invoking nanopb_generator to make sure its proto files are generated # invoking nanopb_generator to make sure its proto files are generated

Loading…
Cancel
Save