1#!/bin/bash
2
3cd /sys/kernel/config/usb_gadget
4
5if [ ! -f "g1" ]; then
6    mkdir g1
7    cd g1
8
9    echo 0x1d6b > idVendor  # Linux foundation
10    echo 0x0104 > idProduct # Multifunction composite gadget
11    mkdir -p strings/0x409
12    echo "Linux" > strings/0x409/manufacturer
13    echo "Ethernet/ECM gadget" > strings/0x409/product
14
15    mkdir -p configs/c.1
16    echo 100 > configs/c.1/MaxPower
17    mkdir -p configs/c.1/strings/0x409
18    echo "ECM" > configs/c.1/strings/0x409/configuration
19
20    mkdir -p functions/ecm.usb0
21
22    ln -s functions/ecm.usb0 configs/c.1
23
24    echo f0835000.udc > UDC
25
26fi
27exit 0
28