aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/flashing.md6
-rw-r--r--tmk_core/chibios.mk22
2 files changed, 8 insertions, 20 deletions
diff --git a/docs/flashing.md b/docs/flashing.md
index 833b9dd62..d11dbdf15 100644
--- a/docs/flashing.md
+++ b/docs/flashing.md
@@ -171,7 +171,5 @@ Flashing sequence:
171 171
172There are a number of DFU commands that you can use to flash firmware to a STM32 device: 172There are a number of DFU commands that you can use to flash firmware to a STM32 device:
173 173
174* `:dfu-util` - The default command for flashing to STM32 devices. 174* `:dfu-util` - The default command for flashing to STM32 devices.
175* `:dfu-util-wait` - This works like the default command, but it gives you a (configurable) 10 second timeout before it attempts to flash the firmware. You can use `TIME_DELAY=20` from the command line to change the timeout. 175* `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.
176 * Eg: `make <keyboard>:<keymap>:dfu-util TIME_DELAY=5`
177* `:st-link-cli` - This allows you to flash the firmware via ST-LINK's CLI utility, rather than dfu-util.
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index eee520467..4b5b6d00b 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -235,28 +235,18 @@ qmk: $(BUILD_DIR)/$(TARGET).bin
235 printf "@ $(TARGET).json\n@=info.json\n" | zipnote -w $(TARGET).qmk 235 printf "@ $(TARGET).json\n@=info.json\n" | zipnote -w $(TARGET).qmk
236 236
237define EXEC_DFU_UTIL 237define EXEC_DFU_UTIL
238 until $(DFU_UTIL) -l | grep -q "Found DFU"; do\
239 echo "Error: Bootloader not found. Trying again in 5s." ;\
240 sleep 5 ;\
241 done
238 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin 242 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
239endef 243endef
240 244
241dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter 245dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
242 $(call EXEC_DFU_UTIL) 246 $(call EXEC_DFU_UTIL)
243 247
244ifneq ($(strip $(TIME_DELAY)),) 248# Legacy alias
245 TIME_DELAY = $(strip $(TIME_DELAY)) 249dfu-util-wait: dfu-util
246else
247 TIME_DELAY = 10
248endif
249dfu-util-wait: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
250 echo "Preparing to flash firmware. Please enter bootloader now..." ;\
251 COUNTDOWN=$(TIME_DELAY) ;\
252 while [[ $$COUNTDOWN -ge 1 ]] ; do \
253 echo "Flashing in $$COUNTDOWN ..."; \
254 sleep 1 ;\
255 ((COUNTDOWN = COUNTDOWN - 1)) ; \
256 done; \
257 echo "Flashing $(TARGET).bin" ;\
258 sleep 1 ;\
259 $(call EXEC_DFU_UTIL)
260 250
261st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter 251st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
262 $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst 252 $(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst