aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb/usbip
diff options
context:
space:
mode:
Diffstat (limited to 'tools/usb/usbip')
-rw-r--r--tools/usb/usbip/README57
-rwxr-xr-xtools/usb/usbip/vudc/vudc_server_example.sh107
2 files changed, 163 insertions, 1 deletions
diff --git a/tools/usb/usbip/README b/tools/usb/usbip/README
index 831f49fea3ce..5eb2b6c7722b 100644
--- a/tools/usb/usbip/README
+++ b/tools/usb/usbip/README
@@ -4,10 +4,33 @@
# Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
# 2005-2008 Takahiro Hirofuchi
+[Overview]
+USB/IP protocol allows to pass USB device from server to client over the
+network. Server is a machine which provides (shares) a USB device. Client is
+a machine which uses USB device provided by server over the network.
+The USB device may be either physical device connected to a server or
+software entity created on a server using USB gadget subsystem.
+Whole project consists of four parts:
+
+ - usbip-vhci
+ A client side kernel module which provides a virtual USB Host Controller
+ and allows to import a USB device from a remote machine.
+
+ - usbip-host (stub driver)
+ A server side module which provides a USB device driver which can be
+ bound to a physical USB device to make it exportable.
+
+ - usbip-vudc
+ A server side module which provides a virtual USB Device Controller and allows
+ to export a USB device created using USB Gadget Subsystem.
+
+ - usbip-utils
+ A set of userspace tools used to handle connection and management.
+ Used on both sides.
[Requirements]
- USB/IP device drivers
- Found in the staging directory of the Linux kernel.
+ Found in the drivers/usb/usbip/ directory of the Linux kernel tree.
- libudev >= 2.0
libudev library
@@ -36,6 +59,10 @@
[Usage]
+On a server side there are two entities which can be shared.
+First of them is physical usb device connected to the machine.
+To make it available below steps should be executed:
+
server:# (Physically attach your USB device.)
server:# insmod usbip-core.ko
@@ -52,6 +79,30 @@
- The USB device 1-2 is now exportable to other hosts!
- Use `usbip unbind --busid 1-2' to stop exporting the device.
+Second of shareable entities is USB Gadget created using USB Gadget Subsystem
+on a server machine. To make it available below steps should be executed:
+
+ server:# (Create your USB gadget)
+ - Currently the most preferable way of creating a new USB gadget
+ is ConfigFS Composite Gadget. Please refer to its documentation
+ for details.
+ - See vudc_server_example.sh for a short example of USB gadget creation
+
+ server:# insmod usbip-core.ko
+ server:# insmod usbip-vudc.ko
+ - To create more than one instance of vudc use num module param
+
+ server:# (Bind gadget to one of available vudc)
+ - Assign your new gadget to USB/IP UDC
+ - Using ConfigFS interface you may do this simply by:
+ server:# cd /sys/kernel/config/usb_gadget/<gadget_name>
+ server:# echo "usbip-vudc.0" > UDC
+
+ server:# usbipd -D --device
+ - Start usbip daemon.
+
+To attach new device to client machine below commands should be used:
+
client:# insmod usbip-core.ko
client:# insmod vhci-hcd.ko
@@ -60,6 +111,8 @@
client:# usbip attach --remote <host> --busid 1-2
- Connect the remote USB device.
+ - When using vudc on a server side busid is really vudc instance name.
+ For example: usbip-vudc.0
client:# usbip port
- Show virtual port status.
@@ -192,6 +245,8 @@ Detach the imported device:
- http://usbip.wiki.sourceforge.net/how-to-debug-usbip
- usbip-host.ko must be bound to the target device.
- See /proc/bus/usb/devices and find "Driver=..." lines of the device.
+ - Target USB gadget must be bound to vudc
+ (using USB gadget susbsys, not usbip bind command)
- Shutdown firewall.
- usbip now uses TCP port 3240.
- Disable SELinux.
diff --git a/tools/usb/usbip/vudc/vudc_server_example.sh b/tools/usb/usbip/vudc/vudc_server_example.sh
new file mode 100755
index 000000000000..2736be64f203
--- /dev/null
+++ b/tools/usb/usbip/vudc/vudc_server_example.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+
+################################################################################
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# For more information, please refer to <http://unlicense.org/>
+################################################################################
+
+################################################################################
+# This is a sample script which shows how to use vUDC with ConfigFS gadgets
+################################################################################
+
+# Stop script on error
+set -e
+
+################################################################################
+# Create your USB gadget
+# You may use bare ConfigFS interface (as below)
+# or libusbgx or gt toool
+# Instead of ConfigFS gadgets you may use any of legacy gadgets.
+################################################################################
+CONFIGFS_MOUNT_POINT="/sys/kernel/config"
+GADGET_NAME="g1"
+ID_VENDOR="0x1d6b"
+ID_PRODUCT="0x0104"
+
+cd ${CONFIGFS_MOUNT_POINT}/usb_gadget
+# Create a new USB gadget
+mkdir ${GADGET_NAME}
+cd ${GADGET_NAME}
+
+# This gadget contains one function - ACM (serial port over USB)
+FUNC_DIR="functions/acm.ser0"
+mkdir ${FUNC_DIR}
+
+# Just one configuration
+mkdir configs/c.1
+ln -s ${FUNC_DIR} configs/c.1
+
+# Set our gadget identity
+echo ${ID_VENDOR} > idVendor
+echo ${ID_PRODUCT} > idProduct
+
+################################################################################
+# Load vudc-module if vudc is not available
+# You may change value of num param to get more than one vUDC instance
+################################################################################
+[[ -d /sys/class/udc/usbip-vudc.0 ]] || modprobe usbip-vudc num=1
+
+################################################################################
+# Bind gadget to our vUDC
+# By default we bind to first one but you may change this if you would like
+# to use more than one instance
+################################################################################
+echo "usbip-vudc.0" > UDC
+
+################################################################################
+# Let's now run our usbip daemon in a USB device mode
+################################################################################
+usbipd --device &
+
+################################################################################
+# Now your USB gadget is available using USB/IP protocol.
+# To prepare your client, you should ensure that usbip-vhci module is inside
+# your kernel. If it's not then you can load it:
+#
+# $ modprobe usbip-vhci
+#
+# To check availability of your gadget you may try to list devices exported
+# on a remote server:
+#
+# $ modprobe usbip-vhci
+# $ usbip list -r $SERVER_IP
+# Exportable USB devices
+# ======================
+# usbipd: info: request 0x8005(6): complete
+# - 127.0.0.1
+# usbip-vudc.0: Linux Foundation : unknown product (1d6b:0104)
+# : /sys/devices/platform/usbip-vudc.0
+# : (Defined at Interface level) (00/00/00)
+#
+# To attach this device to your client you may use:
+#
+# $ usbip attach -r $SERVER_IP -d usbip-vudc.0
+#
+################################################################################