diff options
Diffstat (limited to 'tmk_core/avr.mk')
| -rw-r--r-- | tmk_core/avr.mk | 42 |
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 |
| 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) | 91 | ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) |
| 92 | TEENSY_LOADER_CLI = teensy-loader-cli | 92 | TEENSY_LOADER_CLI ?= teensy-loader-cli |
| 93 | else | 93 | else |
| 94 | TEENSY_LOADER_CLI = teensy_loader_cli | 94 | TEENSY_LOADER_CLI ?= teensy_loader_cli |
| 95 | endif | 95 | endif |
| 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 | ||
| 101 | teensy: $(BUILD_DIR)/$(TARGET).hex | 101 | teensy: $(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 | |||
| 104 | BATCHISP ?= batchisp | ||
| 103 | 105 | ||
| 104 | flip: $(BUILD_DIR)/$(TARGET).hex | 106 | flip: $(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 | |||
| 111 | DFU_PROGRAMMER ?= dfu-programmer | ||
| 108 | 112 | ||
| 109 | dfu: $(BUILD_DIR)/$(TARGET).hex sizeafter | 113 | dfu: $(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 |
| 114 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 118 | ifneq (, $(findstring 0.7, $(shell $(DFU_PROGRAMMER) --version 2>&1))) |
| 115 | dfu-programmer $(MCU) erase --force | 119 | $(DFU_PROGRAMMER) $(MCU) erase --force |
| 116 | else | 120 | else |
| 117 | dfu-programmer $(MCU) erase | 121 | $(DFU_PROGRAMMER) $(MCU) erase |
| 118 | endif | 122 | endif |
| 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 | ||
| 122 | dfu-start: | 126 | dfu-start: |
| 123 | dfu-programmer $(MCU) reset | 127 | $(DFU_PROGRAMMER) $(MCU) reset |
| 124 | dfu-programmer $(MCU) start | 128 | $(DFU_PROGRAMMER) $(MCU) start |
| 125 | 129 | ||
| 126 | flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 130 | flip-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 | ||
| 133 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep | 137 | dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep |
| 134 | ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) | 138 | ifneq (, $(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 |
| 136 | else | 140 | else |
| 137 | dfu-programmer $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep | 141 | $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(BUILD_DIR)/$(TARGET).eep |
| 138 | endif | 142 | endif |
| 139 | dfu-programmer $(MCU) reset | 143 | $(DFU_PROGRAMMER) $(MCU) reset |
| 140 | 144 | ||
| 141 | # Convert hex to bin. | 145 | # Convert hex to bin. |
| 142 | flashbin: $(BUILD_DIR)/$(TARGET).hex | 146 | flashbin: $(BUILD_DIR)/$(TARGET).hex |
