aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/avr.mk
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/avr.mk')
-rw-r--r--tmk_core/avr.mk42
1 files changed, 23 insertions, 19 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 5df539def..ccecdb192 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -89,9 +89,9 @@ DEBUG_HOST = localhost
89#============================================================================ 89#============================================================================
90# Autodecct teensy loader 90# Autodecct teensy loader
91ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) 91ifneq (, $(shell which teensy-loader-cli 2>/dev/null))
92 TEENSY_LOADER_CLI = teensy-loader-cli 92 TEENSY_LOADER_CLI ?= teensy-loader-cli
93else 93else
94 TEENSY_LOADER_CLI = teensy_loader_cli 94 TEENSY_LOADER_CLI ?= teensy_loader_cli
95endif 95endif
96 96
97# Program the device. 97# Program the device.
@@ -100,43 +100,47 @@ program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
100 100
101teensy: $(BUILD_DIR)/$(TARGET).hex 101teensy: $(BUILD_DIR)/$(TARGET).hex
102 $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex 102 $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
103
104BATCHISP ?= batchisp
103 105
104flip: $(BUILD_DIR)/$(TARGET).hex 106flip: $(BUILD_DIR)/$(TARGET).hex
105 batchisp -hardware usb -device $(MCU) -operation erase f 107 $(BATCHISP) -hardware usb -device $(MCU) -operation erase f
106 batchisp -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program 108 $(BATCHISP) -hardware usb -device $(MCU) -operation loadbuffer $(BUILD_DIR)/$(TARGET).hex program
107 batchisp -hardware usb -device $(MCU) -operation start reset 0 109 $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0
110
111DFU_PROGRAMMER ?= dfu-programmer
108 112
109dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter 113dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter
110 until dfu-programmer $(MCU) get bootloader-version; do\ 114 until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\
111 echo "Error: Bootloader not found. Trying again in 5s." ;\ 115 echo "Error: Bootloader not found. Trying again in 5s." ;\
112 sleep 5 ;\ 116 sleep 5 ;\
113 done 117 done
114ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) 118ifneq (, $(findstring 0.7, $(shell $(DFU_PROGRAMMER) --version 2>&1)))
115 dfu-programmer $(MCU) erase --force 119 $(DFU_PROGRAMMER) $(MCU) erase --force
116else 120else
117 dfu-programmer $(MCU) erase 121 $(DFU_PROGRAMMER) $(MCU) erase
118endif 122endif
119 dfu-programmer $(MCU) flash $(BUILD_DIR)/$(TARGET).hex 123 $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex
120 dfu-programmer $(MCU) reset 124 $(DFU_PROGRAMMER) $(MCU) reset
121 125
122dfu-start: 126dfu-start:
123 dfu-programmer $(MCU) reset 127 $(DFU_PROGRAMMER) $(MCU) reset
124 dfu-programmer $(MCU) start 128 $(DFU_PROGRAMMER) $(MCU) start
125 129
126flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep 130flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
127 $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex 131 $(COPY) $(BUILD_DIR)/$(TARGET).eep $(BUILD_DIR)/$(TARGET)eep.hex
128 batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase 132 $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM erase
129 batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program 133 $(BATCHISP) -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(BUILD_DIR)/$(TARGET)eep.hex program
130 batchisp -hardware usb -device $(MCU) -operation start reset 0 134 $(BATCHISP) -hardware usb -device $(MCU) -operation start reset 0
131 $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex 135 $(REMOVE) $(BUILD_DIR)/$(TARGET)eep.hex
132 136
133dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep 137dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
134ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) 138ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1)))
135 dfu-programmer $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep 139 $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(BUILD_DIR)/$(TARGET).eep
136else 140else
137 dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep 141 $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep
138endif 142endif
139 dfu-programmer $(MCU) reset 143 $(DFU_PROGRAMMER) $(MCU) reset
140 144
141# Convert hex to bin. 145# Convert hex to bin.
142flashbin: $(BUILD_DIR)/$(TARGET).hex 146flashbin: $(BUILD_DIR)/$(TARGET).hex