162306a36Sopenharmony_ci#
262306a36Sopenharmony_ci# README for usbip-utils
362306a36Sopenharmony_ci#
462306a36Sopenharmony_ci# Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
562306a36Sopenharmony_ci#               2005-2008 Takahiro Hirofuchi
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci[Overview]
862306a36Sopenharmony_ciUSB/IP protocol allows to pass USB device from server to client over the
962306a36Sopenharmony_cinetwork. Server is a machine which provides (shares) a USB device. Client is
1062306a36Sopenharmony_cia machine which uses USB device provided by server over the network.
1162306a36Sopenharmony_ciThe USB device may be either physical device connected to a server or
1262306a36Sopenharmony_cisoftware entity created on a server using USB gadget subsystem.
1362306a36Sopenharmony_ciWhole project consists of four parts:
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci    - usbip-vhci
1662306a36Sopenharmony_ci        A client side kernel module which provides a virtual USB Host Controller
1762306a36Sopenharmony_ci        and allows to import a USB device from a remote machine.
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci    - usbip-host (stub driver)
2062306a36Sopenharmony_ci        A server side module which provides a USB device driver which can be
2162306a36Sopenharmony_ci        bound to a physical USB device to make it exportable.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci    - usbip-vudc
2462306a36Sopenharmony_ci        A server side module which provides a virtual USB Device Controller and allows
2562306a36Sopenharmony_ci        to export a USB device created using USB Gadget Subsystem.
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci    - usbip-utils
2862306a36Sopenharmony_ci        A set of userspace tools used to handle connection and management.
2962306a36Sopenharmony_ci        Used on both sides.
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci[Requirements]
3262306a36Sopenharmony_ci    - USB/IP device drivers
3362306a36Sopenharmony_ci        Found in the drivers/usb/usbip/ directory of the Linux kernel tree.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci    - libudev >= 2.0
3662306a36Sopenharmony_ci	libudev library
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci    - libwrap0-dev
3962306a36Sopenharmony_ci	tcp wrapper library
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci    - gcc >= 4.0
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci    - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci[Optional]
4662306a36Sopenharmony_ci    - hwdata
4762306a36Sopenharmony_ci        Contains USB device identification data.
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci[Install]
5162306a36Sopenharmony_ci    0. Generate configuration scripts.
5262306a36Sopenharmony_ci	$ ./autogen.sh
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci    1. Compile & install the userspace utilities.
5562306a36Sopenharmony_ci	$ ./configure [--with-tcp-wrappers=no] [--with-usbids-dir=<dir>]
5662306a36Sopenharmony_ci	$ make install
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci    2. Compile & install USB/IP drivers.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci[Usage]
6262306a36Sopenharmony_ciOn a server side there are two entities which can be shared.
6362306a36Sopenharmony_ciFirst of them is physical usb device connected to the machine.
6462306a36Sopenharmony_ciTo make it available below steps should be executed:
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci    server:# (Physically attach your USB device.)
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci    server:# insmod usbip-core.ko
6962306a36Sopenharmony_ci    server:# insmod usbip-host.ko
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci    server:# usbipd -D
7262306a36Sopenharmony_ci	- Start usbip daemon.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci    server:# usbip list -l
7562306a36Sopenharmony_ci	- List driver assignments for USB devices.
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci    server:# usbip bind --busid 1-2
7862306a36Sopenharmony_ci	- Bind usbip-host.ko to the device with busid 1-2.
7962306a36Sopenharmony_ci	- The USB device 1-2 is now exportable to other hosts!
8062306a36Sopenharmony_ci	- Use `usbip unbind --busid 1-2' to stop exporting the device.
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ciSecond of shareable entities is USB Gadget created using USB Gadget Subsystem
8362306a36Sopenharmony_cion a server machine. To make it available below steps should be executed:
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci    server:# (Create your USB gadget)
8662306a36Sopenharmony_ci        - Currently the most preferable way of creating a new USB gadget
8762306a36Sopenharmony_ci          is ConfigFS Composite Gadget. Please refer to its documentation
8862306a36Sopenharmony_ci          for details.
8962306a36Sopenharmony_ci        - See vudc_server_example.sh for a short example of USB gadget creation
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci    server:# insmod usbip-core.ko
9262306a36Sopenharmony_ci    server:# insmod usbip-vudc.ko
9362306a36Sopenharmony_ci        - To create more than one instance of vudc use num module param
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci    server:# (Bind gadget to one of available vudc)
9662306a36Sopenharmony_ci        - Assign your new gadget to USB/IP UDC
9762306a36Sopenharmony_ci        - Using ConfigFS interface you may do this simply by:
9862306a36Sopenharmony_ci            server:# cd /sys/kernel/config/usb_gadget/<gadget_name>
9962306a36Sopenharmony_ci            server:# echo "usbip-vudc.0" > UDC
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci    server:# usbipd -D --device
10262306a36Sopenharmony_ci        - Start usbip daemon.
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciTo attach new device to client machine below commands should be used:
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci    client:# insmod usbip-core.ko
10762306a36Sopenharmony_ci    client:# insmod vhci-hcd.ko
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci    client:# usbip list --remote <host>
11062306a36Sopenharmony_ci	- List exported USB devices on the <host>.
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci    client:# usbip attach --remote <host> --busid 1-2
11362306a36Sopenharmony_ci	- Connect the remote USB device.
11462306a36Sopenharmony_ci	- When using vudc on a server side busid is really vudc instance name.
11562306a36Sopenharmony_ci	  For example: usbip-vudc.0
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci    client:# usbip port
11862306a36Sopenharmony_ci	- Show virtual port status.
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci    client:# usbip detach --port <port>
12162306a36Sopenharmony_ci	- Detach the USB device.
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci[Example]
12562306a36Sopenharmony_ci---------------------------
12662306a36Sopenharmony_ci	SERVER SIDE
12762306a36Sopenharmony_ci---------------------------
12862306a36Sopenharmony_ciPhysically attach your USB devices to this host.
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci    trois:# insmod path/to/usbip-core.ko
13162306a36Sopenharmony_ci    trois:# insmod path/to/usbip-host.ko
13262306a36Sopenharmony_ci    trois:# usbipd -D
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ciIn another terminal, let's look up what USB devices are physically
13562306a36Sopenharmony_ciattached to this host.
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci    trois:# usbip list -l
13862306a36Sopenharmony_ci    Local USB devices
13962306a36Sopenharmony_ci    =================
14062306a36Sopenharmony_ci     - busid 1-1 (05a9:a511)
14162306a36Sopenharmony_ci	     1-1:1.0
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci     - busid 3-2 (0711:0902)
14462306a36Sopenharmony_ci	     3-2:1.0
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci     - busid 3-3.1 (08bb:2702)
14762306a36Sopenharmony_ci	     3-3.1:1.0
14862306a36Sopenharmony_ci	     3-3.1:1.1
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci     - busid 3-3.2 (04bb:0206)
15162306a36Sopenharmony_ci	     3-3.2:1.0
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci     - busid 3-3 (0409:0058)
15462306a36Sopenharmony_ci	     3-3:1.0
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci     - busid 4-1 (046d:08b2)
15762306a36Sopenharmony_ci	     4-1:1.0
15862306a36Sopenharmony_ci	     4-1:1.1
15962306a36Sopenharmony_ci	     4-1:1.2
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci     - busid 5-2 (058f:9254)
16262306a36Sopenharmony_ci	     5-2:1.0
16362306a36Sopenharmony_ci
16462306a36Sopenharmony_ciA USB storage device of busid 3-3.2 is now bound to the usb-storage
16562306a36Sopenharmony_cidriver. To export this device, we first mark the device as
16662306a36Sopenharmony_ci"exportable"; the device is bound to the usbip-host driver. Please
16762306a36Sopenharmony_ciremember you can not export a USB hub.
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ciMark the device of busid 3-3.2 as exportable:
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci    trois:# usbip --debug bind --busid 3-3.2
17262306a36Sopenharmony_ci    ...
17362306a36Sopenharmony_ci    usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage
17462306a36Sopenharmony_ci    ...
17562306a36Sopenharmony_ci    bind device on busid 3-3.2: complete
17662306a36Sopenharmony_ci
17762306a36Sopenharmony_ci    trois:# usbip list -l
17862306a36Sopenharmony_ci    Local USB devices
17962306a36Sopenharmony_ci    =================
18062306a36Sopenharmony_ci    ...
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci     - busid 3-3.2 (04bb:0206)
18362306a36Sopenharmony_ci	     3-3.2:1.0
18462306a36Sopenharmony_ci    ...
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci---------------------------
18762306a36Sopenharmony_ci	CLIENT SIDE
18862306a36Sopenharmony_ci---------------------------
18962306a36Sopenharmony_ciFirst, let's list available remote devices that are marked as
19062306a36Sopenharmony_ciexportable on the host.
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci    deux:# insmod path/to/usbip-core.ko
19362306a36Sopenharmony_ci    deux:# insmod path/to/vhci-hcd.ko
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci    deux:# usbip list --remote 10.0.0.3
19662306a36Sopenharmony_ci    Exportable USB devices
19762306a36Sopenharmony_ci    ======================
19862306a36Sopenharmony_ci     - 10.0.0.3
19962306a36Sopenharmony_ci	    1-1: Prolific Technology, Inc. : unknown product (067b:3507)
20062306a36Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
20162306a36Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
20262306a36Sopenharmony_ci	       :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci	1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
20562306a36Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
20662306a36Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
20762306a36Sopenharmony_ci	       :  0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci	1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
21062306a36Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
21162306a36Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
21262306a36Sopenharmony_ci	       :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci	    3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
21562306a36Sopenharmony_ci	       : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
21662306a36Sopenharmony_ci	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
21762306a36Sopenharmony_ci	       :  0 - Data / unknown subclass / unknown protocol (0a/ff/00)
21862306a36Sopenharmony_ci	       :  1 - Audio / Control Device / unknown protocol (01/01/00)
21962306a36Sopenharmony_ci	       :  2 - Audio / Streaming / unknown protocol (01/02/00)
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ciAttach a remote USB device:
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci    deux:# usbip attach --remote 10.0.0.3 --busid 1-1
22462306a36Sopenharmony_ci    port 0 attached
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ciShow the devices attached to this client:
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci    deux:# usbip port
22962306a36Sopenharmony_ci    Port 00: <Port in Use> at Full Speed(12Mbps)
23062306a36Sopenharmony_ci	   Prolific Technology, Inc. : unknown product (067b:3507)
23162306a36Sopenharmony_ci	   6-1 -> usbip://10.0.0.3:3240/1-1  (remote bus/dev 001/004)
23262306a36Sopenharmony_ci	   6-1:1.0 used by usb-storage
23362306a36Sopenharmony_ci			  /sys/class/scsi_device/0:0:0:0/device
23462306a36Sopenharmony_ci			  /sys/class/scsi_host/host0/device
23562306a36Sopenharmony_ci			  /sys/block/sda/device
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ciDetach the imported device:
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_ci    deux:# usbip detach --port 0
24062306a36Sopenharmony_ci    port 0 detached
24162306a36Sopenharmony_ci
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci[Checklist]
24462306a36Sopenharmony_ci    - See 'Debug Tips' on the project wiki.
24562306a36Sopenharmony_ci	- http://usbip.wiki.sourceforge.net/how-to-debug-usbip
24662306a36Sopenharmony_ci    - usbip-host.ko must be bound to the target device.
24762306a36Sopenharmony_ci	- See /sys/kernel/debug/usb/devices and find "Driver=..." lines of the device.
24862306a36Sopenharmony_ci    - Target USB gadget must be bound to vudc
24962306a36Sopenharmony_ci      (using USB gadget susbsys, not usbip bind command)
25062306a36Sopenharmony_ci    - Shutdown firewall.
25162306a36Sopenharmony_ci	- usbip now uses TCP port 3240.
25262306a36Sopenharmony_ci    - Disable SELinux.
25362306a36Sopenharmony_ci    - Check the kernel and daemon messages.
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci[Contact]
25762306a36Sopenharmony_ci    Mailing List: linux-usb@vger.kernel.org
258