Revision as of 20:14, 19 February 2012 by Craig Peacock (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

USB/IP: USB device sharing over IP

The USB/IP project allows sharing of USB devices over an IP network. It encapsulates USB I/O request packets and transmits them over IP using TCP port 3240.

Kernel Source

USBIP has been moved into the staging directory of the kernel tree since version 2.6.28. The usermode applications are in the drivers/staging/usbip/userspace folder.

The latest version can be obtained from the kernel source or from here

To compile in server support into your kernel, enable the following at the kernel config menu :

Device Drivers -> Staging drivers -> USB/IP support
Device Drivers -> Staging drivers -> USB/IP support -> Host driver

If you would like to use the same kernel as the client, additionally enable :

Device Drivers -> Staging drivers -> USB/IP support -> VHCI hcd

Cross Compiling the Userland Utilities

The USB/IP Utilities require sysfsutils and glib 2.6.0+ as dependencies.

sysfsutils

Download sysfsutils and cross compile for ARM assuming your ARM cross compiler is located at /opt/arm-2011.09/

wget http://sourceforge.net/projects/linuxdiag/files/sysfsutils/2.1.0/sysfsutils-2.1.0.tar.gz
tar -xzf sysfsutils-2.1.0.tar.gz
cd sysfsutils-2.1.0
./configure \
       --target=arm-none-linux-gnueabi \
       --host=arm-none-linux-gnueabi \
       --prefix=/opt/arm-2011.09/arm-none-linux-gnueabi
make
make install 

glib

Download glib and cross compile for ARM:

wget http://ftp.gnome.org/pub/GNOME/sources/glib/2.18/glib-2.18.4.tar.gz
tar -xzf glib-2.18.4.tar.gz
cd glib-2.18.4

Create the following file (arm.cache) :

glib_cv_long_long_format=ll
glib_cv_stack_grows=no 
glib_cv_sane_realloc=yes
glib_cv_have_strlcpy=no
glib_cv_va_val_copy=yes
glib_cv_rtldglobal_broken=no
glib_cv_uscore=no
glib_cv_monotonic_clock=no
ac_cv_func_nonposix_getpwuid_r=no 
ac_cv_func_posix_getpwuid_r=no
ac_cv_func_posix_getgrgid_r=no
glib_cv_use_pid_surrogate=yes 
ac_cv_func_printf_unix98=no
ac_cv_func_vsnprintf_c99=yes
ac_cv_func_realloc_0_nonnull=yes 
ac_cv_func_realloc_works=yes
./configure \
 --target=arm-none-linux-gnueabi \
 --host=arm-none-linux-gnueabi \
 --prefix=/opt/arm-2011.09/arm-none-linux-gnueabi \
 --cache-file=arm.cache 
make
make install

USB/IP userspace

With our dependencies out of the way, we can finally compile our userland utilities. The userland utilities can be found in the kernel source.

cd drivers/staging/usbip/userspace
./autogen.sh
PACKAGE_CFLAGS="-I/opt/arm-2011.09/arm-none-linux-gnueabi/include/glib-2.0 -I/opt/arm-2011.09/arm-none-linux-gnueabi/lib/glib-2.0/include"
./configure \
       --target=arm-none-linux-gnueabi \
       --host=arm-none-linux-gnueabi \
       --prefix=/home/cpeacock/export/rootfs-f12
make
make install

Using USBIP

Server

On the server side, you must start the daemon and export any devices you want to share.

To start the daemon :

# /sbin/usbipd -D

To list the devices to export :

# ./usbip list -l
Local USB devices
=================
 - busid 1-1 (05e3:0608)
         1-1:1.0 -> hub

 - busid 1-1.1 (05e3:0726)
         1-1.1:1.0 -> usb-storage

 - busid 1-1.2 (045e:0750)
         1-1.2:1.0 -> usbhid
         1-1.2:1.1 -> usbhid

 - busid 1-1.3 (046d:080a)
         1-1.3:1.0 -> unknown
         1-1.3:1.1 -> unknown
         1-1.3:1.2 -> unknown
         1-1.3:1.3 -> unknown

And to export a device (.e.g the HID device):

./usbip bind -b 1-1.2

Client

A Windows Client can be downloaded from here

Follow the instructions called USAGE on how to install and use.