Skip to content

Commit

Permalink
optimize board build for size to avoid going over the limit. (commaai…
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
adhintz authored and rbiasini committed Jan 23, 2019
1 parent 20e8fa9 commit 9ee6285
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion board/build.mk
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 $^
Expand Down

0 comments on commit 9ee6285

Please sign in to comment.