File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # https://www.kernel.org/doc/Documentation/usb/gadget_configfs.txt
3
+
4
+ CONFIGS_ROOT=/sys/kernel/config
5
+ cd $CONFIGS_ROOT /usb_gadget
6
+ mkdir -p kbdbox
7
+ cd kbdbox
8
+
9
+ # USB ids
10
+ echo 0x1d6b > idVendor # Linux Foundation
11
+ echo 0x0104 > idProduct # Multifunction Composite Gadget
12
+ echo 0x0100 > bcdDevice # v1.0.0
13
+ echo 0x0200 > bcdUSB # USB2
14
+ echo 0x03 > bDeviceClass # hid
15
+ echo 0x00 > bDeviceSubClass
16
+ echo 0x00 > bDeviceProtocol
17
+
18
+ # USB strings
19
+ mkdir -p strings/0x409
20
+ echo " fedcba9876543210" > strings/0x409/serialnumber
21
+ echo " broxigarchen" > strings/0x409/manufacturer
22
+ echo " Keyboard box" > strings/0x409/product
23
+
24
+ # USB configuration
25
+ mkdir -p configs/c.1/strings/0x409
26
+ echo " Config 1: keyboard" > configs/c.1/strings/0x409/configuration
27
+ echo 250 > configs/c.1/MaxPower
28
+
29
+ # USB kbd function
30
+ mkdir -p functions/hid.usb0
31
+ echo 0 > functions/hid.usb0/protocol
32
+ echo 0 > functions/hid.usb0/subclass
33
+ echo 8 > functions/hid.usb0/report_length
34
+ echo 63 > functions/hid.usb0/report_desc_length
35
+ echo -ne \\ x05\\ x01\\ x09\\ x06\\ xA1\\ x01\\ x05\\ x07\\ x19\\ xE0\\ x29\\ xE7\\ x15\\ x00\\ x25\\ x01\\ x75\\ x01\\ x95\\ x08\\ x81\\ x02\\ x95\\ x01\\ x75\\ x08\\ x81\\ x03\\ x95\\ x05\\ x75\\ x01\\ x05\\ x08\\ x19\\ x01\\ x29\\ x05\\ x91\\ x02\\ x95\\ x01\\ x75\\ x03\\ x91\\ x03\\ x95\\ x06\\ x75\\ x08\\ x15\\ x00\\ x25\\ x65\\ x05\\ x07\\ x19\\ x00\\ x29\\ x65\\ x81\\ x00\\ xC0 > functions/hid.usb0/report_desc
36
+
37
+ # bind function to config
38
+ ln -s functions/hid.usb0 configs/c.1
39
+
40
+ # bound to UDC
41
+ ls /sys/class/udc > UDC
Original file line number Diff line number Diff line change
1
+ CONFIGS_ROOT=/sys/kernel/config
2
+ cd $CONFIGS_ROOT /usb_gadget/kbdbox
3
+
4
+ rm configs/c.1/hid.usb0
5
+ rmdir configs/c.1/strings/0x409
6
+ rmdir configs/c.1
7
+ rmdir functions/hid.usb0
8
+ rmdir strings/0x409
9
+ cd ..
10
+ rmdir kbdbox
You can’t perform that action at this time.
0 commit comments