summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-11-30 09:28:09 +0100
committerDaniel Friesel <derf@finalrewind.org>2018-11-30 09:28:09 +0100
commit463eea4804253970199bd9b705768b8dde83deb7 (patch)
tree00f277ef19b632b5acaf45133c4e3d6b424e965a
parentfff703319bbf5ad7fc6ca7d3aeca9963d011e19b (diff)
arduino: check program size is below 100% before flashing
-rw-r--r--src/arch/arduino-nano-168/Makefile.inc1
-rw-r--r--src/arch/arduino-nano/Makefile.inc1
2 files changed, 2 insertions, 0 deletions
diff --git a/src/arch/arduino-nano-168/Makefile.inc b/src/arch/arduino-nano-168/Makefile.inc
index 61492db..d89bf6d 100644
--- a/src/arch/arduino-nano-168/Makefile.inc
+++ b/src/arch/arduino-nano-168/Makefile.inc
@@ -79,6 +79,7 @@ OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
build/system.elf: ${OBJECTS}
${QUIET}${CXX} ${COMMON_FLAGS} ${CXXFLAGS} -Wl,--gc-sections -o $@ ${OBJECTS}
${QUIET}avr-size --format=avr --mcu=${MCU} $@
+ ${QUIET}test $$(avr-size --format=avr --mcu=${MCU} build/system.elf | fgrep Program | grep -o '[0-9.]*%' | cut -d . -f 1) -lt 100
build/system.hex: build/system.elf
${QUIET}${OBJCOPY} -O ihex ${@:.hex=.elf} $@
diff --git a/src/arch/arduino-nano/Makefile.inc b/src/arch/arduino-nano/Makefile.inc
index 8896681..50109eb 100644
--- a/src/arch/arduino-nano/Makefile.inc
+++ b/src/arch/arduino-nano/Makefile.inc
@@ -79,6 +79,7 @@ OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o}
build/system.elf: ${OBJECTS}
${QUIET}${CXX} ${COMMON_FLAGS} ${CXXFLAGS} -Wl,--gc-sections -o $@ ${OBJECTS}
${QUIET}avr-size --format=avr --mcu=${MCU} $@
+ ${QUIET}test $$(avr-size --format=avr --mcu=${MCU} build/system.elf | fgrep Program | grep -o '[0-9.]*%' | cut -d . -f 1) -lt 100
build/system.hex: build/system.elf
${QUIET}${OBJCOPY} -O ihex ${@:.hex=.elf} $@