18c2ecf20Sopenharmony_ci#
28c2ecf20Sopenharmony_ci# README for usbip-utils
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
58c2ecf20Sopenharmony_ci#               2005-2008 Takahiro Hirofuchi
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci[Overview]
88c2ecf20Sopenharmony_ciUSB/IP protocol allows to pass USB device from server to client over the
98c2ecf20Sopenharmony_cinetwork. Server is a machine which provides (shares) a USB device. Client is
108c2ecf20Sopenharmony_cia machine which uses USB device provided by server over the network.
118c2ecf20Sopenharmony_ciThe USB device may be either physical device connected to a server or
128c2ecf20Sopenharmony_cisoftware entity created on a server using USB gadget subsystem.
138c2ecf20Sopenharmony_ciWhole project consists of four parts:
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci    - usbip-vhci
168c2ecf20Sopenharmony_ci        A client side kernel module which provides a virtual USB Host Controller
178c2ecf20Sopenharmony_ci        and allows to import a USB device from a remote machine.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci    - usbip-host (stub driver)
208c2ecf20Sopenharmony_ci        A server side module which provides a USB device driver which can be
218c2ecf20Sopenharmony_ci        bound to a physical USB device to make it exportable.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci    - usbip-vudc
248c2ecf20Sopenharmony_ci        A server side module which provides a virtual USB Device Controller and allows
258c2ecf20Sopenharmony_ci        to export a USB device created using USB Gadget Subsystem.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci    - usbip-utils
288c2ecf20Sopenharmony_ci        A set of userspace tools used to handle connection and management.
298c2ecf20Sopenharmony_ci        Used on both sides.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci[Requirements]
328c2ecf20Sopenharmony_ci    - USB/IP device drivers
338c2ecf20Sopenharmony_ci        Found in the drivers/usb/usbip/ directory of the Linux kernel tree.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci    - libudev >= 2.0
368c2ecf20Sopenharmony_ci	libudev library
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci    - libwrap0-dev
398c2ecf20Sopenharmony_ci	tcp wrapper library
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci    - gcc >= 4.0
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci    - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci[Optional]
468c2ecf20Sopenharmony_ci    - hwdata
478c2ecf20Sopenharmony_ci        Contains USB device identification data.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci[Install]
518c2ecf20Sopenharmony_ci    0. Generate configuration scripts.
528c2ecf20Sopenharmony_ci	$ ./autogen.sh
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci    1. Compile & install the userspace utilities.
558c2ecf20Sopenharmony_ci	$ ./configure [--with-tcp-wrappers=no] [--with-usbids-dir=<dir>]
568c2ecf20Sopenharmony_ci	$ make install
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci    2. Compile & install USB/IP drivers.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci[Usage]
628c2ecf20Sopenharmony_ciOn a server side there are two entities which can be shared.
638c2ecf20Sopenharmony_ciFirst of them is physical usb device connected to the machine.
648c2ecf20Sopenharmony_ciTo make it available below steps should be executed:
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci    server:# (Physically attach your USB device.)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci    server:# insmod usbip-core.ko
698c2ecf20Sopenharmony_ci    server:# insmod usbip-host.ko
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci    server:# usbipd -D
728c2ecf20Sopenharmony_ci	- Start usbip daemon.
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci    server:# usbip list -l
758c2ecf20Sopenharmony_ci	- List driver assignments for USB devices.
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci    server:# usbip bind --busid 1-2
788c2ecf20Sopenharmony_ci	- Bind usbip-host.ko to the device with busid 1-2.
798c2ecf20Sopenharmony_ci	- The USB device 1-2 is now exportable to other hosts!
808c2ecf20Sopenharmony_ci	- Use `usbip unbind --busid 1-2' to stop exporting the device.
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciSecond of shareable entities is USB Gadget created using USB Gadget Subsystem
838c2ecf20Sopenharmony_cion a server machine. To make it available below steps should be executed:
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci    server:# (Create your USB gadget)
868c2ecf20Sopenharmony_ci        - Currently the most preferable way of creating a new USB gadget
878c2ecf20Sopenharmony_ci          is ConfigFS Composite Gadget. Please refer to its documentation
888c2ecf20Sopenharmony_ci          for details.
898c2ecf20Sopenharmony_ci        - See vudc_server_example.sh for a short example of USB gadget creation
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci    server:# insmod usbip-core.ko
928c2ecf20Sopenharmony_ci    server:# insmod usbip-vudc.ko
938c2ecf20Sopenharmony_ci        - To create more than one instance of vudc use num module param
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci    server:# (Bind gadget to one of available vudc)
968c2ecf20Sopenharmony_ci        - Assign your new gadget to USB/IP UDC
978c2ecf20Sopenharmony_ci        - Using ConfigFS interface you may do this simply by:
988c2ecf20Sopenharmony_ci            server:# cd /sys/kernel/config/usb_gadget/<gadget_name>
998c2ecf20Sopenharmony_ci            server:# echo "usbip-vudc.0" > UDC
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci    server:# usbipd -D --device
1028c2ecf20Sopenharmony_ci        - Start usbip daemon.
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciTo attach new device to client machine below commands should be used:
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci    client:# insmod usbip-core.ko
1078c2ecf20Sopenharmony_ci    client:# insmod vhci-hcd.ko
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci    client:# usbip list --remote <host>
1108c2ecf20Sopenharmony_ci	- List exported USB devices on the <host>.
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci    client:# usbip attach --remote <host> --busid 1-2
1138c2ecf20Sopenharmony_ci	- Connect the remote USB device.
1148c2ecf20Sopenharmony_ci	- When using vudc on a server side busid is really vudc instance name.
1158c2ecf20Sopenharmony_ci	  For example: usbip-vudc.0
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci    client:# usbip port
1188c2ecf20Sopenharmony_ci	- Show virtual port status.
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci    client:# usbip detach --port <port>
1218c2ecf20Sopenharmony_ci	- Detach the USB device.
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci[Example]
1258c2ecf20Sopenharmony_ci---------------------------
1268c2ecf20Sopenharmony_ci	SERVER SIDE
1278c2ecf20Sopenharmony_ci---------------------------
1288c2ecf20Sopenharmony_ciPhysically attach your USB devices to this host.
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci    trois:# insmod path/to/usbip-core.ko
1318c2ecf20Sopenharmony_ci    trois:# insmod path/to/usbip-host.ko
1328c2ecf20Sopenharmony_ci    trois:# usbipd -D
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciIn another terminal, let's look up what USB devices are physically
1358c2ecf20Sopenharmony_ciattached to this host.
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci    trois:# usbip list -l
1388c2ecf20Sopenharmony_ci    Local USB devices
1398c2ecf20Sopenharmony_ci    =================
1408c2ecf20Sopenharmony_ci     - busid 1-1 (05a9:a511)
1418c2ecf20Sopenharmony_ci	     1-1:1.0
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci     - busid 3-2 (0711:0902)
1448c2ecf20Sopenharmony_ci	     3-2:1.0
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci     - busid 3-3.1 (08bb:2702)
1478c2ecf20Sopenharmony_ci	     3-3.1:1.0
1488c2ecf20Sopenharmony_ci	     3-3.1:1.1
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci     - busid 3-3.2 (04bb:0206)
1518c2ecf20Sopenharmony_ci	     3-3.2:1.0
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci     - busid 3-3 (0409:0058)
1548c2ecf20Sopenharmony_ci	     3-3:1.0
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci     - busid 4-1 (046d:08b2)
1578c2ecf20Sopenharmony_ci	     4-1:1.0
1588c2ecf20Sopenharmony_ci	     4-1:1.1
1598c2ecf20Sopenharmony_ci	     4-1:1.2
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci     - busid 5-2 (058f:9254)
1628c2ecf20Sopenharmony_ci	     5-2:1.0
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ciA USB storage device of busid 3-3.2 is now bound to the usb-storage
1658c2ecf20Sopenharmony_cidriver. To export this device, we first mark the device as
1668c2ecf20Sopenharmony_ci"exportable"; the device is bound to the usbip-host driver. Please
1678c2ecf20Sopenharmony_ciremember you can not export a USB hub.
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ciMark the device of busid 3-3.2 as exportable:
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci    trois:# usbip --debug bind --busid 3-3.2
1728c2ecf20Sopenharmony_ci    ...
1738c2ecf20Sopenharmony_ci    usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage
1748c2ecf20Sopenharmony_ci    ...
1758c2ecf20Sopenharmony_ci    bind device on busid 3-3.2: complete
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci    trois:# usbip list -l
1788c2ecf20Sopenharmony_ci    Local USB devices
1798c2ecf20Sopenharmony_ci    =================
1808c2ecf20Sopenharmony_ci    ...
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci     - busid 3-3.2 (04bb:0206)
1838c2ecf20Sopenharmony_ci	     3-3.2:1.0
1848c2ecf20Sopenharmony_ci    ...
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci---------------------------
1878c2ecf20Sopenharmony_ci	CLIENT SIDE
1888c2ecf20Sopenharmony_ci---------------------------
1898c2ecf20Sopenharmony_ciFirst, let's list available remote devices that are marked as
1908c2ecf20Sopenharmony_ciexportable on the host.
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci    deux:# insmod path/to/usbip-core.ko
1938c2ecf20Sopenharmony_ci    deux:# insmod path/to/vhci-hcd.ko
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci    deux:# usbip list --remote 10.0.0.3
1968c2ecf20Sopenharmony_ci    Exportable USB devices
1978c2ecf20Sopenharmony_ci    ======================
1988c2ecf20Sopenharmony_ci     - 10.0.0.3
1998c2ecf20Sopenharmony_ci	    1-1: Prolific Technology, Inc. : unknown product (067b:3507)
2008c2ecf20Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
2018c2ecf20Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
2028c2ecf20Sopenharmony_ci	       :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci	1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
2058c2ecf20Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
2068c2ecf20Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
2078c2ecf20Sopenharmony_ci	       :  0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
2108c2ecf20Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
2118c2ecf20Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
2128c2ecf20Sopenharmony_ci	       :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci	    3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
2158c2ecf20Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
2168c2ecf20Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
2178c2ecf20Sopenharmony_ci	       :  0 - Data / unknown subclass / unknown protocol (0a/ff/00)
2188c2ecf20Sopenharmony_ci	       :  1 - Audio / Control Device / unknown protocol (01/01/00)
2198c2ecf20Sopenharmony_ci	       :  2 - Audio / Streaming / unknown protocol (01/02/00)
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ciAttach a remote USB device:
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci    deux:# usbip attach --remote 10.0.0.3 --busid 1-1
2248c2ecf20Sopenharmony_ci    port 0 attached
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ciShow the devices attached to this client:
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci    deux:# usbip port
2298c2ecf20Sopenharmony_ci    Port 00: <Port in Use> at Full Speed(12Mbps)
2308c2ecf20Sopenharmony_ci	   Prolific Technology, Inc. : unknown product (067b:3507)
2318c2ecf20Sopenharmony_ci	   6-1 -> usbip://10.0.0.3:3240/1-1  (remote bus/dev 001/004)
2328c2ecf20Sopenharmony_ci	   6-1:1.0 used by usb-storage
2338c2ecf20Sopenharmony_ci			  /sys/class/scsi_device/0:0:0:0/device
2348c2ecf20Sopenharmony_ci			  /sys/class/scsi_host/host0/device
2358c2ecf20Sopenharmony_ci			  /sys/block/sda/device
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ciDetach the imported device:
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci    deux:# usbip detach --port 0
2408c2ecf20Sopenharmony_ci    port 0 detached
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci[Checklist]
2448c2ecf20Sopenharmony_ci    - See 'Debug Tips' on the project wiki.
2458c2ecf20Sopenharmony_ci	- http://usbip.wiki.sourceforge.net/how-to-debug-usbip
2468c2ecf20Sopenharmony_ci    - usbip-host.ko must be bound to the target device.
2478c2ecf20Sopenharmony_ci	- See /sys/kernel/debug/usb/devices and find "Driver=..." lines of the device.
2488c2ecf20Sopenharmony_ci    - Target USB gadget must be bound to vudc
2498c2ecf20Sopenharmony_ci      (using USB gadget susbsys, not usbip bind command)
2508c2ecf20Sopenharmony_ci    - Shutdown firewall.
2518c2ecf20Sopenharmony_ci	- usbip now uses TCP port 3240.
2528c2ecf20Sopenharmony_ci    - Disable SELinux.
2538c2ecf20Sopenharmony_ci    - Check the kernel and daemon messages.
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci[Contact]
2578c2ecf20Sopenharmony_ci    Mailing List: linux-usb@vger.kernel.org
258