Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ID_VENDOR="0x1d6b"
- ID_PRODUCT="0x0104"
- SERIAL="$(grep Serial /proc/cpuinfo | sed 's/Serial\s*: 0000\(\w*\)/\1/')"
- MAC="$(echo ${SERIAL} | sed 's/\(\w\w\)/:\1/g' | cut -b 2-)"
- MAC_HOST="12$(echo ${MAC} | cut -b 3-)"
- MAC_DEV="02$(echo ${MAC} | cut -b 3-)"
- g="/sys/kernel/config/usb_gadget/g"
- modprobe libcomposite
- write_config() {
- if [ ! -d "${g}/$(dirname $2)" ]; then
- mkdir -p ${g}/$(dirname $2)
- fi
- if [ -f "${g}/$2" ]; then
- if [ "$(cat ${g}/$2)" != "$1" ]; then
- echo "$1" > "${g}/$2"
- fi
- else
- echo "$1" > "${g}/$2"
- fi
- }
- write_config "" UDC
- write_config ${ID_VENDOR} idVendor # Linux Foundation
- write_config ${ID_PRODUCT} idProduct # Multifunction Composite Gadget
- write_config 0x0100 bcdDevice
- write_config 0x0200 bcdUSB
- write_config 0xEF bDeviceClass
- write_config 0x02 bDeviceSubClass
- write_config 0x01 bDeviceProtocol
- mkdir -p ${g}/strings/0x409
- write_config "${SERIAL}" strings/0x409/serialnumber
- write_config "Zefie Networks" strings/0x409/manufacturer
- write_config "Raspberry Pi Zero Gadget" strings/0x409/product
- write_config 1 os_desc/use
- write_config 0xcd os_desc/b_vendor_code
- write_config MSFT100 os_desc/qw_sign
- mkdir -p ${g}/functions/acm.GS0 # serial
- mkdir -p ${g}/functions/rndis.usb0 # network
- write_config $MAC_HOST functions/rndis.usb0/host_addr
- write_config $MAC_DEV functions/rndis.usb0/dev_addr
- write_config RNDIS functions/rndis.usb0/os_desc/interface.rndis/compatible_id
- write_config 5162001 functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
- write_config 250 configs/c.1/MaxPower
- ln -s ${g}/configs/c.1 ${g}/os_desc
- ln -s ${g}/functions/rndis.usb0 ${g}/configs/c.1/
- ln -s ${g}/functions/acm.GS0 ${g}/configs/c.1/
- udevadm settle -t 5 || :
- write_config $(ls -1 /sys/class/udc) UDC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement