diff options
author | Drashna Jaelre <drashna@live.com> | 2019-08-20 15:39:24 -0700 |
---|---|---|
committer | Yan-Fa Li <yanfali@gmail.com> | 2019-08-20 15:39:24 -0700 |
commit | 4003d077cef42d7a3405250ea6417db3a3549e9e (patch) | |
tree | 012079bc5fac326baafaba6514843e7ef0a05e5e /tmk_core/avr.mk | |
parent | 91ee6a1dbb6f43ac708b0dc301f5cbcef6dcfdf5 (diff) |
Add a universal flash command for cli (#6224)
* Add universal flash command
* Add bootloader info to I:C boards
* Add support for ATSAM
* Add messages for flash target
* Message cleanup
* Add USB ASP Flashing target
* Make usbasp target more universal
* Add phoney target for usbasp
* Clarify error message when bootloader isn't matched
Diffstat (limited to 'tmk_core/avr.mk')
-rw-r--r-- | tmk_core/avr.mk | 91 |
1 files changed, 51 insertions, 40 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk index 5bfd5a9b0d..e5443418b9 100644 --- a/tmk_core/avr.mk +++ b/tmk_core/avr.mk @@ -89,11 +89,11 @@ DEBUG_HOST = localhost #============================================================================ # Autodetect teensy loader ifndef TEENSY_LOADER_CLI - ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) - TEENSY_LOADER_CLI ?= teensy-loader-cli - else - TEENSY_LOADER_CLI ?= teensy_loader_cli - endif + ifneq (, $(shell which teensy-loader-cli 2>/dev/null)) + TEENSY_LOADER_CLI ?= teensy-loader-cli + else + TEENSY_LOADER_CLI ?= teensy_loader_cli + endif endif # Generate a .qmk for the QMK-FF @@ -124,8 +124,12 @@ qmk: $(BUILD_DIR)/$(TARGET).hex program: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep check-size $(PROGRAM_CMD) -teensy: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware +define EXEC_TEENSY $(TEENSY_LOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex +endef + +teensy: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware + $(call EXEC_TEENSY) BATCHISP ?= batchisp @@ -137,18 +141,32 @@ flip: $(BUILD_DIR)/$(TARGET).hex check-size DFU_PROGRAMMER ?= dfu-programmer GREP ?= grep -dfu: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size + +define EXEC_DFU + if [ "$(1)" ]; then \ + echo "Flashing '$(1)' for EE_HANDS split keyboard support." ;\ + fi; \ until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ echo "Error: Bootloader not found. Trying again in 5s." ;\ sleep 5 ;\ - done + done; \ if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\ - $(DFU_PROGRAMMER) $(MCU) erase --force;\ - else\ - $(DFU_PROGRAMMER) $(MCU) erase;\ - fi - $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex + $(DFU_PROGRAMMER) $(MCU) erase --force; \ + if [ "$(1)" ]; then \ + $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(QUANTUM_PATH)/split_common/$(1);\ + fi; \ + else \ + $(DFU_PROGRAMMER) $(MCU) erase; \ + if [ "$(1)" ]; then \ + $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(QUANTUM_PATH)/split_common/$(1);\ + fi; \ + fi; \ + $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex;\ $(DFU_PROGRAMMER) $(MCU) reset +endef + +dfu: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size + $(call EXEC_DFU) dfu-start: $(DFU_PROGRAMMER) $(MCU) reset @@ -170,34 +188,10 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep $(DFU_PROGRAMMER) $(MCU) reset dfu-split-left: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size - until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ - echo "Error: Bootloader not found. Trying again in 5s." ;\ - sleep 5 ;\ - done - if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\ - $(DFU_PROGRAMMER) $(MCU) erase --force;\ - $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(QUANTUM_PATH)/split_common/eeprom-lefthand.eep;\ - else\ - $(DFU_PROGRAMMER) $(MCU) erase;\ - $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(QUANTUM_PATH)/split_common/eeprom-lefthand.eep;\ - fi - $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex - $(DFU_PROGRAMMER) $(MCU) reset + $(call EXEC_DFU,eeprom-lefthand.eep) dfu-split-right: $(BUILD_DIR)/$(TARGET).hex cpfirmware check-size - until $(DFU_PROGRAMMER) $(MCU) get bootloader-version; do\ - echo "Error: Bootloader not found. Trying again in 5s." ;\ - sleep 5 ;\ - done - if $(DFU_PROGRAMMER) --version 2>&1 | $(GREP) -q 0.7 ; then\ - $(DFU_PROGRAMMER) $(MCU) erase --force;\ - $(DFU_PROGRAMMER) $(MCU) flash --eeprom $(QUANTUM_PATH)/split_common/eeprom-righthand.eep;\ - else\ - $(DFU_PROGRAMMER) $(MCU) erase;\ - $(DFU_PROGRAMMER) $(MCU) flash-eeprom $(QUANTUM_PATH)/split_common/eeprom-righthand.eep;\ - fi - $(DFU_PROGRAMMER) $(MCU) flash $(BUILD_DIR)/$(TARGET).hex - $(DFU_PROGRAMMER) $(MCU) reset + $(call EXEC_DFU,eeprom-righthand.eep) define EXEC_AVRDUDE USB= ;\ @@ -245,8 +239,12 @@ avrdude-split-left: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware avrdude-split-right: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware $(call EXEC_AVRDUDE,eeprom-righthand.eep) -usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware +define EXEC_USBASP avrdude -p $(MCU) -c usbasp -U flash:w:$(BUILD_DIR)/$(TARGET).hex +endef + +usbasp: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware + $(call EXEC_USBASP) # Convert hex to bin. @@ -323,3 +321,16 @@ production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware @cat $(TARGET)_bootloader.hex >> $(TARGET)_production.hex echo "File sizes:" $(SIZE) $(TARGET).hex $(TARGET)_bootloader.hex $(TARGET)_production.hex + +flash: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware +ifeq ($(strip $(BOOTLOADER)), caterina) + $(call EXEC_AVRDUDE) +else ifeq ($(strip $(BOOTLOADER)), halfkay) + $(call EXEC_TEENSY) +else ifeq (dfu,$(findstring dfu,$(BOOTLOADER))) + $(call EXEC_DFU) +else ifeq ($(strip $(BOOTLOADER)), USBasp) + $(call EXEC_USBASP) +else + $(PRINT_OK); $(SILENT) || printf "&(MSG_FLASH_BOOTLOADER)" +endif |