aboutsummaryrefslogtreecommitdiff
path: root/arduino-mk/Arduino.mk
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2013-05-30 15:01:07 +0200
committerMatthijs Kooijman <matthijs@stdin.nl>2013-05-30 19:27:10 +0200
commit5ea24373116beffea81675a12363be08e2d0e0c8 (patch)
tree8852b4a8a145f4c5be5d8b68fbc07143491885db /arduino-mk/Arduino.mk
parentc64f38ae6d3591e4b94f6ba8659e7ddf30446a14 (diff)
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.
Diffstat (limited to 'arduino-mk/Arduino.mk')
-rw-r--r--arduino-mk/Arduino.mk11
1 files 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)