aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xkeyboards/alice/program106
-rw-r--r--keyboards/alice/rules.mk2
-rw-r--r--keyboards/jj40/README.md2
-rw-r--r--keyboards/jj4x4/README.md2
-rw-r--r--keyboards/jj50/README.md2
-rw-r--r--keyboards/jj50/program74
-rw-r--r--keyboards/jj50/rules.mk2
-rw-r--r--keyboards/mechmini/v1/README.md2
-rw-r--r--keyboards/mehkee96/program105
-rw-r--r--keyboards/mehkee96/rules.mk2
-rw-r--r--keyboards/ps2avrGB/README.md2
-rwxr-xr-xkeyboards/ps2avrGB/program105
-rw-r--r--keyboards/ps2avrGB/rules.mk2
-rwxr-xr-xkeyboards/winkeyless/bface/program105
-rw-r--r--keyboards/winkeyless/bface/rules.mk2
-rw-r--r--keyboards/ymd75/README.md2
-rw-r--r--keyboards/ymd75/program74
-rw-r--r--keyboards/ymd75/rules.mk2
-rw-r--r--keyboards/ymd96/program74
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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24
25def 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
29def 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
33def 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
41def 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
50def 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
69if len(sys.argv) < 2:
70 print('Usage: %s <firmware.hex>' % sys.argv[0])
71 sys.exit(1)
72
73kb = checkForKeyboardInNormalMode()
74
75if 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
83attempts = 12 # 60 seconds
84found = False
85for 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
103if 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
45SRC += i2c_master.c 45SRC += i2c_master.c
46 46
47# programming options 47# programming options
48PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex 48PROGRAM_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
39In order to use the `./program` script, which can reboot the board into 39In order to use the `././util/atmega32a_program.py` script, which can reboot the board into
40the bootloader, you'll need Python 2 with PyUSB installed: 40the 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
39In order to use the `./program` script, which can reboot the board into 39In order to use the `./util/atmega32a_program.py` script, which can reboot the board into
40the bootloader, you'll need Python 2 with PyUSB installed: 40the 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
40In order to use the `./program` script, which can reboot the board into 40In order to use the `././util/atmega32a_program.py` script, which can reboot the board into
41the bootloader, you'll need Python 2 with PyUSB installed: 41the 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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24if len(sys.argv) < 2:
25 print('Usage: %s <firmware.hex>' % sys.argv[0])
26 sys.exit(1)
27
28print('Searching for ps2avrGB... ', end='')
29
30dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D)
31if dev is None:
32 raise ValueError('Device not found')
33
34print('Found', end='\n\n')
35
36print('Device Information:')
37print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor))
38print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct))
39print('Manufacturer: %s' % (dev.iManufacturer))
40print('Serial: %s' % (dev.iSerialNumber))
41print('Product: %s' % (dev.iProduct), end='\n\n')
42
43print('Transferring control to bootloader... ', end='')
44
45dev.set_configuration()
46
47request_type = usb.util.build_request_type(
48 usb.util.CTRL_OUT,
49 usb.util.CTRL_TYPE_CLASS,
50 usb.util.CTRL_RECIPIENT_DEVICE)
51
52USBRQ_HID_SET_REPORT = 0x09
53HID_REPORT_OPTION = 0x0301
54
55
56try:
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 )
64except 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
69time.sleep(2)
70
71print('OK')
72print('Programming...')
73if 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
58SRC = matrix.c i2c.c backlight.c 58SRC = matrix.c i2c.c backlight.c
59 59
60# programming options 60# programming options
61PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex 61PROGRAM_CMD = ./util/atmega32a_program.py $(TARGET).hex
62 62
63LAYOUTS = ortho_5x12 63LAYOUTS = 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
32In order to use the `./program` script, which can reboot the board into 32In order to use the `./util/atmega32a_program.py` script, which can reboot the board into
33the bootloader, you'll need Python 2 with PyUSB installed: 33the 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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24
25def 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
29def 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
33def 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
41def 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
50def 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
69if len(sys.argv) < 2:
70 print('Usage: %s <firmware.hex>' % sys.argv[0])
71 sys.exit(1)
72
73kb = checkForKeyboardInNormalMode()
74
75if 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
82attempts = 12 # 60 seconds
83found = False
84for 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
102if 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
32SRC = matrix.c i2c.c 32SRC = matrix.c i2c.c
33 33
34# programming options 34# programming options
35PROGRAM_CMD = ./keyboards/mehkee96/program $(TARGET).hex 35PROGRAM_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
33In order to use the `./program` script, which can reboot the board into 33In order to use the `./util/atmega32a_program.py` script, which can reboot the board into
34the bootloader, you'll need Python 2 with PyUSB installed: 34the 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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24
25def 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
29def 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
33def 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
41def 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
50def 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
69if len(sys.argv) < 2:
70 print('Usage: %s <firmware.hex>' % sys.argv[0])
71 sys.exit(1)
72
73kb = checkForKeyboardInNormalMode()
74
75if 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
82attempts = 12 # 60 seconds
83found = False
84for 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
102if 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
47SRC = matrix.c i2c.c 47SRC = matrix.c i2c.c
48 48
49# programming options 49# programming options
50PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex 50PROGRAM_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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24
25def 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
29def 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
33def 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
41def 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
50def 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
69if len(sys.argv) < 2:
70 print('Usage: %s <firmware.hex>' % sys.argv[0])
71 sys.exit(1)
72
73kb = checkForKeyboardInNormalMode()
74
75if 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
82attempts = 12 # 60 seconds
83found = False
84for 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
102if 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
44SRC = matrix.c i2c.c backlight_ps2avrGB.c 44SRC = matrix.c i2c.c backlight_ps2avrGB.c
45 45
46# programming options 46# programming options
47PROGRAM_CMD = ./keyboards/winkeyless/bface/program .build/$(TARGET).hex 47PROGRAM_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
40In order to use the `./program` script, which can reboot the board into 40In order to use the `./util/atmega32a_program.py` script, which can reboot the board into
41the bootloader, you'll need Python 2 with PyUSB installed: 41the 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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24if len(sys.argv) < 2:
25 print('Usage: %s <firmware.hex>' % sys.argv[0])
26 sys.exit(1)
27
28print('Searching for ps2avrGB... ', end='')
29
30dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D)
31if dev is None:
32 raise ValueError('Device not found')
33
34print('Found', end='\n\n')
35
36print('Device Information:')
37print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor))
38print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct))
39print('Manufacturer: %s' % (dev.iManufacturer))
40print('Serial: %s' % (dev.iSerialNumber))
41print('Product: %s' % (dev.iProduct), end='\n\n')
42
43print('Transferring control to bootloader... ', end='')
44
45dev.set_configuration()
46
47request_type = usb.util.build_request_type(
48 usb.util.CTRL_OUT,
49 usb.util.CTRL_TYPE_CLASS,
50 usb.util.CTRL_RECIPIENT_DEVICE)
51
52USBRQ_HID_SET_REPORT = 0x09
53HID_REPORT_OPTION = 0x0301
54
55
56try:
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 )
64except 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
69time.sleep(2)
70
71print('OK')
72print('Programming...')
73if 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
62PROGRAM_CMD = ./keyboards/ps2avrGB/program $(TARGET).hex 62PROGRAM_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
17from __future__ import print_function
18
19import os
20import sys
21import time
22import usb
23
24if len(sys.argv) < 2:
25 print('Usage: %s <firmware.hex>' % sys.argv[0])
26 sys.exit(1)
27
28print('Searching for ps2avrGB... ', end='')
29
30dev = usb.core.find(idVendor=0x20A0, idProduct=0x422D)
31if dev is None:
32 raise ValueError('Device not found')
33
34print('Found', end='\n\n')
35
36print('Device Information:')
37print(' idVendor: %d (0x%04x)' % (dev.idVendor, dev.idVendor))
38print(' idProduct: %d (0x%04x)' % (dev.idProduct, dev.idProduct))
39print('Manufacturer: %s' % (dev.iManufacturer))
40print('Serial: %s' % (dev.iSerialNumber))
41print('Product: %s' % (dev.iProduct), end='\n\n')
42
43print('Transferring control to bootloader... ', end='')
44
45dev.set_configuration()
46
47request_type = usb.util.build_request_type(
48 usb.util.CTRL_OUT,
49 usb.util.CTRL_TYPE_CLASS,
50 usb.util.CTRL_RECIPIENT_DEVICE)
51
52USBRQ_HID_SET_REPORT = 0x09
53HID_REPORT_OPTION = 0x0301
54
55
56try:
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 )
64except 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
69time.sleep(2)
70
71print('OK')
72print('Programming...')
73if os.system('bootloadHID -r "%s"' % sys.argv[1]) == 0:
74 print('\nDone!')