]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add delayed flashing option for DFU Util (#4225)
authorDrashna Jaelre <drashna@live.com>
Sat, 27 Oct 2018 04:21:43 +0000 (21:21 -0700)
committerJack Humbert <jack.humb@gmail.com>
Sat, 27 Oct 2018 04:21:43 +0000 (00:21 -0400)
* Add delayed flashing option for DFU Util

* Use a loop to make code cleaner

* Make delay configurable but default to 10

* Better formatting of check

tmk_core/chibios.mk

index 014c8d502ad9cec36fa13dd11b0e0187c4b345db..0f665450ac56427a99ffc851f951feacbf9d2bb7 100644 (file)
@@ -233,6 +233,24 @@ qmk: $(BUILD_DIR)/$(TARGET).bin
 dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
        $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
 
+
+ifneq ($(strip $(TIME_DELAY)),)
+  TIME_DELAY = $(strip $(TIME_DELAY))
+else
+  TIME_DELAY = 10
+endif
+dfu-util-wait: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
+       echo "Preparing to flash firmware. Please enter bootloader now..." ;\
+  COUNTDOWN=$(TIME_DELAY) ;\
+  while [[ $$COUNTDOWN -ge 1 ]] ; do \
+        echo "Flashing in $$COUNTDOWN ..."; \
+        sleep 1 ;\
+        ((COUNTDOWN = COUNTDOWN - 1)) ; \
+  done; \
+  echo "Flashing $(TARGET).bin" ;\
+  sleep 1 ;\
+  $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
+
 st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
        $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst