]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - tmk_core/avr.mk
update layout macros for planck
[qmk_firmware.git] / tmk_core / avr.mk
index 6773726ee3e59754b88dcb2c3b9b67baa2353638..0e014a412aa7957be40f33e03b9f27e654266485 100644 (file)
@@ -12,7 +12,7 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature
 EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) 
 BIN =
 
-
+COMMON_VPATH += $(DRIVER_PATH)/avr
 
 COMPILEFLAGS += -funsigned-char
 COMPILEFLAGS += -funsigned-bitfields
@@ -144,10 +144,31 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
        fi
        $(DFU_PROGRAMMER) $(MCU) reset
 
+avrdude: $(BUILD_DIR)/$(TARGET).hex
+       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 AVRDUDE, AVRDUDESS, or XLoader.'; \
+       else \
+               ls /dev/tty* > /tmp/1; \
+               echo "Detecting USB port, reset your controller now.\c"; \
+               while [ -z $$USB ]; do \
+                       sleep 1; \
+                       echo ".\c"; \
+                       ls /dev/tty* > /tmp/2; \
+                       USB=`diff /tmp/1 /tmp/2 | grep -o '/dev/tty.*'`; \
+               done; \
+               echo ""; \
+               echo "Detected controller on USB port at $$USB"; \
+               sleep 1; \
+               avrdude -p $(MCU) -c avr109 -P $$USB -U flash:w:$(BUILD_DIR)/$(TARGET).hex; \
+       fi
+
 # Convert hex to bin.
-flashbin: $(BUILD_DIR)/$(TARGET).hex
+bin: $(BUILD_DIR)/$(TARGET).hex
        $(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
        $(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
+
+# copy bin to FLASH.bin
+flashbin: bin
        $(COPY) $(BUILD_DIR)/$(TARGET).bin FLASH.bin; 
 
 # Generate avr-gdb config/init file which does the following: