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.
master
Purdea Andrei 2021-06-16 07:20:44 +03:00 committed by GitHub
parent 22cd151fc3
commit ed0451bc28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 10 deletions

View File

@ -93,3 +93,5 @@ MSG_PYTHON_MISSING = $(ERROR_COLOR)ERROR:$(NO_COLOR) Can not run \"qmk\" command
MSG_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 MSG_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
MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n MSG_FLASH_ARCH = $(WARN_COLOR)WARNING:$(NO_COLOR) This board's architecture is not supported by the \":flash\" target at this time.\n\n
MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) Bootloader not found. Trying again in 5s.\n MSG_BOOTLOADER_NOT_FOUND = $(ERROR_COLOR)ERROR:$(NO_COLOR) Bootloader not found. Trying again in 5s.\n
BOOTLOADER_RETRY_TIME ?= 0.5
MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY = Bootloader not found. Trying again every $(BOOTLOADER_RETRY_TIME)s

View File

@ -113,10 +113,16 @@ define EXEC_DFU
if [ "$(1)" ]; then \ if [ "$(1)" ]; then \
echo "Flashing '$(1)' for EE_HANDS split keyboard support." ;\ echo "Flashing '$(1)' for EE_HANDS split keyboard support." ;\
fi; \ fi; \
until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ if ! $(DFU_PROGRAMMER) $(MCU) get bootloader-version >/dev/null 2>/dev/null; then\
printf "$(MSG_BOOTLOADER_NOT_FOUND)" ;\ printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
sleep 5 ;\ sleep $(BOOTLOADER_RETRY_TIME) ;\
done; \ while ! $(DFU_PROGRAMMER) $(MCU) get bootloader-version >/dev/null 2>/dev/null; do\
printf "." ;\
sleep $(BOOTLOADER_RETRY_TIME) ;\
done ;\
printf "\n" ;\
fi; \
$(DFU_PROGRAMMER) $(MCU) get bootloader-version ;\
if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\ if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\
$(DFU_PROGRAMMER) $(MCU) erase --force; \ $(DFU_PROGRAMMER) $(MCU) erase --force; \
if [ "$(1)" ]; then \ if [ "$(1)" ]; then \
@ -172,7 +178,7 @@ define EXEC_AVRDUDE
TMP2=`mktemp`; \ TMP2=`mktemp`; \
list_devices > $$TMP1; \ list_devices > $$TMP1; \
while [ -z "$$USB" ]; do \ while [ -z "$$USB" ]; do \
sleep 0.5; \ sleep $(BOOTLOADER_RETRY_TIME); \
printf "."; \ printf "."; \
list_devices > $$TMP2; \ list_devices > $$TMP2; \
USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \ USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
@ -187,7 +193,7 @@ define EXEC_AVRDUDE
sleep 1; \ sleep 1; \
else \ else \
printf "Waiting for $$USB to become writable."; \ printf "Waiting for $$USB to become writable."; \
while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \ while [ ! -w "$$USB" ]; do sleep $(BOOTLOADER_RETRY_TIME); printf "."; done; echo ""; \
fi; \ fi; \
if [ -z "$(1)" ]; then \ if [ -z "$(1)" ]; then \
$(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \ $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \

View File

@ -341,10 +341,15 @@ ST_LINK_CLI ?= st-link_cli
ST_FLASH ?= st-flash ST_FLASH ?= st-flash
define EXEC_DFU_UTIL define EXEC_DFU_UTIL
until $(DFU_UTIL) -l | grep -q "Found DFU"; do\ if ! $(DFU_UTIL) -l | grep -q "Found DFU"; then \
printf "$(MSG_BOOTLOADER_NOT_FOUND)" ;\ printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
sleep 5 ;\ sleep $(BOOTLOADER_RETRY_TIME) ;\
done while ! $(DFU_UTIL) -l | grep -q "Found DFU"; do \
printf "." ;\
sleep $(BOOTLOADER_RETRY_TIME) ;\
done ;\
printf "\n" ;\
fi
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
endef endef