diff --git a/HISTORY.md b/HISTORY.md index 8c24017..0d79497 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -11,6 +11,7 @@ The following is the rough list of changes that went into different versions. I - Auto detect alternate core path from sketchbook folder. Fix issue #86 - Remove redundant checks for ARDUINO_DIR - Improve avrdude and avrdude.conf path auto detection. Fix issue #48 +- Move binary sketch size verification logic inside makefile. Fix issue #54 ### 0.12.0 (2013-06-20) - Fix "generated_assembly" target, which got broken earlier. Fix issue #76 (https://github.com/matthijskooijman) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 3e98c9f..12ad2f6 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -879,8 +879,13 @@ $(OBJDIR)/%.o: $(ARDUINO_CORE_PATH)/%.cpp $(COMMON_DEPS) | $(OBJDIR) $(OBJDIR)/%.hex: $(OBJDIR)/%.elf $(COMMON_DEPS) $(OBJCOPY) -O ihex -R .eeprom $< $@ @$(ECHO) - @$(ECHO) $(call avr_size,$<,$@) +ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) + @if [ `$(SIZE) $@ | awk 'FNR == 2 {print $$2}'` -le $(HEX_MAXIMUM_SIZE) ]; then touch $@.sizeok; fi +else + @$(ECHO) Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $@ is less than $(BOARD_TAG)\'s flash memory + @touch $@.sizeok +endif $(OBJDIR)/%.eep: $(OBJDIR)/%.elf $(COMMON_DEPS) -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ @@ -968,7 +973,7 @@ endif # Explicit targets start here # -all: $(TARGET_EEP) $(TARGET_HEX) verify_size +all: $(TARGET_EEP) $(TARGET_HEX) # Rule to create $(OBJDIR) automatically. All rules with recipes that # create a file within it, but do not already depend on a file within it @@ -1060,15 +1065,14 @@ disasm: $(OBJDIR)/$(TARGET).lss symbol_sizes: $(OBJDIR)/$(TARGET).sym @$(ECHO) A symbol listing sorted by their size have been dumped to $(OBJDIR)/$(TARGET).sym -$(TARGET_HEX).sizeok: $(TARGET_HEX) -ifneq ($(strip $(HEX_MAXIMUM_SIZE)),) - $(ARDMK_PATH)/ard-verify-size $(TARGET_HEX) $(HEX_MAXIMUM_SIZE) - touch $@ -else - @$(ECHO) Maximum Hex size is not specified. Make sure the hex file that you are going to upload is less than microcontrollers flash memory +verify_size: +ifeq ($(strip $(HEX_MAXIMUM_SIZE)),) + @$(ECHO) + @$(ECHO) Maximum flash memory of $(BOARD_TAG) is not specified. Make sure the size of $(TARGET_HEX) is less than $(BOARD_TAG)\'s flash memory + @$(ECHO) endif - -verify_size: $(TARGET_HEX) $(TARGET_HEX).sizeok + @if [ ! -f $(TARGET_HEX).sizeok ]; then echo >&2 "\nThe size of the compiled binary file is greater than the $(BOARD_TAG)'s flash memory. \ +See http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it."; false; fi generate_assembly: $(OBJDIR)/$(TARGET).s @$(ECHO) Compiler-generated assembly for the main input source has been dumped to $(OBJDIR)/$(TARGET).s diff --git a/bin/ard-verify-size b/bin/ard-verify-size deleted file mode 100755 index 2a7fa28..0000000 --- a/bin/ard-verify-size +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -TARGET_HEX="$1" -MAX_SIZE="$2" -HEX_SIZE="$(cut -c12- < $TARGET_HEX | tr -d \\n | tr -d \\r | wc -c | awk '{print $1/2}')" -if [ $HEX_SIZE -gt $MAX_SIZE ] -then - echo "Sketch size is ${HEX_SIZE} bytes and maximum allowed is ${MAX_SIZE} bytes; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it." 1>&2 - exit 1 -fi