3 ################################################################################
4 # This is free and unencumbered software released into the public domain.
6 # Anyone is free to copy, modify, publish, use, compile, sell, or
7 # distribute this software, either in source code form or as a compiled
8 # binary, for any purpose, commercial or non-commercial, and by any
11 # In jurisdictions that recognize copyright laws, the author or authors
12 # of this software dedicate any and all copyright interest in the
13 # software to the public domain. We make this dedication for the benefit
14 # of the public at large and to the detriment of our heirs and
15 # successors. We intend this dedication to be an overt act of
16 # relinquishment in perpetuity of all present and future rights to this
17 # software under copyright law.
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 # OTHER DEALINGS IN THE SOFTWARE.
27 # For more information, please refer to <https://unlicense.org/>
28 ################################################################################
30 ################################################################################
31 # This is a sample script which shows how to use vUDC with ConfigFS gadgets
32 ################################################################################
34 # Stop script on error
37 ################################################################################
38 # Create your USB gadget
39 # You may use bare ConfigFS interface (as below)
40 # or libusbgx or gt toool
41 # Instead of ConfigFS gadgets you may use any of legacy gadgets.
42 ################################################################################
43 CONFIGFS_MOUNT_POINT
="/sys/kernel/config"
48 cd ${CONFIGFS_MOUNT_POINT}/usb_gadget
49 # Create a new USB gadget
53 # This gadget contains one function - ACM (serial port over USB)
54 FUNC_DIR
="functions/acm.ser0"
57 # Just one configuration
59 ln -s ${FUNC_DIR} configs
/c
.1
61 # Set our gadget identity
62 echo ${ID_VENDOR} > idVendor
63 echo ${ID_PRODUCT} > idProduct
65 ################################################################################
66 # Load vudc-module if vudc is not available
67 # You may change value of num param to get more than one vUDC instance
68 ################################################################################
69 [[ -d /sys
/class
/udc
/usbip-vudc
.0 ]] || modprobe usbip-vudc num
=1
71 ################################################################################
72 # Bind gadget to our vUDC
73 # By default we bind to first one but you may change this if you would like
74 # to use more than one instance
75 ################################################################################
76 echo "usbip-vudc.0" > UDC
78 ################################################################################
79 # Let's now run our usbip daemon in a USB device mode
80 ################################################################################
83 ################################################################################
84 # Now your USB gadget is available using USB/IP protocol.
85 # To prepare your client, you should ensure that usbip-vhci module is inside
86 # your kernel. If it's not then you can load it:
88 # $ modprobe usbip-vhci
90 # To check availability of your gadget you may try to list devices exported
93 # $ modprobe usbip-vhci
94 # $ usbip list -r $SERVER_IP
95 # Exportable USB devices
96 # ======================
97 # usbipd: info: request 0x8005(6): complete
99 # usbip-vudc.0: Linux Foundation : unknown product (1d6b:0104)
100 # : /sys/devices/platform/usbip-vudc.0
101 # : (Defined at Interface level) (00/00/00)
103 # To attach this device to your client you may use:
105 # $ usbip attach -r $SERVER_IP -d usbip-vudc.0
107 ################################################################################