summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-04-03 17:29:06 +0100
committerGitHub <noreply@github.com>2021-04-03 17:29:06 +0100
commit60e1910e5b4f83a07aebbb0d75276ecda6c50e27 (patch)
treed00fa860a4a3dd9314f8a15726b78a6ca8baabf0
parent4e2ab3a17734fa0460e259b835e2ea1dbfd72d75 (diff)
Add WSL specific logic for avrdude device detection (#12392)
-rw-r--r--tmk_core/avr.mk65
1 files changed, 35 insertions, 30 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index f9c56e06de..c1d3f6b39e 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -154,38 +154,43 @@ dfu-split-left: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
dfu-split-right: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
$(call EXEC_DFU,eeprom-righthand.eep)
+AVRDUDE_PROGRAMMER ?= avrdude
+
define EXEC_AVRDUDE
- USB= ;\
- if $(GREP) -q -s Microsoft /proc/version; then \
- echo 'ERROR: AVR flashing cannot be automated within the Windows Subsystem for Linux (WSL) currently. Instead, take the .hex file generated and flash it using QMK Toolbox, AVRDUDE, AVRDUDESS, or XLoader.'; \
- else \
- printf "Detecting USB port, reset your controller now."; \
- TMP1=`mktemp`; \
- TMP2=`mktemp`; \
- ls /dev/tty* > $$TMP1; \
- while [ -z $$USB ]; do \
- sleep 0.5; \
- printf "."; \
- ls /dev/tty* > $$TMP2; \
- USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
- mv $$TMP2 $$TMP1; \
- done; \
- rm $$TMP1; \
- echo ""; \
- echo "Device $$USB has appeared; assuming it is the controller."; \
- if $(GREP) -q -s 'MINGW\|MSYS' /proc/version; then \
- USB=`echo "$$USB" | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
- echo "Remapped MSYS2 USB port to $$USB"; \
- sleep 1; \
+ list_devices() { \
+ if $(GREP) -q -s icrosoft /proc/version; then \
+ wmic.exe path Win32_SerialPort get DeviceID 2>/dev/null | LANG=C perl -pne 's/COM(\d+)/COM.($$1-1)/e' | sed 's!COM!/dev/ttyS!' | xargs echo -n | sort; \
else \
- printf "Waiting for $$USB to become writable."; \
- while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
+ ls /dev/tty*; \
fi; \
- if [ -z "$(1)" ]; then \
- avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
- else \
- avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \
- fi \
+ }; \
+ USB= ;\
+ printf "Detecting USB port, reset your controller now."; \
+ TMP1=`mktemp`; \
+ TMP2=`mktemp`; \
+ list_devices > $$TMP1; \
+ while [ -z $$USB ]; do \
+ sleep 0.5; \
+ printf "."; \
+ list_devices > $$TMP2; \
+ USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
+ mv $$TMP2 $$TMP1; \
+ done; \
+ rm $$TMP1; \
+ echo ""; \
+ echo "Device $$USB has appeared; assuming it is the controller."; \
+ if $(GREP) -q -s 'MINGW\|MSYS\|icrosoft' /proc/version; then \
+ USB=`echo "$$USB" | LANG=C perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
+ echo "Remapped USB port to $$USB"; \
+ sleep 1; \
+ else \
+ printf "Waiting for $$USB to become writable."; \
+ while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
+ fi; \
+ if [ -z "$(1)" ]; then \
+ $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
+ else \
+ $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \
fi
endef
@@ -204,7 +209,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_AVRDUDE,eeprom-righthand.eep)
define EXEC_USBASP
- avrdude -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
+ $(AVRDUDE_PROGRAMMER) -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
endef
usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware