diff options
| author | zvecr <git@zvecr.com> | 2019-03-14 22:55:08 +0000 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2019-03-14 15:55:08 -0700 |
| commit | 205ffc277c1b6cb25d11f0938d4df02048870fa5 (patch) | |
| tree | 449c1448855b51fe7d814b17bc89add848fd9a55 | |
| parent | c025d813baf7ca1dcd427b293b36603339ac31f7 (diff) | |
| download | qmk_firmware-205ffc277c1b6cb25d11f0938d4df02048870fa5.tar.gz qmk_firmware-205ffc277c1b6cb25d11f0938d4df02048870fa5.zip | |
Align use of atmega32a program script (#5259)
* Remove duplicate 'program' files and refactor to use atmega32a_program.py
* Update readme references from 'program' to 'atmega32a_program.py'
| -rwxr-xr-x | keyboards/alice/program | 106 | ||||
| -rw-r--r-- | keyboards/alice/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/jj40/README.md | 2 | ||||
| -rw-r--r-- | keyboards/jj4x4/README.md | 2 | ||||
| -rw-r--r-- | keyboards/jj50/README.md | 2 | ||||
| -rw-r--r-- | keyboards/jj50/program | 74 | ||||
| -rw-r--r-- | keyboards/jj50/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/mechmini/v1/README.md | 2 | ||||
| -rw-r--r-- | keyboards/mehkee96/program | 105 | ||||
| -rw-r--r-- | keyboards/mehkee96/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/ps2avrGB/README.md | 2 | ||||
| -rwxr-xr-x | keyboards/ps2avrGB/program | 105 | ||||
| -rw-r--r-- | keyboards/ps2avrGB/rules.mk | 2 | ||||
| -rwxr-xr-x | keyboards/winkeyless/bface/program | 105 | ||||
| -rw-r--r-- | keyboards/winkeyless/bface/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/ymd75/README.md | 2 | ||||
| -rw-r--r-- | keyboards/ymd75/program | 74 | ||||
| -rw-r--r-- | keyboards/ymd75/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/ymd96/program | 74 |
19 files changed, 12 insertions, 655 deletions
diff --git a/keyboards/alice/program b/keyboards/alice/program deleted file mode 100755 index 3779bad04..000000000 --- a/keyboards/alice/program +++ /dev/null | |||
| @@ -1,106 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | |||
| 25 | def checkForKeyboardInNormalMode(): | ||
| 26 | """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found.""" | ||
| 27 | return usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 28 | |||
| 29 | def checkForKeyboardInBootloaderMode(): | ||
| 30 | """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise.""" | ||
| 31 | return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None) | ||
| 32 | |||
| 33 | def flashKeyboard(firmware_file): | ||
| 34 | """Calls bootloadHID to flash the given file to the device.""" | ||
| 35 | print('Flashing firmware to device ...') | ||
| 36 | if os.system('bootloadHID -r "%s"' % firmware_file) == 0: | ||
| 37 | print('\nDone!') | ||
| 38 | else: | ||
| 39 | print('\nbootloadHID returned an error.') | ||
| 40 | |||
| 41 | def printDeviceInfo(dev): | ||
| 42 | """Prints all infos for a given USB device""" | ||
| 43 | print('Device Information:') | ||
| 44 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 45 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 46 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 47 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 48 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 49 | |||
| 50 | def sendDeviceToBootloaderMode(dev): | ||
| 51 | """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing.""" | ||
| 52 | try: | ||
| 53 | dev.set_configuration() | ||
| 54 | |||
| 55 | request_type = usb.util.build_request_type( | ||
| 56 | usb.util.CTRL_OUT, | ||
| 57 | usb.util.CTRL_TYPE_CLASS, | ||
| 58 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 59 | |||
| 60 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 61 | HID_REPORT_OPTION = 0x0301 | ||
| 62 | |||
| 63 | dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | |||
| 69 | if len(sys.argv) < 2: | ||
| 70 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 71 | sys.exit(1) | ||
| 72 | |||
| 73 | kb = checkForKeyboardInNormalMode() | ||
| 74 | |||
| 75 | if kb is not None: | ||
| 76 | print('Found a keyboard in normal mode. Attempting to send it to bootloader mode ...', end='') | ||
| 77 | printDeviceInfo(kb) | ||
| 78 | sendDeviceToBootloaderMode(kb) | ||
| 79 | print(' done.') | ||
| 80 | print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.") | ||
| 81 | print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode") | ||
| 82 | |||
| 83 | attempts = 12 # 60 seconds | ||
| 84 | found = False | ||
| 85 | for attempt in range(1, attempts + 1): | ||
| 86 | print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='') | ||
| 87 | |||
| 88 | if checkForKeyboardInBootloaderMode(): | ||
| 89 | print('Found', end='\n\n') | ||
| 90 | flashKeyboard(sys.argv[1]) | ||
| 91 | found = True | ||
| 92 | break | ||
| 93 | else: | ||
| 94 | print('Nothing.', end='') | ||
| 95 | |||
| 96 | if attempt != attempts: # no need to wait on the last attempt | ||
| 97 | print(' Sleeping 5 seconds.', end='') | ||
| 98 | time.sleep(5) | ||
| 99 | |||
| 100 | # print a newline | ||
| 101 | print() | ||
| 102 | |||
| 103 | if not found: | ||
| 104 | print("Couldn't find a flashable keyboard. Aborting.") | ||
| 105 | sys.exit(2) | ||
| 106 | |||
diff --git a/keyboards/alice/rules.mk b/keyboards/alice/rules.mk index bb57cbeae..eecd38d7e 100644 --- a/keyboards/alice/rules.mk +++ b/keyboards/alice/rules.mk | |||
| @@ -45,4 +45,4 @@ OPT_DEFS = -DDEBUG_LEVEL=0 | |||
| 45 | SRC += i2c_master.c | 45 | SRC += i2c_master.c |
| 46 | 46 | ||
| 47 | # programming options | 47 | # programming options |
| 48 | PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex | 48 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
diff --git a/keyboards/jj40/README.md b/keyboards/jj40/README.md index ed1ea90fe..7d3612554 100644 --- a/keyboards/jj40/README.md +++ b/keyboards/jj40/README.md | |||
| @@ -36,7 +36,7 @@ $ make | |||
| 36 | $ sudo cp bootloadHID /usr/bin | 36 | $ sudo cp bootloadHID /usr/bin |
| 37 | ``` | 37 | ``` |
| 38 | 38 | ||
| 39 | In order to use the `./program` script, which can reboot the board into | 39 | In order to use the `././util/atmega32a_program.py` script, which can reboot the board into |
| 40 | the bootloader, you'll need Python 2 with PyUSB installed: | 40 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 41 | 41 | ||
| 42 | ``` | 42 | ``` |
diff --git a/keyboards/jj4x4/README.md b/keyboards/jj4x4/README.md index 09684bd82..29dc2605d 100644 --- a/keyboards/jj4x4/README.md +++ b/keyboards/jj4x4/README.md | |||
| @@ -36,7 +36,7 @@ $ make | |||
| 36 | $ sudo cp bootloadHID /usr/bin | 36 | $ sudo cp bootloadHID /usr/bin |
| 37 | ``` | 37 | ``` |
| 38 | 38 | ||
| 39 | In order to use the `./program` script, which can reboot the board into | 39 | In order to use the `./util/atmega32a_program.py` script, which can reboot the board into |
| 40 | the bootloader, you'll need Python 2 with PyUSB installed: | 40 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 41 | 41 | ||
| 42 | ``` | 42 | ``` |
diff --git a/keyboards/jj50/README.md b/keyboards/jj50/README.md index 397889535..f7b8acc64 100644 --- a/keyboards/jj50/README.md +++ b/keyboards/jj50/README.md | |||
| @@ -37,7 +37,7 @@ $ brew cask install crosspack-avr | |||
| 37 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb | 37 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb |
| 38 | ``` | 38 | ``` |
| 39 | 39 | ||
| 40 | In order to use the `./program` script, which can reboot the board into | 40 | In order to use the `././util/atmega32a_program.py` script, which can reboot the board into |
| 41 | the bootloader, you'll need Python 2 with PyUSB installed: | 41 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 42 | 42 | ||
| 43 | ``` | 43 | ``` |
diff --git a/keyboards/jj50/program b/keyboards/jj50/program deleted file mode 100644 index a88d9cd9b..000000000 --- a/keyboards/jj50/program +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | if len(sys.argv) < 2: | ||
| 25 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 26 | sys.exit(1) | ||
| 27 | |||
| 28 | print('Searching for ps2avrGB... ', end='') | ||
| 29 | |||
| 30 | dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 31 | if dev is None: | ||
| 32 | raise ValueError('Device not found') | ||
| 33 | |||
| 34 | print('Found', end='\n\n') | ||
| 35 | |||
| 36 | print('Device Information:') | ||
| 37 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 38 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 39 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 40 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 41 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 42 | |||
| 43 | print('Transferring control to bootloader... ', end='') | ||
| 44 | |||
| 45 | dev.set_configuration() | ||
| 46 | |||
| 47 | request_type = usb.util.build_request_type( | ||
| 48 | usb.util.CTRL_OUT, | ||
| 49 | usb.util.CTRL_TYPE_CLASS, | ||
| 50 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 51 | |||
| 52 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 53 | HID_REPORT_OPTION = 0x0301 | ||
| 54 | |||
| 55 | |||
| 56 | try: | ||
| 57 | dev.ctrl_transfer( | ||
| 58 | request_type, | ||
| 59 | USBRQ_HID_SET_REPORT, | ||
| 60 | HID_REPORT_OPTION, | ||
| 61 | 0, | ||
| 62 | [0, 0, 0xFF] + [0] * 5 | ||
| 63 | ) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | # wait a bit until bootloader starts up | ||
| 69 | time.sleep(2) | ||
| 70 | |||
| 71 | print('OK') | ||
| 72 | print('Programming...') | ||
| 73 | if os.system('bootloadHID -r "%s"' % sys.argv[1]) == 0: | ||
| 74 | print('\nDone!') | ||
diff --git a/keyboards/jj50/rules.mk b/keyboards/jj50/rules.mk index 1a18ec4fe..4ee571918 100644 --- a/keyboards/jj50/rules.mk +++ b/keyboards/jj50/rules.mk | |||
| @@ -58,6 +58,6 @@ CUSTOM_MATRIX = yes | |||
| 58 | SRC = matrix.c i2c.c backlight.c | 58 | SRC = matrix.c i2c.c backlight.c |
| 59 | 59 | ||
| 60 | # programming options | 60 | # programming options |
| 61 | PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex | 61 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
| 62 | 62 | ||
| 63 | LAYOUTS = ortho_5x12 | 63 | LAYOUTS = ortho_5x12 |
diff --git a/keyboards/mechmini/v1/README.md b/keyboards/mechmini/v1/README.md index b4a1924c4..315349803 100644 --- a/keyboards/mechmini/v1/README.md +++ b/keyboards/mechmini/v1/README.md | |||
| @@ -29,7 +29,7 @@ $ brew cask install crosspack-avr | |||
| 29 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb | 29 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb |
| 30 | ``` | 30 | ``` |
| 31 | 31 | ||
| 32 | In order to use the `./program` script, which can reboot the board into | 32 | In order to use the `./util/atmega32a_program.py` script, which can reboot the board into |
| 33 | the bootloader, you'll need Python 2 with PyUSB installed: | 33 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 34 | 34 | ||
| 35 | ``` | 35 | ``` |
diff --git a/keyboards/mehkee96/program b/keyboards/mehkee96/program deleted file mode 100644 index b777b9110..000000000 --- a/keyboards/mehkee96/program +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | |||
| 25 | def checkForKeyboardInNormalMode(): | ||
| 26 | """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found.""" | ||
| 27 | return usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 28 | |||
| 29 | def checkForKeyboardInBootloaderMode(): | ||
| 30 | """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise.""" | ||
| 31 | return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None) | ||
| 32 | |||
| 33 | def flashKeyboard(firmware_file): | ||
| 34 | """Calls bootloadHID to flash the given file to the device.""" | ||
| 35 | print('Flashing firmware to device ...') | ||
| 36 | if os.system('bootloadHID -r "%s"' % firmware_file) == 0: | ||
| 37 | print('\nDone!') | ||
| 38 | else: | ||
| 39 | print('\nbootloadHID returned an error.') | ||
| 40 | |||
| 41 | def printDeviceInfo(dev): | ||
| 42 | """Prints all infos for a given USB device""" | ||
| 43 | print('Device Information:') | ||
| 44 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 45 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 46 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 47 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 48 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 49 | |||
| 50 | def sendDeviceToBootloaderMode(dev): | ||
| 51 | """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing.""" | ||
| 52 | try: | ||
| 53 | dev.set_configuration() | ||
| 54 | |||
| 55 | request_type = usb.util.build_request_type( | ||
| 56 | usb.util.CTRL_OUT, | ||
| 57 | usb.util.CTRL_TYPE_CLASS, | ||
| 58 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 59 | |||
| 60 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 61 | HID_REPORT_OPTION = 0x0301 | ||
| 62 | |||
| 63 | dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | |||
| 69 | if len(sys.argv) < 2: | ||
| 70 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 71 | sys.exit(1) | ||
| 72 | |||
| 73 | kb = checkForKeyboardInNormalMode() | ||
| 74 | |||
| 75 | if kb is not None: | ||
| 76 | print('Found a keyboard in normal mode. Attempting to send it to bootloader mode ...', end='') | ||
| 77 | sendDeviceToBootloaderMode(kb) | ||
| 78 | print(' done.') | ||
| 79 | print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.") | ||
| 80 | print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode") | ||
| 81 | |||
| 82 | attempts = 12 # 60 seconds | ||
| 83 | found = False | ||
| 84 | for attempt in range(1, attempts + 1): | ||
| 85 | print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='') | ||
| 86 | |||
| 87 | if checkForKeyboardInBootloaderMode(): | ||
| 88 | print('Found', end='\n\n') | ||
| 89 | flashKeyboard(sys.argv[1]) | ||
| 90 | found = True | ||
| 91 | break | ||
| 92 | else: | ||
| 93 | print('Nothing.', end='') | ||
| 94 | |||
| 95 | if attempt != attempts: # no need to wait on the last attempt | ||
| 96 | print(' Sleeping 5 seconds.', end='') | ||
| 97 | time.sleep(5) | ||
| 98 | |||
| 99 | # print a newline | ||
| 100 | print() | ||
| 101 | |||
| 102 | if not found: | ||
| 103 | print("Couldn't find a flashable keyboard. Aborting.") | ||
| 104 | sys.exit(2) | ||
| 105 | |||
diff --git a/keyboards/mehkee96/rules.mk b/keyboards/mehkee96/rules.mk index e6e7d4a58..f7fb397e2 100644 --- a/keyboards/mehkee96/rules.mk +++ b/keyboards/mehkee96/rules.mk | |||
| @@ -32,4 +32,4 @@ CUSTOM_MATRIX = yes | |||
| 32 | SRC = matrix.c i2c.c | 32 | SRC = matrix.c i2c.c |
| 33 | 33 | ||
| 34 | # programming options | 34 | # programming options |
| 35 | PROGRAM_CMD = ./keyboards/mehkee96/program $(TARGET).hex | 35 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
diff --git a/keyboards/ps2avrGB/README.md b/keyboards/ps2avrGB/README.md index 8399dff02..8a558b158 100644 --- a/keyboards/ps2avrGB/README.md +++ b/keyboards/ps2avrGB/README.md | |||
| @@ -30,7 +30,7 @@ $ brew cask install crosspack-avr | |||
| 30 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb | 30 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb |
| 31 | ``` | 31 | ``` |
| 32 | 32 | ||
| 33 | In order to use the `./program` script, which can reboot the board into | 33 | In order to use the `./util/atmega32a_program.py` script, which can reboot the board into |
| 34 | the bootloader, you'll need Python 2 with PyUSB installed: | 34 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 35 | 35 | ||
| 36 | ``` | 36 | ``` |
diff --git a/keyboards/ps2avrGB/program b/keyboards/ps2avrGB/program deleted file mode 100755 index b777b9110..000000000 --- a/keyboards/ps2avrGB/program +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | |||
| 25 | def checkForKeyboardInNormalMode(): | ||
| 26 | """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found.""" | ||
| 27 | return usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 28 | |||
| 29 | def checkForKeyboardInBootloaderMode(): | ||
| 30 | """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise.""" | ||
| 31 | return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None) | ||
| 32 | |||
| 33 | def flashKeyboard(firmware_file): | ||
| 34 | """Calls bootloadHID to flash the given file to the device.""" | ||
| 35 | print('Flashing firmware to device ...') | ||
| 36 | if os.system('bootloadHID -r "%s"' % firmware_file) == 0: | ||
| 37 | print('\nDone!') | ||
| 38 | else: | ||
| 39 | print('\nbootloadHID returned an error.') | ||
| 40 | |||
| 41 | def printDeviceInfo(dev): | ||
| 42 | """Prints all infos for a given USB device""" | ||
| 43 | print('Device Information:') | ||
| 44 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 45 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 46 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 47 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 48 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 49 | |||
| 50 | def sendDeviceToBootloaderMode(dev): | ||
| 51 | """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing.""" | ||
| 52 | try: | ||
| 53 | dev.set_configuration() | ||
| 54 | |||
| 55 | request_type = usb.util.build_request_type( | ||
| 56 | usb.util.CTRL_OUT, | ||
| 57 | usb.util.CTRL_TYPE_CLASS, | ||
| 58 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 59 | |||
| 60 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 61 | HID_REPORT_OPTION = 0x0301 | ||
| 62 | |||
| 63 | dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | |||
| 69 | if len(sys.argv) < 2: | ||
| 70 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 71 | sys.exit(1) | ||
| 72 | |||
| 73 | kb = checkForKeyboardInNormalMode() | ||
| 74 | |||
| 75 | if kb is not None: | ||
| 76 | print('Found a keyboard in normal mode. Attempting to send it to bootloader mode ...', end='') | ||
| 77 | sendDeviceToBootloaderMode(kb) | ||
| 78 | print(' done.') | ||
| 79 | print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.") | ||
| 80 | print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode") | ||
| 81 | |||
| 82 | attempts = 12 # 60 seconds | ||
| 83 | found = False | ||
| 84 | for attempt in range(1, attempts + 1): | ||
| 85 | print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='') | ||
| 86 | |||
| 87 | if checkForKeyboardInBootloaderMode(): | ||
| 88 | print('Found', end='\n\n') | ||
| 89 | flashKeyboard(sys.argv[1]) | ||
| 90 | found = True | ||
| 91 | break | ||
| 92 | else: | ||
| 93 | print('Nothing.', end='') | ||
| 94 | |||
| 95 | if attempt != attempts: # no need to wait on the last attempt | ||
| 96 | print(' Sleeping 5 seconds.', end='') | ||
| 97 | time.sleep(5) | ||
| 98 | |||
| 99 | # print a newline | ||
| 100 | print() | ||
| 101 | |||
| 102 | if not found: | ||
| 103 | print("Couldn't find a flashable keyboard. Aborting.") | ||
| 104 | sys.exit(2) | ||
| 105 | |||
diff --git a/keyboards/ps2avrGB/rules.mk b/keyboards/ps2avrGB/rules.mk index 1be9edc24..95d287f7f 100644 --- a/keyboards/ps2avrGB/rules.mk +++ b/keyboards/ps2avrGB/rules.mk | |||
| @@ -47,4 +47,4 @@ CUSTOM_MATRIX = yes | |||
| 47 | SRC = matrix.c i2c.c | 47 | SRC = matrix.c i2c.c |
| 48 | 48 | ||
| 49 | # programming options | 49 | # programming options |
| 50 | PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex | 50 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
diff --git a/keyboards/winkeyless/bface/program b/keyboards/winkeyless/bface/program deleted file mode 100755 index 298e64547..000000000 --- a/keyboards/winkeyless/bface/program +++ /dev/null | |||
| @@ -1,105 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com>, Sebastian Kaim <sebb@sebb767.de> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | |||
| 25 | def checkForKeyboardInNormalMode(): | ||
| 26 | """Returns a device if a ps2avrGB device in normal made (that is in keyboard mode) or None if it is not found.""" | ||
| 27 | return usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 28 | |||
| 29 | def checkForKeyboardInBootloaderMode(): | ||
| 30 | """Returns True if a ps2avrGB device in bootloader (flashable) mode is found and False otherwise.""" | ||
| 31 | return (usb.core.find(idVendor=0x16c0, idProduct=0x05df) is not None) | ||
| 32 | |||
| 33 | def flashKeyboard(firmware_file): | ||
| 34 | """Calls bootloadHID to flash the given file to the device.""" | ||
| 35 | print('Flashing firmware to device ...') | ||
| 36 | if os.system('bootloadHID -r "%s"' % firmware_file) == 0: | ||
| 37 | print('\nDone!') | ||
| 38 | else: | ||
| 39 | print('\nbootloadHID returned an error.') | ||
| 40 | |||
| 41 | def printDeviceInfo(dev): | ||
| 42 | """Prints all infos for a given USB device""" | ||
| 43 | print('Device Information:') | ||
| 44 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 45 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 46 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 47 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 48 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 49 | |||
| 50 | def sendDeviceToBootloaderMode(dev): | ||
| 51 | """Tries to send a given ps2avrGB keyboard to bootloader mode to allow flashing.""" | ||
| 52 | try: | ||
| 53 | dev.set_configuration() | ||
| 54 | |||
| 55 | request_type = usb.util.build_request_type( | ||
| 56 | usb.util.CTRL_OUT, | ||
| 57 | usb.util.CTRL_TYPE_CLASS, | ||
| 58 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 59 | |||
| 60 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 61 | HID_REPORT_OPTION = 0x0301 | ||
| 62 | |||
| 63 | dev.ctrl_transfer(request_type, USBRQ_HID_SET_REPORT, HID_REPORT_OPTION, 0, [0, 0, 0xFF] + [0] * 5) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | |||
| 69 | if len(sys.argv) < 2: | ||
| 70 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 71 | sys.exit(1) | ||
| 72 | |||
| 73 | kb = checkForKeyboardInNormalMode() | ||
| 74 | |||
| 75 | if kb is not None: | ||
| 76 | print('Found a keyboad in normal mode. Attempting to send it to bootloader mode ...', end='') | ||
| 77 | sendDeviceToBootloaderMode(kb) | ||
| 78 | print(' done.') | ||
| 79 | print("Hint: If your keyboard can't be set to bootloader mode automatically, plug it in while pressing the bootloader key to do so manually.") | ||
| 80 | print(" You can find more infos about this here: https://github.com/qmk/qmk_firmware/tree/master/keyboards/ps2avrGB#setting-the-board-to-bootloader-mode") | ||
| 81 | |||
| 82 | attempts = 12 # 60 seconds | ||
| 83 | found = False | ||
| 84 | for attempt in range(1, attempts + 1): | ||
| 85 | print("Searching for keyboard in bootloader mode (%i/%i) ... " % (attempt, attempts), end='') | ||
| 86 | |||
| 87 | if checkForKeyboardInBootloaderMode(): | ||
| 88 | print('Found', end='\n\n') | ||
| 89 | flashKeyboard(sys.argv[1]) | ||
| 90 | found = True | ||
| 91 | break | ||
| 92 | else: | ||
| 93 | print('Nothing.', end='') | ||
| 94 | |||
| 95 | if attempt != attempts: # no need to wait on the last attempt | ||
| 96 | print(' Sleeping 5 seconds.', end='') | ||
| 97 | time.sleep(5) | ||
| 98 | |||
| 99 | # print a newline | ||
| 100 | print() | ||
| 101 | |||
| 102 | if not found: | ||
| 103 | print("Couldn't find a flashable keyboard. Aborting.") | ||
| 104 | sys.exit(2) | ||
| 105 | |||
diff --git a/keyboards/winkeyless/bface/rules.mk b/keyboards/winkeyless/bface/rules.mk index 10331ef70..369ccf2ed 100644 --- a/keyboards/winkeyless/bface/rules.mk +++ b/keyboards/winkeyless/bface/rules.mk | |||
| @@ -44,5 +44,5 @@ CUSTOM_MATRIX = yes | |||
| 44 | SRC = matrix.c i2c.c backlight_ps2avrGB.c | 44 | SRC = matrix.c i2c.c backlight_ps2avrGB.c |
| 45 | 45 | ||
| 46 | # programming options | 46 | # programming options |
| 47 | PROGRAM_CMD = ./keyboards/winkeyless/bface/program .build/$(TARGET).hex | 47 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
| 48 | 48 | ||
diff --git a/keyboards/ymd75/README.md b/keyboards/ymd75/README.md index eed6ce13e..d1c4e95ae 100644 --- a/keyboards/ymd75/README.md +++ b/keyboards/ymd75/README.md | |||
| @@ -37,7 +37,7 @@ $ brew cask install crosspack-avr | |||
| 37 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb | 37 | $ brew install --HEAD https://raw.githubusercontent.com/robertgzr/homebrew-tap/master/bootloadhid.rb |
| 38 | ``` | 38 | ``` |
| 39 | 39 | ||
| 40 | In order to use the `./program` script, which can reboot the board into | 40 | In order to use the `./util/atmega32a_program.py` script, which can reboot the board into |
| 41 | the bootloader, you'll need Python 2 with PyUSB installed: | 41 | the bootloader, you'll need Python 2 with PyUSB installed: |
| 42 | 42 | ||
| 43 | ``` | 43 | ``` |
diff --git a/keyboards/ymd75/program b/keyboards/ymd75/program deleted file mode 100644 index a88d9cd9b..000000000 --- a/keyboards/ymd75/program +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | if len(sys.argv) < 2: | ||
| 25 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 26 | sys.exit(1) | ||
| 27 | |||
| 28 | print('Searching for ps2avrGB... ', end='') | ||
| 29 | |||
| 30 | dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 31 | if dev is None: | ||
| 32 | raise ValueError('Device not found') | ||
| 33 | |||
| 34 | print('Found', end='\n\n') | ||
| 35 | |||
| 36 | print('Device Information:') | ||
| 37 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 38 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 39 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 40 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 41 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 42 | |||
| 43 | print('Transferring control to bootloader... ', end='') | ||
| 44 | |||
| 45 | dev.set_configuration() | ||
| 46 | |||
| 47 | request_type = usb.util.build_request_type( | ||
| 48 | usb.util.CTRL_OUT, | ||
| 49 | usb.util.CTRL_TYPE_CLASS, | ||
| 50 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 51 | |||
| 52 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 53 | HID_REPORT_OPTION = 0x0301 | ||
| 54 | |||
| 55 | |||
| 56 | try: | ||
| 57 | dev.ctrl_transfer( | ||
| 58 | request_type, | ||
| 59 | USBRQ_HID_SET_REPORT, | ||
| 60 | HID_REPORT_OPTION, | ||
| 61 | 0, | ||
| 62 | [0, 0, 0xFF] + [0] * 5 | ||
| 63 | ) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | # wait a bit until bootloader starts up | ||
| 69 | time.sleep(2) | ||
| 70 | |||
| 71 | print('OK') | ||
| 72 | print('Programming...') | ||
| 73 | if os.system('bootloadHID -r "%s"' % sys.argv[1]) == 0: | ||
| 74 | print('\nDone!') | ||
diff --git a/keyboards/ymd75/rules.mk b/keyboards/ymd75/rules.mk index 9697a76f1..9d09d3da9 100644 --- a/keyboards/ymd75/rules.mk +++ b/keyboards/ymd75/rules.mk | |||
| @@ -59,4 +59,4 @@ SRC = matrix.c i2c.c backlight.c | |||
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | # programming options | 61 | # programming options |
| 62 | PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex | 62 | PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex |
diff --git a/keyboards/ymd96/program b/keyboards/ymd96/program deleted file mode 100644 index a88d9cd9b..000000000 --- a/keyboards/ymd96/program +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 1 | #!/usr/bin/env python | ||
| 2 | # Copyright 2017 Luiz Ribeiro <luizribeiro@gmail.com> | ||
| 3 | # | ||
| 4 | # This program is free software: you can redistribute it and/or modify | ||
| 5 | # it under the terms of the GNU General Public License as published by | ||
| 6 | # the Free Software Foundation, either version 2 of the License, or | ||
| 7 | # (at your option) any later version. | ||
| 8 | # | ||
| 9 | # This program is distributed in the hope that it will be useful, | ||
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | # GNU General Public License for more details. | ||
| 13 | # | ||
| 14 | # You should have received a copy of the GNU General Public License | ||
| 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | |||
| 17 | from __future__ import print_function | ||
| 18 | |||
| 19 | import os | ||
| 20 | import sys | ||
| 21 | import time | ||
| 22 | import usb | ||
| 23 | |||
| 24 | if len(sys.argv) < 2: | ||
| 25 | print('Usage: %s <firmware.hex>' % sys.argv[0]) | ||
| 26 | sys.exit(1) | ||
| 27 | |||
| 28 | print('Searching for ps2avrGB... ', end='') | ||
| 29 | |||
| 30 | dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D) | ||
| 31 | if dev is None: | ||
| 32 | raise ValueError('Device not found') | ||
| 33 | |||
| 34 | print('Found', end='\n\n') | ||
| 35 | |||
| 36 | print('Device Information:') | ||
| 37 | print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor)) | ||
| 38 | print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct)) | ||
| 39 | print('Manufacturer: %s' % (dev.iManufacturer)) | ||
| 40 | print('Serial: %s' % (dev.iSerialNumber)) | ||
| 41 | print('Product: %s' % (dev.iProduct), end='\n\n') | ||
| 42 | |||
| 43 | print('Transferring control to bootloader... ', end='') | ||
| 44 | |||
| 45 | dev.set_configuration() | ||
| 46 | |||
| 47 | request_type = usb.util.build_request_type( | ||
| 48 | usb.util.CTRL_OUT, | ||
| 49 | usb.util.CTRL_TYPE_CLASS, | ||
| 50 | usb.util.CTRL_RECIPIENT_DEVICE) | ||
| 51 | |||
| 52 | USBRQ_HID_SET_REPORT = 0x09 | ||
| 53 | HID_REPORT_OPTION = 0x0301 | ||
| 54 | |||
| 55 | |||
| 56 | try: | ||
| 57 | dev.ctrl_transfer( | ||
| 58 | request_type, | ||
| 59 | USBRQ_HID_SET_REPORT, | ||
| 60 | HID_REPORT_OPTION, | ||
| 61 | 0, | ||
| 62 | [0, 0, 0xFF] + [0] * 5 | ||
| 63 | ) | ||
| 64 | except usb.core.USBError: | ||
| 65 | # for some reason I keep getting USBError, but it works! | ||
| 66 | pass | ||
| 67 | |||
| 68 | # wait a bit until bootloader starts up | ||
| 69 | time.sleep(2) | ||
| 70 | |||
| 71 | print('OK') | ||
| 72 | print('Programming...') | ||
| 73 | if os.system('bootloadHID -r "%s"' % sys.argv[1]) == 0: | ||
| 74 | print('\nDone!') | ||
