@ -135,13 +135,14 @@ flip: $(BUILD_DIR)/$(TARGET).hex check-size
$( BATCHISP) -hardware usb -device $( MCU) -operation start reset 0
$( BATCHISP) -hardware usb -device $( MCU) -operation start reset 0
DFU_PROGRAMMER ?= dfu-programmer
DFU_PROGRAMMER ?= dfu-programmer
GREP ?= grep
dfu : $( BUILD_DIR ) /$( TARGET ) .hex cpfirmware check -size
dfu : $( BUILD_DIR ) /$( TARGET ) .hex cpfirmware check -size
until $( DFU_PROGRAMMER) $( MCU) get bootloader-version; do \
until $( DFU_PROGRAMMER) $( MCU) get bootloader-version; do \
echo "Error: Bootloader not found. Trying again in 5s." ; \
echo "Error: Bootloader not found. Trying again in 5s." ; \
sleep 5 ; \
sleep 5 ; \
done
done
if $( DFU_PROGRAMMER) --version 2>& 1 | grep -q 0.7 ; then \
if $( DFU_PROGRAMMER) --version 2>& 1 | $( GREP) -q 0.7 ; then \
$( DFU_PROGRAMMER) $( MCU) erase --force; \
$( DFU_PROGRAMMER) $( MCU) erase --force; \
else \
else \
$( DFU_PROGRAMMER) $( MCU) erase; \
$( DFU_PROGRAMMER) $( MCU) erase; \
@ -161,7 +162,7 @@ flip-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
$( REMOVE) $( BUILD_DIR) /$( TARGET) eep.hex
$( REMOVE) $( BUILD_DIR) /$( TARGET) eep.hex
dfu-ee : $( BUILD_DIR ) /$( TARGET ) .hex $( BUILD_DIR ) /$( TARGET ) .eep
dfu-ee : $( BUILD_DIR ) /$( TARGET ) .hex $( BUILD_DIR ) /$( TARGET ) .eep
if $( DFU_PROGRAMMER) --version 2>& 1 | grep -q 0.7 ; then \
if $( DFU_PROGRAMMER) --version 2>& 1 | $( GREP) -q 0.7 ; then \
$( DFU_PROGRAMMER) $( MCU) flash --eeprom $( BUILD_DIR) /$( TARGET) .eep; \
$( DFU_PROGRAMMER) $( MCU) flash --eeprom $( BUILD_DIR) /$( TARGET) .eep; \
else \
else \
$( DFU_PROGRAMMER) $( MCU) flash-eeprom $( BUILD_DIR) /$( TARGET) .eep; \
$( DFU_PROGRAMMER) $( MCU) flash-eeprom $( BUILD_DIR) /$( TARGET) .eep; \
@ -169,7 +170,7 @@ dfu-ee: $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).eep
$( DFU_PROGRAMMER) $( MCU) reset
$( DFU_PROGRAMMER) $( MCU) reset
avrdude : $( BUILD_DIR ) /$( TARGET ) .hex check -size
avrdude : $( BUILD_DIR ) /$( TARGET ) .hex check -size
if grep -q -s Microsoft /proc/version; then \
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.' ; \
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 \
else \
printf "Detecting USB port, reset your controller now." ; \
printf "Detecting USB port, reset your controller now." ; \
@ -178,12 +179,12 @@ avrdude: $(BUILD_DIR)/$(TARGET).hex check-size
sleep 0.5; \
sleep 0.5; \
printf "." ; \
printf "." ; \
ls /dev/tty* > /tmp/2; \
ls /dev/tty* > /tmp/2; \
USB = ` comm -13 /tmp/1 /tmp/2 | grep -o '/dev/tty.*' ` ; \
USB = ` comm -13 /tmp/1 /tmp/2 | $( GREP) -o '/dev/tty.*' ` ; \
mv /tmp/2 /tmp/1; \
mv /tmp/2 /tmp/1; \
done ; \
done ; \
echo "" ; \
echo "" ; \
echo " Detected controller on USB port at $$ USB " ; \
echo " Detected controller on USB port at $$ USB " ; \
if grep -q -s 'MINGW\|MSYS' /proc/version; then \
if $( GREP) -q -s 'MINGW\|MSYS' /proc/version; then \
USB = ` echo " $$ USB " | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e' ` ; \
USB = ` echo " $$ USB " | perl -pne 's/\/dev\/ttyS(\d+)/COM.($$1+1)/e' ` ; \
echo " Remapped MSYS2 USB port to $$ USB " ; \
echo " Remapped MSYS2 USB port to $$ USB " ; \
fi ; \
fi ; \
@ -252,12 +253,12 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
bootloader :
bootloader :
make -C lib/lufa/Bootloaders/DFU/ clean
make -C lib/lufa/Bootloaders/DFU/ clean
echo -e "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n" > lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e "#ifndef QMK_KEYBOARD\n#define QMK_KEYBOARD\n" > lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "MANUFACTURER" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "MANUFACTURER" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "PRODUCT" $( ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "PRODUCT" $( ALL_CONFIGS) -h | tail -1` Bootloader >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "QMK_ESC_OUTPUT" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "QMK_ESC_OUTPUT" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "QMK_ESC_INPUT" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "QMK_ESC_INPUT" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "QMK_LED" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "QMK_LED" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` grep "QMK_SPEAKER" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e ` $( GREP) "QMK_SPEAKER" $( ALL_CONFIGS) -h | tail -1` >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h
echo -e "\n#endif" >> lib/lufa/Bootloaders/DFU/Keyboard.h
make -C lib/lufa/Bootloaders/DFU/
make -C lib/lufa/Bootloaders/DFU/
echo -e " BootloaderDFU.hex copied to $( TARGET) _bootloader.hex "
echo -e " BootloaderDFU.hex copied to $( TARGET) _bootloader.hex "