xref: /linux/tools/usb/usbip/README (revision 444d930998f87ce2b5803866ecd171fdbd2c85ec)
1588b48caSValentina Manea#
2588b48caSValentina Manea# README for usbip-utils
3588b48caSValentina Manea#
4588b48caSValentina Manea# Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
5588b48caSValentina Manea#               2005-2008 Takahiro Hirofuchi
6588b48caSValentina Manea
7*444d9309SKrzysztof Opasiak[Overview]
8*444d9309SKrzysztof OpasiakUSB/IP protocol allows to pass USB device from server to client over the
9*444d9309SKrzysztof Opasiaknetwork. Server is a machine which provides (shares) a USB device. Client is
10*444d9309SKrzysztof Opasiaka machine which uses USB device provided by server over the network.
11*444d9309SKrzysztof OpasiakThe USB device may be either physical device connected to a server or
12*444d9309SKrzysztof Opasiaksoftware entity created on a server using USB gadget subsystem.
13*444d9309SKrzysztof OpasiakWhole project consists of four parts:
14*444d9309SKrzysztof Opasiak
15*444d9309SKrzysztof Opasiak    - usbip-vhci
16*444d9309SKrzysztof Opasiak        A client side kernel module which provides a virtual USB Host Controller
17*444d9309SKrzysztof Opasiak        and allows to import a USB device from a remote machine.
18*444d9309SKrzysztof Opasiak
19*444d9309SKrzysztof Opasiak    - usbip-host (stub driver)
20*444d9309SKrzysztof Opasiak        A server side module which provides a USB device driver which can be
21*444d9309SKrzysztof Opasiak        bound to a physical USB device to make it exportable.
22*444d9309SKrzysztof Opasiak
23*444d9309SKrzysztof Opasiak    - usbip-vudc
24*444d9309SKrzysztof Opasiak        A server side module which provides a virtual USB Device Controller and allows
25*444d9309SKrzysztof Opasiak        to export a USB device created using USB Gadget Subsystem.
26*444d9309SKrzysztof Opasiak
27*444d9309SKrzysztof Opasiak    - usbip-utils
28*444d9309SKrzysztof Opasiak        A set of userspace tools used to handle connection and management.
29*444d9309SKrzysztof Opasiak        Used on both sides.
30588b48caSValentina Manea
31588b48caSValentina Manea[Requirements]
32588b48caSValentina Manea    - USB/IP device drivers
33*444d9309SKrzysztof Opasiak        Found in the drivers/usb/usbip/ directory of the Linux kernel tree.
34588b48caSValentina Manea
35588b48caSValentina Manea    - libudev >= 2.0
36588b48caSValentina Manea	libudev library
37588b48caSValentina Manea
38588b48caSValentina Manea    - libwrap0-dev
39588b48caSValentina Manea	tcp wrapper library
40588b48caSValentina Manea
41588b48caSValentina Manea    - gcc >= 4.0
42588b48caSValentina Manea
43588b48caSValentina Manea    - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config
44588b48caSValentina Manea
45588b48caSValentina Manea[Optional]
46588b48caSValentina Manea    - hwdata
47588b48caSValentina Manea        Contains USB device identification data.
48588b48caSValentina Manea
49588b48caSValentina Manea
50588b48caSValentina Manea[Install]
51588b48caSValentina Manea    0. Generate configuration scripts.
52588b48caSValentina Manea	$ ./autogen.sh
53588b48caSValentina Manea
54588b48caSValentina Manea    1. Compile & install the userspace utilities.
55588b48caSValentina Manea	$ ./configure [--with-tcp-wrappers=no] [--with-usbids-dir=<dir>]
56588b48caSValentina Manea	$ make install
57588b48caSValentina Manea
58588b48caSValentina Manea    2. Compile & install USB/IP drivers.
59588b48caSValentina Manea
60588b48caSValentina Manea
61588b48caSValentina Manea[Usage]
62*444d9309SKrzysztof OpasiakOn a server side there are two entities which can be shared.
63*444d9309SKrzysztof OpasiakFirst of them is physical usb device connected to the machine.
64*444d9309SKrzysztof OpasiakTo make it available below steps should be executed:
65*444d9309SKrzysztof Opasiak
66588b48caSValentina Manea    server:# (Physically attach your USB device.)
67588b48caSValentina Manea
68588b48caSValentina Manea    server:# insmod usbip-core.ko
69588b48caSValentina Manea    server:# insmod usbip-host.ko
70588b48caSValentina Manea
71588b48caSValentina Manea    server:# usbipd -D
72588b48caSValentina Manea	- Start usbip daemon.
73588b48caSValentina Manea
74588b48caSValentina Manea    server:# usbip list -l
75588b48caSValentina Manea	- List driver assignments for USB devices.
76588b48caSValentina Manea
77588b48caSValentina Manea    server:# usbip bind --busid 1-2
78588b48caSValentina Manea	- Bind usbip-host.ko to the device with busid 1-2.
79588b48caSValentina Manea	- The USB device 1-2 is now exportable to other hosts!
80588b48caSValentina Manea	- Use `usbip unbind --busid 1-2' to stop exporting the device.
81588b48caSValentina Manea
82*444d9309SKrzysztof OpasiakSecond of shareable entities is USB Gadget created using USB Gadget Subsystem
83*444d9309SKrzysztof Opasiakon a server machine. To make it available below steps should be executed:
84*444d9309SKrzysztof Opasiak
85*444d9309SKrzysztof Opasiak    server:# (Create your USB gadget)
86*444d9309SKrzysztof Opasiak        - Currently the most preferable way of creating a new USB gadget
87*444d9309SKrzysztof Opasiak          is ConfigFS Composite Gadget. Please refer to its documentation
88*444d9309SKrzysztof Opasiak          for details.
89*444d9309SKrzysztof Opasiak        - See vudc_server_example.sh for a short example of USB gadget creation
90*444d9309SKrzysztof Opasiak
91*444d9309SKrzysztof Opasiak    server:# insmod usbip-core.ko
92*444d9309SKrzysztof Opasiak    server:# insmod usbip-vudc.ko
93*444d9309SKrzysztof Opasiak        - To create more than one instance of vudc use num module param
94*444d9309SKrzysztof Opasiak
95*444d9309SKrzysztof Opasiak    server:# (Bind gadget to one of available vudc)
96*444d9309SKrzysztof Opasiak        - Assign your new gadget to USB/IP UDC
97*444d9309SKrzysztof Opasiak        - Using ConfigFS interface you may do this simply by:
98*444d9309SKrzysztof Opasiak            server:# cd /sys/kernel/config/usb_gadget/<gadget_name>
99*444d9309SKrzysztof Opasiak            server:# echo "usbip-vudc.0" > UDC
100*444d9309SKrzysztof Opasiak
101*444d9309SKrzysztof Opasiak    server:# usbipd -D --device
102*444d9309SKrzysztof Opasiak        - Start usbip daemon.
103*444d9309SKrzysztof Opasiak
104*444d9309SKrzysztof OpasiakTo attach new device to client machine below commands should be used:
105*444d9309SKrzysztof Opasiak
106588b48caSValentina Manea    client:# insmod usbip-core.ko
107588b48caSValentina Manea    client:# insmod vhci-hcd.ko
108588b48caSValentina Manea
109588b48caSValentina Manea    client:# usbip list --remote <host>
110588b48caSValentina Manea	- List exported USB devices on the <host>.
111588b48caSValentina Manea
112588b48caSValentina Manea    client:# usbip attach --remote <host> --busid 1-2
113588b48caSValentina Manea	- Connect the remote USB device.
114*444d9309SKrzysztof Opasiak	- When using vudc on a server side busid is really vudc instance name.
115*444d9309SKrzysztof Opasiak	  For example: usbip-vudc.0
116588b48caSValentina Manea
117588b48caSValentina Manea    client:# usbip port
118588b48caSValentina Manea	- Show virtual port status.
119588b48caSValentina Manea
120588b48caSValentina Manea    client:# usbip detach --port <port>
121588b48caSValentina Manea	- Detach the USB device.
122588b48caSValentina Manea
123588b48caSValentina Manea
124588b48caSValentina Manea[Example]
125588b48caSValentina Manea---------------------------
126588b48caSValentina Manea	SERVER SIDE
127588b48caSValentina Manea---------------------------
128588b48caSValentina ManeaPhysically attach your USB devices to this host.
129588b48caSValentina Manea
130588b48caSValentina Manea    trois:# insmod path/to/usbip-core.ko
131588b48caSValentina Manea    trois:# insmod path/to/usbip-host.ko
132588b48caSValentina Manea    trois:# usbipd -D
133588b48caSValentina Manea
134588b48caSValentina ManeaIn another terminal, let's look up what USB devices are physically
135588b48caSValentina Maneaattached to this host.
136588b48caSValentina Manea
137588b48caSValentina Manea    trois:# usbip list -l
138588b48caSValentina Manea    Local USB devices
139588b48caSValentina Manea    =================
140588b48caSValentina Manea     - busid 1-1 (05a9:a511)
141588b48caSValentina Manea	     1-1:1.0 -> ov511
142588b48caSValentina Manea
143588b48caSValentina Manea     - busid 3-2 (0711:0902)
144588b48caSValentina Manea	     3-2:1.0 -> none
145588b48caSValentina Manea
146588b48caSValentina Manea     - busid 3-3.1 (08bb:2702)
147588b48caSValentina Manea	     3-3.1:1.0 -> snd-usb-audio
148588b48caSValentina Manea	     3-3.1:1.1 -> snd-usb-audio
149588b48caSValentina Manea
150588b48caSValentina Manea     - busid 3-3.2 (04bb:0206)
151588b48caSValentina Manea	     3-3.2:1.0 -> usb-storage
152588b48caSValentina Manea
153588b48caSValentina Manea     - busid 3-3 (0409:0058)
154588b48caSValentina Manea	     3-3:1.0 -> hub
155588b48caSValentina Manea
156588b48caSValentina Manea     - busid 4-1 (046d:08b2)
157588b48caSValentina Manea	     4-1:1.0 -> none
158588b48caSValentina Manea	     4-1:1.1 -> none
159588b48caSValentina Manea	     4-1:1.2 -> none
160588b48caSValentina Manea
161588b48caSValentina Manea     - busid 5-2 (058f:9254)
162588b48caSValentina Manea	     5-2:1.0 -> hub
163588b48caSValentina Manea
164588b48caSValentina ManeaA USB storage device of busid 3-3.2 is now bound to the usb-storage
165588b48caSValentina Maneadriver. To export this device, we first mark the device as
166588b48caSValentina Manea"exportable"; the device is bound to the usbip-host driver. Please
167588b48caSValentina Manearemember you can not export a USB hub.
168588b48caSValentina Manea
169588b48caSValentina ManeaMark the device of busid 3-3.2 as exportable:
170588b48caSValentina Manea
171588b48caSValentina Manea    trois:# usbip --debug bind --busid 3-3.2
172588b48caSValentina Manea    ...
173588b48caSValentina Manea    usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage
174588b48caSValentina Manea    ...
175588b48caSValentina Manea    bind device on busid 3-3.2: complete
176588b48caSValentina Manea
177588b48caSValentina Manea    trois:# usbip list -l
178588b48caSValentina Manea    Local USB devices
179588b48caSValentina Manea    =================
180588b48caSValentina Manea    ...
181588b48caSValentina Manea
182588b48caSValentina Manea     - busid 3-3.2 (04bb:0206)
183588b48caSValentina Manea	     3-3.2:1.0 -> usbip-host
184588b48caSValentina Manea    ...
185588b48caSValentina Manea
186588b48caSValentina Manea---------------------------
187588b48caSValentina Manea	CLIENT SIDE
188588b48caSValentina Manea---------------------------
189588b48caSValentina ManeaFirst, let's list available remote devices that are marked as
190588b48caSValentina Maneaexportable on the host.
191588b48caSValentina Manea
192588b48caSValentina Manea    deux:# insmod path/to/usbip-core.ko
193588b48caSValentina Manea    deux:# insmod path/to/vhci-hcd.ko
194588b48caSValentina Manea
195588b48caSValentina Manea    deux:# usbip list --remote 10.0.0.3
196588b48caSValentina Manea    Exportable USB devices
197588b48caSValentina Manea    ======================
198588b48caSValentina Manea     - 10.0.0.3
199588b48caSValentina Manea	    1-1: Prolific Technology, Inc. : unknown product (067b:3507)
200588b48caSValentina Manea	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1
201588b48caSValentina Manea	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
202588b48caSValentina Manea	       :  0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50)
203588b48caSValentina Manea
204588b48caSValentina Manea	1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203)
205588b48caSValentina Manea	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1
206588b48caSValentina Manea	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
207588b48caSValentina Manea	       :  0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01)
208588b48caSValentina Manea
209588b48caSValentina Manea	1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511)
210588b48caSValentina Manea	       : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3
211588b48caSValentina Manea	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
212588b48caSValentina Manea	       :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
213588b48caSValentina Manea
214588b48caSValentina Manea	    3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2)
215588b48caSValentina Manea	       : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1
216588b48caSValentina Manea	       : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00)
217588b48caSValentina Manea	       :  0 - Data / unknown subclass / unknown protocol (0a/ff/00)
218588b48caSValentina Manea	       :  1 - Audio / Control Device / unknown protocol (01/01/00)
219588b48caSValentina Manea	       :  2 - Audio / Streaming / unknown protocol (01/02/00)
220588b48caSValentina Manea
221588b48caSValentina ManeaAttach a remote USB device:
222588b48caSValentina Manea
223588b48caSValentina Manea    deux:# usbip attach --remote 10.0.0.3 --busid 1-1
224588b48caSValentina Manea    port 0 attached
225588b48caSValentina Manea
226588b48caSValentina ManeaShow the devices attached to this client:
227588b48caSValentina Manea
228588b48caSValentina Manea    deux:# usbip port
229588b48caSValentina Manea    Port 00: <Port in Use> at Full Speed(12Mbps)
230588b48caSValentina Manea	   Prolific Technology, Inc. : unknown product (067b:3507)
231588b48caSValentina Manea	   6-1 -> usbip://10.0.0.3:3240/1-1  (remote bus/dev 001/004)
232588b48caSValentina Manea	   6-1:1.0 used by usb-storage
233588b48caSValentina Manea			  /sys/class/scsi_device/0:0:0:0/device
234588b48caSValentina Manea			  /sys/class/scsi_host/host0/device
235588b48caSValentina Manea			  /sys/block/sda/device
236588b48caSValentina Manea
237588b48caSValentina ManeaDetach the imported device:
238588b48caSValentina Manea
239588b48caSValentina Manea    deux:# usbip detach --port 0
240588b48caSValentina Manea    port 0 detached
241588b48caSValentina Manea
242588b48caSValentina Manea
243588b48caSValentina Manea[Checklist]
244588b48caSValentina Manea    - See 'Debug Tips' on the project wiki.
245588b48caSValentina Manea	- http://usbip.wiki.sourceforge.net/how-to-debug-usbip
246588b48caSValentina Manea    - usbip-host.ko must be bound to the target device.
247588b48caSValentina Manea	- See /proc/bus/usb/devices and find "Driver=..." lines of the device.
248*444d9309SKrzysztof Opasiak    - Target USB gadget must be bound to vudc
249*444d9309SKrzysztof Opasiak      (using USB gadget susbsys, not usbip bind command)
250588b48caSValentina Manea    - Shutdown firewall.
251588b48caSValentina Manea	- usbip now uses TCP port 3240.
252588b48caSValentina Manea    - Disable SELinux.
253588b48caSValentina Manea    - Check the kernel and daemon messages.
254588b48caSValentina Manea
255588b48caSValentina Manea
256588b48caSValentina Manea[Contact]
257588b48caSValentina Manea    Mailing List: linux-usb@vger.kernel.org
258