aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-04-03 16:29:37 +0000
committerQMK Bot <hello@qmk.fm>2021-04-03 16:29:37 +0000
commit9bedc6300dfe7ac99a5233550b69140741888262 (patch)
treea46b8ba7401350c6254307e33398e1a9e0c2d3c8
parentcc4066189a263f8f8a416b6a9cf2e0fb51fe5f43 (diff)
parent60e1910e5b4f83a07aebbb0d75276ecda6c50e27 (diff)
downloadqmk_firmware-9bedc6300dfe7ac99a5233550b69140741888262.tar.gz
qmk_firmware-9bedc6300dfe7ac99a5233550b69140741888262.zip
Merge remote-tracking branch 'origin/master' into develop
-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 f9c56e06d..c1d3f6b39 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
154dfu-split-right: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size 154dfu-split-right: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size
155 $(call EXEC_DFU,eeprom-righthand.eep) 155 $(call EXEC_DFU,eeprom-righthand.eep)
156 156
157AVRDUDE_PROGRAMMER ?= avrdude
158
157define EXEC_AVRDUDE 159define EXEC_AVRDUDE
158 USB= ;\ 160 list_devices() { \
159 if $(GREP) -q -s Microsoft /proc/version; then \ 161 if $(GREP) -q -s icrosoft /proc/version; then \
160 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.'; \ 162 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; \
161 else \
162 printf "Detecting USB port, reset your controller now."; \
163 TMP1=`mktemp`; \
164 TMP2=`mktemp`; \
165 ls /dev/tty* > $$TMP1; \
166 while [ -z $$USB ]; do \
167 sleep 0.5; \
168 printf "."; \
169 ls /dev/tty* > $$TMP2; \
170 USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
171 mv $$TMP2 $$TMP1; \
172 done; \
173 rm $$TMP1; \
174 echo ""; \
175 echo "Device $$USB has appeared; assuming it is the controller."; \
176 if $(GREP) -q -s 'MINGW\|MSYS' /proc/version; then \
177 USB=`echo "$$USB" | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
178 echo "Remapped MSYS2 USB port to $$USB"; \
179 sleep 1; \
180 else \ 163 else \
181 printf "Waiting for $$USB to become writable."; \ 164 ls /dev/tty*; \
182 while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
183 fi; \ 165 fi; \
184 if [ -z "$(1)" ]; then \ 166 }; \
185 avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \ 167 USB= ;\
186 else \ 168 printf "Detecting USB port, reset your controller now."; \
187 avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \ 169 TMP1=`mktemp`; \
188 fi \ 170 TMP2=`mktemp`; \
171 list_devices > $$TMP1; \
172 while [ -z $$USB ]; do \
173 sleep 0.5; \
174 printf "."; \
175 list_devices > $$TMP2; \
176 USB=`comm -13 $$TMP1 $$TMP2 | $(GREP) -o '/dev/tty.*'`; \
177 mv $$TMP2 $$TMP1; \
178 done; \
179 rm $$TMP1; \
180 echo ""; \
181 echo "Device $$USB has appeared; assuming it is the controller."; \
182 if $(GREP) -q -s 'MINGW\|MSYS\|icrosoft' /proc/version; then \
183 USB=`echo "$$USB" | LANG=C perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e'`; \
184 echo "Remapped USB port to $$USB"; \
185 sleep 1; \
186 else \
187 printf "Waiting for $$USB to become writable."; \
188 while [ ! -w "$$USB" ]; do sleep 0.5; printf "."; done; echo ""; \
189 fi; \
190 if [ -z "$(1)" ]; then \
191 $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
192 else \
193 $(AVRDUDE_PROGRAMMER) -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex -U eeprom:w:$(QUANTUM_PATH)/split_common/$(1); \
189 fi 194 fi
190endef 195endef
191 196
@@ -204,7 +209,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
204 $(call EXEC_AVRDUDE,eeprom-righthand.eep) 209 $(call EXEC_AVRDUDE,eeprom-righthand.eep)
205 210
206define EXEC_USBASP 211define EXEC_USBASP
207 avrdude -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex 212 $(AVRDUDE_PROGRAMMER) -p $(AVRDUDE_MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex
208endef 213endef
209 214
210usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware 215usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware