From 5ea24373116beffea81675a12363be08e2d0e0c8 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Thu, 30 May 2013 15:01:07 +0200 Subject: [PATCH] Fix raw_upload and reset for normal uploads In commit 90e3c9ad (Fix upload in case of parallelized make), some dependencies were shuffled to (I assume) prevent the reset from happening before or at the same time as the upload when running a parallel make. However, this introduced two problems: - The upload and raw_upload became effectively the same, and both of them did a reset (even though raw_upload should do the upload without a reset). - The reset target does not depend on $(TARGET_HEX) or verify_size, so in a parallel make the reset is executed before / at the same time as the actual compilation (since the reset doesn't seem to be needed for at least the Arduino Uno, apparently avrdude handles this, this probably wasn't noticed by anyone). Because we can't force a specific ordering of dependencies in parallel make and because adding dependencies to the reset target doesn't seem appropriate (you should be able to do a "make reset" without needing to compile everything first), this commit changes the uploading to call $(MAKE) again to do the actual upload. The current approach ensures that: - raw_upload does a compile, size check and upload and upload does the same plus a reset. - A reset is not done if the compilation fails or the size check fails. - verify_size is called only once. --- arduino-mk/Arduino.mk | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arduino-mk/Arduino.mk b/arduino-mk/Arduino.mk index 79878f6..1064160 100644 --- a/arduino-mk/Arduino.mk +++ b/arduino-mk/Arduino.mk @@ -951,9 +951,16 @@ $(CORE_LIB): $(CORE_OBJS) $(LIB_OBJS) $(USER_LIB_OBJS) $(DEP_FILE): $(OBJDIR) $(DEPS) cat $(DEPS) > $(DEP_FILE) -upload: raw_upload +upload: $(TARGET_HEX) verify_size + # Use submake so we can guarantee the reset happens + # before the upload, even with make -j + $(MAKE) reset + $(MAKE) do_upload -raw_upload: reset $(TARGET_HEX) verify_size +raw_upload: $(TARGET_HEX) verify_size + $(MAKE) do_upload + +do_upload: $(AVRDUDE) $(AVRDUDE_COM_OPTS) $(AVRDUDE_ARD_OPTS) \ $(AVRDUDE_UPLOAD_HEX)