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.
This commit is contained in:
Matthijs Kooijman 2013-05-30 15:01:07 +02:00
parent c64f38ae6d
commit 5ea2437311

View file

@ -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)