From 9ee628557f3f33759c62b567964b918a597d3387 Mon Sep 17 00:00:00 2001 From: Drew Hintz Date: Wed, 23 Jan 2019 13:24:29 -0800 Subject: [PATCH] optimize board build for size to avoid going over the limit. (#150) * optimize board build for size to avoid going over the limit. Here are the sizes of board/obj/panda.bin with different settings: -O2 32228 -Og 30172 -Os 28028 * warning if panda.bin is over the panda's limit * if bin is too big, error out --- board/build.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/board/build.mk b/board/build.mk index aee724c19044c1..9f2c4250c2c772 100644 --- a/board/build.mk +++ b/board/build.mk @@ -1,4 +1,4 @@ -CFLAGS += -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -O2 +CFLAGS += -I inc -I ../ -nostdlib -fno-builtin -std=gnu11 -Os CFLAGS += -Tstm32_flash.ld @@ -51,6 +51,8 @@ obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).o $(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^ $(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin SETLEN=1 ../crypto/sign.py obj/code.bin $@ $(CERT) + @BINSIZE=$$(du -b "obj/$(PROJ_NAME).bin" | cut -f 1) ; if [ $$BINSIZE -ge 32768 ]; then echo "ERROR obj/$(PROJ_NAME).bin is too big!"; exit 1; fi; + obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.$(PROJ_NAME).o obj/rsa.$(PROJ_NAME).o $(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^