Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Define paths and addresses
- GADGET_DIR="/sys/kernel/config/usb_gadget/g1"
- HOST="00:dc:c8:f7:75:15"
- SELF="00:dd:dc:eb:6d:a1"
- # Create USB gadget
- mkdir -p $GADGET_DIR
- cd $GADGET_DIR
- # Set basic device properties
- echo 0x1d6b > idVendor # Linux Foundation
- echo 0x0104 > idProduct # Multifunction Composite Gadget
- echo 0x0100 > bcdDevice # v1.1.0
- echo 0x0200 > bcdUSB # USB 2.0
- # Add English strings
- mkdir -p strings/0x409
- echo "0001" > strings/0x409/serialnumber
- echo "WulfData" > strings/0x409/manufacturer
- echo "Speakers and Audio System" > strings/0x409/product
- # Create configuration
- mkdir -p configs/c.1
- mkdir -p configs/c.1/strings/0x409
- echo "Config 1" > configs/c.1/strings/0x409/configuration
- echo 500 > configs/c.1/MaxPower
- mkdir functions/ncm.usb0
- # echo $HOST > functions/ecm.usb0/host_addr
- # echo $SELF > functions/ecm.usb0/dev_addr
- ln -s functions/ncm.usb0 configs/c.1/
- # Add Audio Function (UAC2)
- mkdir -p functions/uac2.usb0
- echo 48000 > functions/uac2.usb0/c_srate
- echo 48000 > functions/uac2.usb0/p_srate
- # echo 51 > functions/uac2.usb0/c_chmask # "110011".to_i(2)
- echo 3 > functions/uac2.usb0/c_chmask
- echo 1 > functions/uac2.usb0/p_chmask
- echo 4 > functions/uac2.usb0/c_ssize
- echo 2 > functions/uac2.usb0/p_ssize
- ln -s functions/uac2.usb0 configs/c.1/
- # Enable the gadget
- UDC=$(ls /sys/class/udc | head -n 1)
- echo $UDC > UDC
- # ip link set usb0 up
- sleep 1
- # systemctl start isc-dhcp-server
- systemctl start dnsmasq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement