Advertisement
Guest User

Untitled

a guest
Sep 10th, 2024
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.55 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Define paths and addresses
  4. GADGET_DIR="/sys/kernel/config/usb_gadget/g1"
  5. HOST="00:dc:c8:f7:75:15"
  6. SELF="00:dd:dc:eb:6d:a1"
  7.  
  8.  
  9.   # Create USB gadget
  10.   mkdir -p $GADGET_DIR
  11.   cd $GADGET_DIR
  12.  
  13.   # Set basic device properties
  14.   echo 0x1d6b > idVendor  # Linux Foundation
  15.   echo 0x0104 > idProduct # Multifunction Composite Gadget
  16.   echo 0x0100 > bcdDevice # v1.1.0
  17.   echo 0x0200 > bcdUSB    # USB 2.0
  18.  
  19.   # Add English strings
  20.   mkdir -p strings/0x409
  21.   echo "0001" > strings/0x409/serialnumber
  22.   echo "WulfData" > strings/0x409/manufacturer
  23.   echo "Speakers and Audio System" > strings/0x409/product
  24.  
  25.   # Create configuration
  26.   mkdir -p configs/c.1
  27.   mkdir -p configs/c.1/strings/0x409
  28.   echo "Config 1" > configs/c.1/strings/0x409/configuration
  29.   echo 500 > configs/c.1/MaxPower
  30.  
  31.   mkdir functions/ncm.usb0
  32.   # echo $HOST > functions/ecm.usb0/host_addr
  33.   # echo $SELF > functions/ecm.usb0/dev_addr
  34.   ln -s functions/ncm.usb0 configs/c.1/
  35.  
  36.   # Add Audio Function (UAC2)
  37.   mkdir -p functions/uac2.usb0
  38.   echo 48000 > functions/uac2.usb0/c_srate
  39.   echo 48000 > functions/uac2.usb0/p_srate
  40.   # echo 51 > functions/uac2.usb0/c_chmask # "110011".to_i(2)
  41.   echo 3 > functions/uac2.usb0/c_chmask
  42.   echo 1 > functions/uac2.usb0/p_chmask
  43.  
  44.   echo 4 > functions/uac2.usb0/c_ssize
  45.   echo 2 > functions/uac2.usb0/p_ssize
  46.   ln -s functions/uac2.usb0 configs/c.1/
  47.  
  48.   # Enable the gadget
  49.   UDC=$(ls /sys/class/udc | head -n 1)
  50.   echo $UDC > UDC
  51.   # ip link set usb0 up
  52.   sleep 1
  53.   # systemctl start isc-dhcp-server
  54.   systemctl start dnsmasq
  55.  
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement