Gadget: Added helper to enable/disable gadget, HID keyboard
This commit is contained in:
parent
fc1fa8159e
commit
0d1c04a2d6
25
gadget_disable.sh
Executable file
25
gadget_disable.sh
Executable file
@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
gname=rpikvm
|
||||||
|
|
||||||
|
cd /sys/kernel/config/usb_gadget/$gname
|
||||||
|
|
||||||
|
echo "Disable gadget"
|
||||||
|
echo "" > UDC
|
||||||
|
|
||||||
|
echo "Clean up configs"
|
||||||
|
rm configs/c.1/hid.usb0
|
||||||
|
rmdir configs/c.1/strings/0x409
|
||||||
|
rmdir configs/c.1
|
||||||
|
|
||||||
|
echo "Clean up functions"
|
||||||
|
rmdir functions/hid.usb0
|
||||||
|
|
||||||
|
echo "Clean up strings"
|
||||||
|
rmdir strings/0x409
|
||||||
|
|
||||||
|
echo "Removing gadget"
|
||||||
|
cd ..
|
||||||
|
rmdir $gname
|
||||||
|
|
||||||
|
|
||||||
|
echo "All done"
|
39
gadget_enable.sh
Executable file
39
gadget_enable.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
gname=rpikvm
|
||||||
|
gserial=$(awk '/Serial/ { print $3 }' /proc/cpuinfo)
|
||||||
|
gmanufacturer="Petrkr.NET"
|
||||||
|
gproduct="rPi KVM"
|
||||||
|
|
||||||
|
cd /sys/kernel/config/usb_gadget/
|
||||||
|
mkdir -p $gname
|
||||||
|
cd $gname
|
||||||
|
|
||||||
|
echo "Creating USB Device"
|
||||||
|
echo 0x1d6b > idVendor # Linux Foundation
|
||||||
|
echo 0x0104 > idProduct # Multifunction Composite Gadget
|
||||||
|
echo 0x0100 > bcdDevice # v1.0.0
|
||||||
|
echo 0x0200 > bcdUSB # USB2
|
||||||
|
|
||||||
|
echo "Creating strings"
|
||||||
|
mkdir -p strings/0x409
|
||||||
|
echo "$gserial" > strings/0x409/serialnumber
|
||||||
|
echo "$gmanufacturer" > strings/0x409/manufacturer
|
||||||
|
echo "$gproduct" > strings/0x409/product
|
||||||
|
mkdir -p configs/c.1/strings/0x409
|
||||||
|
|
||||||
|
echo "Config 1: ECM network" > configs/c.1/strings/0x409/configuration
|
||||||
|
echo 250 > configs/c.1/MaxPower
|
||||||
|
|
||||||
|
echo "Creating usb devices"
|
||||||
|
# Gadget HID Keyboard
|
||||||
|
echo " HID Keyboard"
|
||||||
|
mkdir -p functions/hid.usb0
|
||||||
|
echo 1 > functions/hid.usb0/protocol
|
||||||
|
echo 1 > functions/hid.usb0/subclass
|
||||||
|
echo 8 > functions/hid.usb0/report_length
|
||||||
|
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
|
||||||
|
ln -s functions/hid.usb0 configs/c.1/
|
||||||
|
|
||||||
|
echo "Activate gadget"
|
||||||
|
ls /sys/class/udc > UDC
|
Loading…
Reference in New Issue
Block a user