summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/arm_atsam.mk3
-rw-r--r--tmk_core/avr.mk91
-rw-r--r--tmk_core/chibios.mk26
-rw-r--r--tmk_core/rules.mk5
4 files changed, 81 insertions, 44 deletions
diff --git a/tmk_core/arm_atsam.mk b/tmk_core/arm_atsam.mk
index 25a3411f4f..c9b14042f8 100644
--- a/tmk_core/arm_atsam.mk
+++ b/tmk_core/arm_atsam.mk
@@ -54,3 +54,6 @@ EXTRALIBDIRS =
bin: $(BUILD_DIR)/$(TARGET).hex
$(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
+
+flash: bin
+ $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_ARCH)"
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
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 4aebb47762..eee520467d 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -234,9 +234,12 @@ qmk: $(BUILD_DIR)/$(TARGET).bin
zip $(TARGET).qmk -urj $(BUILD_DIR)/$(TARGET).json
printf "@ $(TARGET).json\n@=info.json\n" | zipnote -w $(TARGET).qmk
-dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
+define EXEC_DFU_UTIL
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
+endef
+dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
+ $(call EXEC_DFU_UTIL)
ifneq ($(strip $(TIME_DELAY)),)
TIME_DELAY = $(strip $(TIME_DELAY))
@@ -253,7 +256,7 @@ dfu-util-wait: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
done; \
echo "Flashing $(TARGET).bin" ;\
sleep 1 ;\
- $(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
+ $(call EXEC_DFU_UTIL)
st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
$(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst
@@ -268,7 +271,24 @@ ifndef TEENSY_LOADER_CLI
endif
endif
-teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
+define EXEC_TEENSY
$(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex
+endef
+
+teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
+ $(call EXEC_TEENSY)
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
+ $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
+
+
+flash: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
+ifeq ($(strip $(BOOTLOADER)),dfu)
+ $(call EXEC_DFU_UTIL)
+else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
+ $(call EXEC_TEENSY)
+else ifeq ($(strip $(MCU_FAMILY)),STM32)
+ $(call EXEC_DFU_UTIL)
+else
+ $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)"
+endif
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk
index e51dbfe7c6..31bce33c39 100644
--- a/tmk_core/rules.mk
+++ b/tmk_core/rules.mk
@@ -433,4 +433,7 @@ $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null)))
.PHONY : all finish sizebefore sizeafter qmkversion \
gccversion build elf hex eep lss sym coff extcoff \
clean clean_list debug gdb-config show_path \
-program teensy dfu flip dfu-ee flip-ee dfu-start
+program teensy dfu flip dfu-ee flip-ee dfu-start \
+flash dfu-split-left dfu-split-right \
+avrdude-split-left avrdude-split-right \
+avrdude-loop usbasp