10945b4feSTakahiro Hirofuchi# 20945b4feSTakahiro Hirofuchi# README for usbip-utils 30945b4feSTakahiro Hirofuchi# 489415218Smatt mooney# Copyright (C) 2011 matt mooney <mfm@muteddisk.com> 589415218Smatt mooney# 2005-2008 Takahiro Hirofuchi 60945b4feSTakahiro Hirofuchi 7444d9309SKrzysztof Opasiak[Overview] 8444d9309SKrzysztof OpasiakUSB/IP protocol allows to pass USB device from server to client over the 9444d9309SKrzysztof Opasiaknetwork. Server is a machine which provides (shares) a USB device. Client is 10444d9309SKrzysztof Opasiaka machine which uses USB device provided by server over the network. 11444d9309SKrzysztof OpasiakThe USB device may be either physical device connected to a server or 12444d9309SKrzysztof Opasiaksoftware entity created on a server using USB gadget subsystem. 13444d9309SKrzysztof OpasiakWhole project consists of four parts: 14444d9309SKrzysztof Opasiak 15444d9309SKrzysztof Opasiak - usbip-vhci 16444d9309SKrzysztof Opasiak A client side kernel module which provides a virtual USB Host Controller 17444d9309SKrzysztof Opasiak and allows to import a USB device from a remote machine. 18444d9309SKrzysztof Opasiak 19444d9309SKrzysztof Opasiak - usbip-host (stub driver) 20444d9309SKrzysztof Opasiak A server side module which provides a USB device driver which can be 21444d9309SKrzysztof Opasiak bound to a physical USB device to make it exportable. 22444d9309SKrzysztof Opasiak 23444d9309SKrzysztof Opasiak - usbip-vudc 24444d9309SKrzysztof Opasiak A server side module which provides a virtual USB Device Controller and allows 25444d9309SKrzysztof Opasiak to export a USB device created using USB Gadget Subsystem. 26444d9309SKrzysztof Opasiak 27444d9309SKrzysztof Opasiak - usbip-utils 28444d9309SKrzysztof Opasiak A set of userspace tools used to handle connection and management. 29444d9309SKrzysztof Opasiak Used on both sides. 300945b4feSTakahiro Hirofuchi 310945b4feSTakahiro Hirofuchi[Requirements] 320945b4feSTakahiro Hirofuchi - USB/IP device drivers 33444d9309SKrzysztof Opasiak Found in the drivers/usb/usbip/ directory of the Linux kernel tree. 340945b4feSTakahiro Hirofuchi 3598ada08aSValentina Manea - libudev >= 2.0 3698ada08aSValentina Manea libudev library 370945b4feSTakahiro Hirofuchi 380945b4feSTakahiro Hirofuchi - libwrap0-dev 390945b4feSTakahiro Hirofuchi tcp wrapper library 400945b4feSTakahiro Hirofuchi 410945b4feSTakahiro Hirofuchi - gcc >= 4.0 420945b4feSTakahiro Hirofuchi 430945b4feSTakahiro Hirofuchi - libtool, automake >= 1.9, autoconf >= 2.5.0, pkg-config 440945b4feSTakahiro Hirofuchi 4504f7bb9dSValentina Manea[Optional] 4604f7bb9dSValentina Manea - hwdata 4704f7bb9dSValentina Manea Contains USB device identification data. 4804f7bb9dSValentina Manea 4989415218Smatt mooney 500945b4feSTakahiro Hirofuchi[Install] 5189415218Smatt mooney 0. Generate configuration scripts. 520945b4feSTakahiro Hirofuchi $ ./autogen.sh 530945b4feSTakahiro Hirofuchi 5489415218Smatt mooney 1. Compile & install the userspace utilities. 5589415218Smatt mooney $ ./configure [--with-tcp-wrappers=no] [--with-usbids-dir=<dir>] 560945b4feSTakahiro Hirofuchi $ make install 570945b4feSTakahiro Hirofuchi 5889415218Smatt mooney 2. Compile & install USB/IP drivers. 5989415218Smatt mooney 600945b4feSTakahiro Hirofuchi 610945b4feSTakahiro Hirofuchi[Usage] 62444d9309SKrzysztof OpasiakOn a server side there are two entities which can be shared. 63444d9309SKrzysztof OpasiakFirst of them is physical usb device connected to the machine. 64444d9309SKrzysztof OpasiakTo make it available below steps should be executed: 65444d9309SKrzysztof Opasiak 6689415218Smatt mooney server:# (Physically attach your USB device.) 670945b4feSTakahiro Hirofuchi 68220973ddSmatt mooney server:# insmod usbip-core.ko 69220973ddSmatt mooney server:# insmod usbip-host.ko 700945b4feSTakahiro Hirofuchi 710945b4feSTakahiro Hirofuchi server:# usbipd -D 720945b4feSTakahiro Hirofuchi - Start usbip daemon. 730945b4feSTakahiro Hirofuchi 7489415218Smatt mooney server:# usbip list -l 7589415218Smatt mooney - List driver assignments for USB devices. 760945b4feSTakahiro Hirofuchi 7789415218Smatt mooney server:# usbip bind --busid 1-2 7889415218Smatt mooney - Bind usbip-host.ko to the device with busid 1-2. 7989415218Smatt mooney - The USB device 1-2 is now exportable to other hosts! 8089415218Smatt mooney - Use `usbip unbind --busid 1-2' to stop exporting the device. 810945b4feSTakahiro Hirofuchi 82444d9309SKrzysztof OpasiakSecond of shareable entities is USB Gadget created using USB Gadget Subsystem 83444d9309SKrzysztof Opasiakon a server machine. To make it available below steps should be executed: 84444d9309SKrzysztof Opasiak 85444d9309SKrzysztof Opasiak server:# (Create your USB gadget) 86444d9309SKrzysztof Opasiak - Currently the most preferable way of creating a new USB gadget 87444d9309SKrzysztof Opasiak is ConfigFS Composite Gadget. Please refer to its documentation 88444d9309SKrzysztof Opasiak for details. 89444d9309SKrzysztof Opasiak - See vudc_server_example.sh for a short example of USB gadget creation 90444d9309SKrzysztof Opasiak 91444d9309SKrzysztof Opasiak server:# insmod usbip-core.ko 92444d9309SKrzysztof Opasiak server:# insmod usbip-vudc.ko 93444d9309SKrzysztof Opasiak - To create more than one instance of vudc use num module param 94444d9309SKrzysztof Opasiak 95444d9309SKrzysztof Opasiak server:# (Bind gadget to one of available vudc) 96444d9309SKrzysztof Opasiak - Assign your new gadget to USB/IP UDC 97444d9309SKrzysztof Opasiak - Using ConfigFS interface you may do this simply by: 98444d9309SKrzysztof Opasiak server:# cd /sys/kernel/config/usb_gadget/<gadget_name> 99444d9309SKrzysztof Opasiak server:# echo "usbip-vudc.0" > UDC 100444d9309SKrzysztof Opasiak 101444d9309SKrzysztof Opasiak server:# usbipd -D --device 102444d9309SKrzysztof Opasiak - Start usbip daemon. 103444d9309SKrzysztof Opasiak 104444d9309SKrzysztof OpasiakTo attach new device to client machine below commands should be used: 105444d9309SKrzysztof Opasiak 106220973ddSmatt mooney client:# insmod usbip-core.ko 1070945b4feSTakahiro Hirofuchi client:# insmod vhci-hcd.ko 1080945b4feSTakahiro Hirofuchi 10989415218Smatt mooney client:# usbip list --remote <host> 11089415218Smatt mooney - List exported USB devices on the <host>. 1110945b4feSTakahiro Hirofuchi 11280e4b943SKurt Kanzenbach client:# usbip attach --remote <host> --busid 1-2 1130945b4feSTakahiro Hirofuchi - Connect the remote USB device. 114444d9309SKrzysztof Opasiak - When using vudc on a server side busid is really vudc instance name. 115444d9309SKrzysztof Opasiak For example: usbip-vudc.0 1160945b4feSTakahiro Hirofuchi 11789415218Smatt mooney client:# usbip port 1180945b4feSTakahiro Hirofuchi - Show virtual port status. 1190945b4feSTakahiro Hirofuchi 12089415218Smatt mooney client:# usbip detach --port <port> 12189415218Smatt mooney - Detach the USB device. 1220945b4feSTakahiro Hirofuchi 1230945b4feSTakahiro Hirofuchi 12489415218Smatt mooney[Example] 12589415218Smatt mooney--------------------------- 12689415218Smatt mooney SERVER SIDE 12789415218Smatt mooney--------------------------- 12889415218Smatt mooneyPhysically attach your USB devices to this host. 12989415218Smatt mooney 13089415218Smatt mooney trois:# insmod path/to/usbip-core.ko 13189415218Smatt mooney trois:# insmod path/to/usbip-host.ko 1320945b4feSTakahiro Hirofuchi trois:# usbipd -D 1330945b4feSTakahiro Hirofuchi 13489415218Smatt mooneyIn another terminal, let's look up what USB devices are physically 13589415218Smatt mooneyattached to this host. 1360945b4feSTakahiro Hirofuchi 13745dd9a98Smatt mooney trois:# usbip list -l 13889415218Smatt mooney Local USB devices 13989415218Smatt mooney ================= 14089415218Smatt mooney - busid 1-1 (05a9:a511) 141*a00dfd4dSMagnus Damm 1-1:1.0 14289415218Smatt mooney 14389415218Smatt mooney - busid 3-2 (0711:0902) 144*a00dfd4dSMagnus Damm 3-2:1.0 1450945b4feSTakahiro Hirofuchi 1460945b4feSTakahiro Hirofuchi - busid 3-3.1 (08bb:2702) 147*a00dfd4dSMagnus Damm 3-3.1:1.0 148*a00dfd4dSMagnus Damm 3-3.1:1.1 1490945b4feSTakahiro Hirofuchi 15089415218Smatt mooney - busid 3-3.2 (04bb:0206) 151*a00dfd4dSMagnus Damm 3-3.2:1.0 15289415218Smatt mooney 1530945b4feSTakahiro Hirofuchi - busid 3-3 (0409:0058) 154*a00dfd4dSMagnus Damm 3-3:1.0 1550945b4feSTakahiro Hirofuchi 1560945b4feSTakahiro Hirofuchi - busid 4-1 (046d:08b2) 157*a00dfd4dSMagnus Damm 4-1:1.0 158*a00dfd4dSMagnus Damm 4-1:1.1 159*a00dfd4dSMagnus Damm 4-1:1.2 1600945b4feSTakahiro Hirofuchi 1610945b4feSTakahiro Hirofuchi - busid 5-2 (058f:9254) 162*a00dfd4dSMagnus Damm 5-2:1.0 1630945b4feSTakahiro Hirofuchi 16489415218Smatt mooneyA USB storage device of busid 3-3.2 is now bound to the usb-storage 16589415218Smatt mooneydriver. To export this device, we first mark the device as 16689415218Smatt mooney"exportable"; the device is bound to the usbip-host driver. Please 16789415218Smatt mooneyremember you can not export a USB hub. 1680945b4feSTakahiro Hirofuchi 16989415218Smatt mooneyMark the device of busid 3-3.2 as exportable: 1700945b4feSTakahiro Hirofuchi 17189415218Smatt mooney trois:# usbip --debug bind --busid 3-3.2 17289415218Smatt mooney ... 17345dd9a98Smatt mooney usbip debug: usbip_bind.c:162:[unbind_other] 3-3.2:1.0 -> usb-storage 17445dd9a98Smatt mooney ... 17545dd9a98Smatt mooney bind device on busid 3-3.2: complete 17689415218Smatt mooney 17789415218Smatt mooney trois:# usbip list -l 17889415218Smatt mooney Local USB devices 17989415218Smatt mooney ================= 18089415218Smatt mooney ... 18189415218Smatt mooney 1820945b4feSTakahiro Hirofuchi - busid 3-3.2 (04bb:0206) 183*a00dfd4dSMagnus Damm 3-3.2:1.0 18489415218Smatt mooney ... 1850945b4feSTakahiro Hirofuchi 18689415218Smatt mooney--------------------------- 18789415218Smatt mooney CLIENT SIDE 18889415218Smatt mooney--------------------------- 18989415218Smatt mooneyFirst, let's list available remote devices that are marked as 19089415218Smatt mooneyexportable on the host. 1910945b4feSTakahiro Hirofuchi 19289415218Smatt mooney deux:# insmod path/to/usbip-core.ko 19389415218Smatt mooney deux:# insmod path/to/vhci-hcd.ko 1940945b4feSTakahiro Hirofuchi 19589415218Smatt mooney deux:# usbip list --remote 10.0.0.3 19645dd9a98Smatt mooney Exportable USB devices 19745dd9a98Smatt mooney ====================== 1980945b4feSTakahiro Hirofuchi - 10.0.0.3 1990945b4feSTakahiro Hirofuchi 1-1: Prolific Technology, Inc. : unknown product (067b:3507) 2000945b4feSTakahiro Hirofuchi : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-1 2010945b4feSTakahiro Hirofuchi : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 2020945b4feSTakahiro Hirofuchi : 0 - Mass Storage / SCSI / Bulk (Zip) (08/06/50) 2030945b4feSTakahiro Hirofuchi 2040945b4feSTakahiro Hirofuchi 1-2.2.1: Apple Computer, Inc. : unknown product (05ac:0203) 2050945b4feSTakahiro Hirofuchi : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.1 2060945b4feSTakahiro Hirofuchi : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 2070945b4feSTakahiro Hirofuchi : 0 - Human Interface Devices / Boot Interface Subclass / Keyboard (03/01/01) 2080945b4feSTakahiro Hirofuchi 2090945b4feSTakahiro Hirofuchi 1-2.2.3: OmniVision Technologies, Inc. : OV511+ WebCam (05a9:a511) 2100945b4feSTakahiro Hirofuchi : /sys/devices/pci0000:00/0000:00:1f.2/usb1/1-2/1-2.2/1-2.2.3 2110945b4feSTakahiro Hirofuchi : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 2120945b4feSTakahiro Hirofuchi : 0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00) 2130945b4feSTakahiro Hirofuchi 2140945b4feSTakahiro Hirofuchi 3-1: Logitech, Inc. : QuickCam Pro 4000 (046d:08b2) 2150945b4feSTakahiro Hirofuchi : /sys/devices/pci0000:00/0000:00:1e.0/0000:02:0a.0/usb3/3-1 2160945b4feSTakahiro Hirofuchi : (Defined at Interface level) / unknown subclass / unknown protocol (00/00/00) 2170945b4feSTakahiro Hirofuchi : 0 - Data / unknown subclass / unknown protocol (0a/ff/00) 2180945b4feSTakahiro Hirofuchi : 1 - Audio / Control Device / unknown protocol (01/01/00) 2190945b4feSTakahiro Hirofuchi : 2 - Audio / Streaming / unknown protocol (01/02/00) 2200945b4feSTakahiro Hirofuchi 22189415218Smatt mooneyAttach a remote USB device: 2220945b4feSTakahiro Hirofuchi 22380e4b943SKurt Kanzenbach deux:# usbip attach --remote 10.0.0.3 --busid 1-1 2240945b4feSTakahiro Hirofuchi port 0 attached 2250945b4feSTakahiro Hirofuchi 22689415218Smatt mooneyShow the devices attached to this client: 2270945b4feSTakahiro Hirofuchi 22889415218Smatt mooney deux:# usbip port 2290945b4feSTakahiro Hirofuchi Port 00: <Port in Use> at Full Speed(12Mbps) 2300945b4feSTakahiro Hirofuchi Prolific Technology, Inc. : unknown product (067b:3507) 2310945b4feSTakahiro Hirofuchi 6-1 -> usbip://10.0.0.3:3240/1-1 (remote bus/dev 001/004) 2320945b4feSTakahiro Hirofuchi 6-1:1.0 used by usb-storage 2330945b4feSTakahiro Hirofuchi /sys/class/scsi_device/0:0:0:0/device 2340945b4feSTakahiro Hirofuchi /sys/class/scsi_host/host0/device 2350945b4feSTakahiro Hirofuchi /sys/block/sda/device 2360945b4feSTakahiro Hirofuchi 23789415218Smatt mooneyDetach the imported device: 2380945b4feSTakahiro Hirofuchi 23989415218Smatt mooney deux:# usbip detach --port 0 2400945b4feSTakahiro Hirofuchi port 0 detached 2410945b4feSTakahiro Hirofuchi 2420945b4feSTakahiro Hirofuchi 24389415218Smatt mooney[Checklist] 24489415218Smatt mooney - See 'Debug Tips' on the project wiki. 2450945b4feSTakahiro Hirofuchi - http://usbip.wiki.sourceforge.net/how-to-debug-usbip 246220973ddSmatt mooney - usbip-host.ko must be bound to the target device. 24721470e32SMauro Carvalho Chehab - See /sys/kernel/debug/usb/devices and find "Driver=..." lines of the device. 248444d9309SKrzysztof Opasiak - Target USB gadget must be bound to vudc 249444d9309SKrzysztof Opasiak (using USB gadget susbsys, not usbip bind command) 2500945b4feSTakahiro Hirofuchi - Shutdown firewall. 2510945b4feSTakahiro Hirofuchi - usbip now uses TCP port 3240. 2520945b4feSTakahiro Hirofuchi - Disable SELinux. 25389415218Smatt mooney - Check the kernel and daemon messages. 2540945b4feSTakahiro Hirofuchi 2550945b4feSTakahiro Hirofuchi 2560945b4feSTakahiro Hirofuchi[Contact] 25789415218Smatt mooney Mailing List: linux-usb@vger.kernel.org 258