summary refs log tree commit diff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-10-26 21:21:43 -0700
committerJack Humbert <jack.humb@gmail.com>2018-10-27 00:21:43 -0400
commitf16b5cc92b1fb3f5c551d009b11f291ee650b432 (patch)
tree367c53c0c702ff482814dfd6657d009a488c3fa9
parent5632552558fc5e032e89c62d578dff7d3c3cb800 (diff)
Add delayed flashing option for DFU Util (#4225)
* 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
-rw-r--r--tmk_core/chibios.mk18
1 files changed, 18 insertions, 0 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 014c8d502a..0f665450ac 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -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