aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPurdea Andrei <andrei@purdea.ro>2021-06-16 07:20:44 +0300
committerGitHub <noreply@github.com>2021-06-16 14:20:44 +1000
commited0451bc28dc5ffcc3031bf9918a25e9fb8db2f7 (patch)
tree9f9f28329413adfa7c62bfe0219a346d87880b29
parent22cd151fc359f48d75e361bd46a25ab6b40425fa (diff)
downloadqmk_firmware-ed0451bc28dc5ffcc3031bf9918a25e9fb8db2f7.tar.gz
qmk_firmware-ed0451bc28dc5ffcc3031bf9918a25e9fb8db2f7.zip
Make atmel-dfu and chibios-dfu flashing behave more like caterina flashing. (#12552)
This commit makes atmel-dfu and chibios-dfu bootloaders retry to detect the bootloader every 0,5 seconds (now configurable via the BOOTLOADER_RETRY_TIME makefile variable), and a period is printed after every try. This is a much more pleasant behaviour than the 5s retry timeout.
-rw-r--r--message.mk2
-rw-r--r--tmk_core/avr.mk18
-rw-r--r--tmk_core/chibios.mk13
3 files changed, 23 insertions, 10 deletions
diff --git a/message.mk b/message.mk
index 79d195739..da5f9fb9e 100644
--- a/message.mk
+++ b/message.mk
@@ -93,3 +93,5 @@ MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Can not run \"qmk\" command
93MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n 93MSG_FLASH_BOOTLOADER = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's bootloader is not specified or is not supported by the \":flash\" target at this time.\n\n
94MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n 94MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
95MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) Bootloader not found. Trying again in 5s.\n 95MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) Bootloader not found. Trying again in 5s.\n
96BOOTLOADER_RETRY_TIME ?= 0.5
97MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = Bootloader not found. Trying again every $(BOOTLOADER_RETRY_TIME)s
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 521305f1b..eb934ffe6 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -113,10 +113,16 @@ define EXEC_DFU
113 if [ "$(1)" ]; then \ 113 if [ "$(1)" ]; then \
114 echo "Flashing '$(1)' for EE_HANDS split keyboard support." ;\ 114 echo "Flashing '$(1)' for EE_HANDS split keyboard support." ;\
115 fi; \ 115 fi; \
116 until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ 116 if ! $(DFU_PROGRAMMER) $(MCU) get bootloader-version >/dev/null 2>/dev/null; then\
117 printf "$(MSG_BOOTLOADER_NOT_FOUND)" ;\ 117 printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
118 sleep 5 ;\ 118 sleep $(BOOTLOADER_RETRY_TIME) ;\
119 done; \ 119 while ! $(DFU_PROGRAMMER) $(MCU) get bootloader-version >/dev/null 2>/dev/null; do\
120 printf "." ;\
121 sleep $(BOOTLOADER_RETRY_TIME) ;\
122 done ;\
123 printf "\n" ;\
124 fi; \
125 $(DFU_PROGRAMMER) $(MCU) get bootloader-version ;\
120 if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\ 126 if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\
121 $(DFU_PROGRAMMER) $(MCU) erase --force; \ 127 $(DFU_PROGRAMMER) $(MCU) erase --force; \
122 if [ "$(1)" ]; then \ 128 if [ "$(1)" ]; then \
@@ -172,7 +178,7 @@ define EXEC_AVRDUDE
172 TMP2=`mktemp`; \ 178 TMP2=`mktemp`; \
173 list_devices > $$TMP1; \ 179 list_devices > $$TMP1; \
174 while [ -z "$$USB" ]; do \ 180 while [ -z "$$USB" ]; do \
175 sleep 0.5; \ 181 sleep $(BOOTLOADER_RETRY_TIME); \
176 printf "."; \ 182 printf "."; \
177 list_devices > $$TMP2; \ 183 list_devices > $$TMP2; \
178 USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \ 184 USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
@@ -187,7 +193,7 @@ define EXEC_AVRDUDE
187 sleep 1; \ 193 sleep 1; \
188 else \ 194 else \
189 printf "Waiting for $$USB to become writable."; \ 195 printf "Waiting for $$USB to become writable."; \
190 while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \ 196 while [ ! -w "$$USB" ]; do sleep $(BOOTLOADER_RETRY_TIME); printf "."; done; echo ""; \
191 fi; \ 197 fi; \
192 if [ -z "$(1)" ]; then \ 198 if [ -z "$(1)" ]; then \
193 $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \ 199 $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index cdf9ba649..97299b7d3 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -341,10 +341,15 @@ ST_LINK_CLI ?= st-link_cli
341ST_FLASH ?= st-flash 341ST_FLASH ?= st-flash
342 342
343define EXEC_DFU_UTIL 343define EXEC_DFU_UTIL
344 until $(DFU_UTIL) -l | grep -q "Found DFU"; do\ 344 if ! $(DFU_UTIL) -l | grep -q "Found DFU"; then \
345 printf "$(MSG_BOOTLOADER_NOT_FOUND)" ;\ 345 printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
346 sleep 5 ;\ 346 sleep $(BOOTLOADER_RETRY_TIME) ;\
347 done 347 while ! $(DFU_UTIL) -l | grep -q "Found DFU"; do \
348 printf "." ;\
349 sleep $(BOOTLOADER_RETRY_TIME) ;\
350 done ;\
351 printf "\n" ;\
352 fi
348 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin 353 $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
349endef 354endef
350 355