-
-
Save bartec-rnerella/c976bd6d6f4893c227524c3cb6c0cbd6 to your computer and use it in GitHub Desktop.
Revisions
-
eballetbo created this gist
Jul 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/usr/bin/env bash # mount configfs mount -t configfs none /sys/kernel/config # load libcomposite module modprobe libcomposite # create a gadget mkdir /sys/kernel/config/usb_gadget/g1 # cd to its configfs node cd /sys/kernel/config/usb_gadget/g1 # configure it (vid/pid can be anything if USB Class is used for driver compat) echo 0xabcd > idVendor echo 0x1234 > idProduct # configure its serial/mfg/product mkdir strings/0x409 echo myserial > strings/0x409/serialnumber echo mymfg > strings/0x409/manufacturer echo myproduct > strings/0x409/product # create a config mkdir configs/c.1 # configure it with attributes if needed echo 120 > configs/c.1/MaxPower # ensure function is loaded modprobe usb_f_ecm # create the function (name must match a usb_f_<name> module such as 'ecm') mkdir functions/ecm.0 # associate function with config ln -s functions/ecm.0 configs/c.1 # enable gadget by binding it to a UDC from /sys/class/udc echo 0000:01:00.0 > UDC # to unbind it: echo "" UDC; sleep 1; rm -rf /sys/kernel/config/usb_gadget/g1