summaryrefslogtreecommitdiff
path: root/tmk_core/avr.mk
diff options
context:
space:
mode:
authorDrashna Jael're <drashna@live.com>2021-06-29 12:23:03 -0700
committerDrashna Jael're <drashna@live.com>2021-06-29 12:24:07 -0700
commitacf2c323e2927f6007b17ded577cf49fd86fec6c (patch)
tree8334dc5c71e6ab9bf33c76143eac7bb0e60159b0 /tmk_core/avr.mk
parentec7a7beeed3046e9144d4c4ce0ef3b2c4f9e4341 (diff)
parentf55e39e8a2246f6f96fd5d4a84a866e2615cde7b (diff)
Merge upstream QMK Firmware at '0.12.52~1'
Diffstat (limited to 'tmk_core/avr.mk')
-rw-r--r--tmk_core/avr.mk72
1 files changed, 41 insertions, 31 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index dcdb6a449a..2bc7cc9553 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -154,38 +154,45 @@ 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; \
+ elif [ "`uname`" = "FreeBSD" ]; then \
+ ls /dev/tty* | grep -v '\.lock$$' | grep -v '\.init$$'; \
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 +211,7 @@ avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_AVRDUDE,eeprom-righthand.eep)
define EXEC_USBASP
- avrdude -p $(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
@@ -283,8 +290,11 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
$(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof
bootloader:
+ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
+ $(error Please set BOOTLOADER = qmk-dfu first!)
+endif
make -C lib/lufa/Bootloaders/DFU/ clean
- $(TMK_DIR)/make_dfu_header.sh $(ALL_CONFIGS)
+ bin/qmk generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
$(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))