Repo Init with files
This commit is contained in:
58
usr/local/sbin/usb-gadget.sh
Executable file
58
usr/local/sbin/usb-gadget.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/bash
|
||||
|
||||
GADGET=/sys/kernel/config/usb_gadget/display-pi
|
||||
|
||||
SERIAL=`cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2`
|
||||
if [ -n "$SERIAL" ]; then
|
||||
MAC="fa:${SERIAL:6:2}:${SERIAL:8:2}:${SERIAL:10:2}:${SERIAL:12:2}:${SERIAL:14:2}"
|
||||
else
|
||||
MAC="fa:31:43:14:31:43"
|
||||
fi
|
||||
|
||||
mount -t configfs none /sys/kernel/config
|
||||
mkdir -p $GADGET
|
||||
cd $GADGET
|
||||
|
||||
echo 0x1d6b > idVendor # Linux Foundation
|
||||
echo 0x0104 > idProduct # Multifunction Composite Gadget
|
||||
echo 0x0100 > bcdDevice # v1.0.0
|
||||
echo 0x0200 > bcdUSB # USB2
|
||||
|
||||
echo 0xEF > bDeviceClass
|
||||
echo 0x02 > bDeviceSubClass
|
||||
echo 0x01 > bDeviceProtocol
|
||||
|
||||
mkdir strings/0x409
|
||||
echo $SERIAL > strings/0x409/serialnumber
|
||||
echo "Raspberry Pi" > strings/0x409/manufacturer
|
||||
echo "Display-Pi USB Device" > strings/0x409/product
|
||||
|
||||
mkdir -p functions/acm.usb0 # serial
|
||||
mkdir -p functions/rndis.usb0 # network
|
||||
#mkdir -p functions/ecm.usb0
|
||||
#echo $MAC > functions/ecm.usb0/dev_addr
|
||||
|
||||
mkdir -p configs/c.1
|
||||
echo 250 > configs/c.1/MaxPower
|
||||
ln -s functions/rndis.usb0 configs/c.1/
|
||||
ln -s functions/acm.usb0 configs/c.1/
|
||||
#ln -s functions/ecm.usb0 configs/c.1/
|
||||
|
||||
# OS descriptors
|
||||
# echo 1 > os_desc/use
|
||||
# echo 0xcd > os_desc/b_vendor_code
|
||||
# echo MSFT100 > os_desc/qw_sign
|
||||
#
|
||||
# echo RNDIS > functions/rndis.usb0/os_desc/interface.rndis/compatible_id
|
||||
# echo 5162001 > functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
|
||||
#
|
||||
# ln -s configs/c.1 os_desc
|
||||
|
||||
# Assuming there is only ever going to be one UDC
|
||||
udevadm settle -t 5 || :
|
||||
ls /sys/class/udc > UDC
|
||||
|
||||
# systemctl restart networking
|
||||
# systemctl restart dnsmasq
|
||||
# systemctl restart sshd
|
||||
|
Reference in New Issue
Block a user