1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# README for usbip-utils 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# Copyright (C) 2011 matt mooney <mfm@muteddisk.com> 5*4882a593Smuzhiyun# 2005-2008 Takahiro Hirofuchi 6*4882a593Smuzhiyun 7*4882a593Smuzhiyun[Overview] 8*4882a593SmuzhiyunUSB/IP protocol allows to pass USB device from server to client over the 9*4882a593Smuzhiyunnetwork. Server is a machine which provides (shares) a USB device. Client is 10*4882a593Smuzhiyuna machine which uses USB device provided by server over the network. 11*4882a593SmuzhiyunThe USB device may be either physical device connected to a server or 12*4882a593Smuzhiyunsoftware entity created on a server using USB gadget subsystem. 13*4882a593SmuzhiyunWhole project consists of four parts: 14*4882a593Smuzhiyun 15*4882a593Smuzhiyun - usbip-vhci 16*4882a593Smuzhiyun A client side kernel module which provides a virtual USB Host Controller 17*4882a593Smuzhiyun and allows to import a USB device from a remote machine. 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun - usbip-host (stub driver) 20*4882a593Smuzhiyun A server side module which provides a USB device driver which can be 21*4882a593Smuzhiyun bound to a physical USB device to make it exportable. 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun - usbip-vudc 24*4882a593Smuzhiyun A server side module which provides a virtual USB Device Controller and allows 25*4882a593Smuzhiyun to export a USB device created using USB Gadget Subsystem. 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun - usbip-utils 28*4882a593Smuzhiyun A set of userspace tools used to handle connection and management. 29*4882a593Smuzhiyun Used on both sides. 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun[Requirements] 32*4882a593Smuzhiyun - USB/IP device drivers 33*4882a593Smuzhiyun Found in the drivers/usb/usbip/ directory of the Linux kernel tree. 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun - libudev >= 2.0 36*4882a593Smuzhiyun libudev library 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun - libwrap0-dev 39*4882a593Smuzhiyun tcp wrapper library 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun - gcc >= 4.0 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun[Optional] 46*4882a593Smuzhiyun - hwdata 47*4882a593Smuzhiyun Contains USB device identification data. 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun[Install] 51*4882a593Smuzhiyun 0. Generate configuration scripts. 52*4882a593Smuzhiyun $ ./autogen.sh 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun 1. Compile & install the userspace utilities. 55*4882a593Smuzhiyun $ ./configure [--with-tcp-wrappers=no] [--with-usbids-dir=<dir>] 56*4882a593Smuzhiyun $ make install 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun 2. Compile & install USB/IP drivers. 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun[Usage] 62*4882a593SmuzhiyunOn a server side there are two entities which can be shared. 63*4882a593SmuzhiyunFirst of them is physical usb device connected to the machine. 64*4882a593SmuzhiyunTo make it available below steps should be executed: 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun server:# (Physically attach your USB device.) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyun server:# insmod usbip-core.ko 69*4882a593Smuzhiyun server:# insmod usbip-host.ko 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun server:# usbipd -D 72*4882a593Smuzhiyun - Start usbip daemon. 73*4882a593Smuzhiyun 74*4882a593Smuzhiyun server:# usbip list -l 75*4882a593Smuzhiyun - List driver assignments for USB devices. 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun server:# usbip bind --busid 1-2 78*4882a593Smuzhiyun - Bind usbip-host.ko to the device with busid 1-2. 79*4882a593Smuzhiyun - The USB device 1-2 is now exportable to other hosts! 80*4882a593Smuzhiyun - Use `usbip unbind --busid 1-2' to stop exporting the device. 81*4882a593Smuzhiyun 82*4882a593SmuzhiyunSecond of shareable entities is USB Gadget created using USB Gadget Subsystem 83*4882a593Smuzhiyunon a server machine. To make it available below steps should be executed: 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun server:# (Create your USB gadget) 86*4882a593Smuzhiyun - Currently the most preferable way of creating a new USB gadget 87*4882a593Smuzhiyun is ConfigFS Composite Gadget. Please refer to its documentation 88*4882a593Smuzhiyun for details. 89*4882a593Smuzhiyun - See vudc_server_example.sh for a short example of USB gadget creation 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun server:# insmod usbip-core.ko 92*4882a593Smuzhiyun server:# insmod usbip-vudc.ko 93*4882a593Smuzhiyun - To create more than one instance of vudc use num module param 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun server:# (Bind gadget to one of available vudc) 96*4882a593Smuzhiyun - Assign your new gadget to USB/IP UDC 97*4882a593Smuzhiyun - Using ConfigFS interface you may do this simply by: 98*4882a593Smuzhiyun server:# cd /sys/kernel/config/usb_gadget/<gadget_name> 99*4882a593Smuzhiyun server:# echo "usbip-vudc.0" > UDC 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun server:# usbipd -D --device 102*4882a593Smuzhiyun - Start usbip daemon. 103*4882a593Smuzhiyun 104*4882a593SmuzhiyunTo attach new device to client machine below commands should be used: 105*4882a593Smuzhiyun 106*4882a593Smuzhiyun client:# insmod usbip-core.ko 107*4882a593Smuzhiyun client:# insmod vhci-hcd.ko 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun client:# usbip list --remote <host> 110*4882a593Smuzhiyun - List exported USB devices on the <host>. 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun client:# usbip attach --remote <host> --busid 1-2 113*4882a593Smuzhiyun - Connect the remote USB device. 114*4882a593Smuzhiyun - When using vudc on a server side busid is really vudc instance name. 115*4882a593Smuzhiyun For example: usbip-vudc.0 116*4882a593Smuzhiyun 117*4882a593Smuzhiyun client:# usbip port 118*4882a593Smuzhiyun - Show virtual port status. 119*4882a593Smuzhiyun 120*4882a593Smuzhiyun client:# usbip detach --port <port> 121*4882a593Smuzhiyun - Detach the USB device. 122*4882a593Smuzhiyun 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun[Example] 125*4882a593Smuzhiyun--------------------------- 126*4882a593Smuzhiyun SERVER SIDE 127*4882a593Smuzhiyun--------------------------- 128*4882a593SmuzhiyunPhysically attach your USB devices to this host. 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun trois:# insmod path/to/usbip-core.ko 131*4882a593Smuzhiyun trois:# insmod path/to/usbip-host.ko 132*4882a593Smuzhiyun trois:# usbipd -D 133*4882a593Smuzhiyun 134*4882a593SmuzhiyunIn another terminal, let's look up what USB devices are physically 135*4882a593Smuzhiyunattached to this host. 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun trois:# usbip list -l 138*4882a593Smuzhiyun Local USB devices 139*4882a593Smuzhiyun ================= 140*4882a593Smuzhiyun - busid 1-1 (05a9:a511) 141*4882a593Smuzhiyun 1-1:1.0 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun - busid 3-2 (0711:0902) 144*4882a593Smuzhiyun 3-2:1.0 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun - busid 3-3.1 (08bb:2702) 147*4882a593Smuzhiyun 3-3.1:1.0 148*4882a593Smuzhiyun 3-3.1:1.1 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun - busid 3-3.2 (04bb:0206) 151*4882a593Smuzhiyun 3-3.2:1.0 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun - busid 3-3 (0409:0058) 154*4882a593Smuzhiyun 3-3:1.0 155*4882a593Smuzhiyun 156*4882a593Smuzhiyun - busid 4-1 (046d:08b2) 157*4882a593Smuzhiyun 4-1:1.0 158*4882a593Smuzhiyun 4-1:1.1 159*4882a593Smuzhiyun 4-1:1.2 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun - busid 5-2 (058f:9254) 162*4882a593Smuzhiyun 5-2:1.0 163*4882a593Smuzhiyun 164*4882a593SmuzhiyunA USB storage device of busid 3-3.2 is now bound to the usb-storage 165*4882a593Smuzhiyundriver. To export this device, we first mark the device as 166*4882a593Smuzhiyun"exportable"; the device is bound to the usbip-host driver. Please 167*4882a593Smuzhiyunremember you can not export a USB hub. 168*4882a593Smuzhiyun 169*4882a593SmuzhiyunMark the device of busid 3-3.2 as exportable: 170*4882a593Smuzhiyun 171*4882a593Smuzhiyun trois:# usbip --debug bind --busid 3-3.2 172*4882a593Smuzhiyun ... 173*4882a593Smuzhiyun usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage 174*4882a593Smuzhiyun ... 175*4882a593Smuzhiyun bind device on busid 3-3.2: complete 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun trois:# usbip list -l 178*4882a593Smuzhiyun Local USB devices 179*4882a593Smuzhiyun ================= 180*4882a593Smuzhiyun ... 181*4882a593Smuzhiyun 182*4882a593Smuzhiyun - busid 3-3.2 (04bb:0206) 183*4882a593Smuzhiyun 3-3.2:1.0 184*4882a593Smuzhiyun ... 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun--------------------------- 187*4882a593Smuzhiyun CLIENT SIDE 188*4882a593Smuzhiyun--------------------------- 189*4882a593SmuzhiyunFirst, let's list available remote devices that are marked as 190*4882a593Smuzhiyunexportable on the host. 191*4882a593Smuzhiyun 192*4882a593Smuzhiyun deux:# insmod path/to/usbip-core.ko 193*4882a593Smuzhiyun deux:# insmod path/to/vhci-hcd.ko 194*4882a593Smuzhiyun 195*4882a593Smuzhiyun deux:# usbip list --remote 10.0.0.3 196*4882a593Smuzhiyun Exportable USB devices 197*4882a593Smuzhiyun ====================== 198*4882a593Smuzhiyun - 10.0.0.3 199*4882a593Smuzhiyun 1-1: Prolific Technology, Inc. : unknown product (067b:3507) 200*4882a593Smuzhiyun : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1 201*4882a593Smuzhiyun : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 202*4882a593Smuzhiyun : 0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50) 203*4882a593Smuzhiyun 204*4882a593Smuzhiyun 1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203) 205*4882a593Smuzhiyun : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1 206*4882a593Smuzhiyun : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 207*4882a593Smuzhiyun : 0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01) 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun 1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511) 210*4882a593Smuzhiyun : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3 211*4882a593Smuzhiyun : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 212*4882a593Smuzhiyun : 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00) 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun 3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2) 215*4882a593Smuzhiyun : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1 216*4882a593Smuzhiyun : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 217*4882a593Smuzhiyun : 0 - Data / unknown subclass / unknown protocol (0a/ff/00) 218*4882a593Smuzhiyun : 1 - Audio / Control Device / unknown protocol (01/01/00) 219*4882a593Smuzhiyun : 2 - Audio / Streaming / unknown protocol (01/02/00) 220*4882a593Smuzhiyun 221*4882a593SmuzhiyunAttach a remote USB device: 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun deux:# usbip attach --remote 10.0.0.3 --busid 1-1 224*4882a593Smuzhiyun port 0 attached 225*4882a593Smuzhiyun 226*4882a593SmuzhiyunShow the devices attached to this client: 227*4882a593Smuzhiyun 228*4882a593Smuzhiyun deux:# usbip port 229*4882a593Smuzhiyun Port 00: <Port in Use> at Full Speed(12Mbps) 230*4882a593Smuzhiyun Prolific Technology, Inc. : unknown product (067b:3507) 231*4882a593Smuzhiyun 6-1 -> usbip://10.0.0.3:3240/1-1 (remote bus/dev 001/004) 232*4882a593Smuzhiyun 6-1:1.0 used by usb-storage 233*4882a593Smuzhiyun /sys/class/scsi_device/0:0:0:0/device 234*4882a593Smuzhiyun /sys/class/scsi_host/host0/device 235*4882a593Smuzhiyun /sys/block/sda/device 236*4882a593Smuzhiyun 237*4882a593SmuzhiyunDetach the imported device: 238*4882a593Smuzhiyun 239*4882a593Smuzhiyun deux:# usbip detach --port 0 240*4882a593Smuzhiyun port 0 detached 241*4882a593Smuzhiyun 242*4882a593Smuzhiyun 243*4882a593Smuzhiyun[Checklist] 244*4882a593Smuzhiyun - See 'Debug Tips' on the project wiki. 245*4882a593Smuzhiyun - http://usbip.wiki.sourceforge.net/how-to-debug-usbip 246*4882a593Smuzhiyun - usbip-host.ko must be bound to the target device. 247*4882a593Smuzhiyun - See /sys/kernel/debug/usb/devices and find "Driver=..." lines of the device. 248*4882a593Smuzhiyun - Target USB gadget must be bound to vudc 249*4882a593Smuzhiyun (using USB gadget susbsys, not usbip bind command) 250*4882a593Smuzhiyun - Shutdown firewall. 251*4882a593Smuzhiyun - usbip now uses TCP port 3240. 252*4882a593Smuzhiyun - Disable SELinux. 253*4882a593Smuzhiyun - Check the kernel and daemon messages. 254*4882a593Smuzhiyun 255*4882a593Smuzhiyun 256*4882a593Smuzhiyun[Contact] 257*4882a593Smuzhiyun Mailing List: linux-usb@vger.kernel.org 258