USB/IP Project aims to develop a general USB device sharing system over IP network. To share USB devices between computers with their full functionality, USB/IP encapsulates “USB I/O messages” into TCP/IP payloads and transmits them between computers.
In this post, we explain the steps need to take to install USBIP on a pcDuino.
Because the default kernel doesn’t support USBIP, we need to rebuild the kernel with USBIP enabled. We have published many posts about how to compile and replace kernel on pcDuino. We are going to repeat here to refresh the memory.
In the kernel build post, we build pcDuino kernel on a X86 PC with cross-compilation. In this post, we are going to show something interesting by building kernel on pcDuino itself. Besides the time it takes to build, another issue is the storage space on pcDuino. There are two ways to get around: one is to use a large SD card, and the other one is to use NFS to make an external storage area to pcDuino.
Extra Space provided by SD card:
Let’s look at first option, ‘extra space provided by SD card’. We use a 16G SD card and boot from this SD card.
In this work, we need to login as root user:
1
|
$sudo su |
First, we need to download source files of kernel:
For your convenience, we hosted the kernel source files for pcDuino also at amazon cloud. We are going to work at at directory ” /lib/modules/3.4.29+”.
1
2
3
4
|
$cd /lib/modules/3.4.29+ root@ubuntu:/lib/modules/3.4.29+#wget https://s3.amazonaws.com/linksprite/pcduino/kernel/linux-sunxi.tar.bz2 root@ubuntu:/lib/modules/3.4.29+#wget https://s3.amazonaws.com/linksprite/pcduino/kernel/sun4i_defconfig root@ubuntu:/lib/modules/3.4.29+#tar jxf linux-sunxi.tar.bz2 |
We create a directory named ‘build’ under “/lib/modules/3.4.29+”, and we copy ‘
sun4i_defconfig’ to the directory ‘build’, and rename as ‘.config’.
1
2
|
root@ubuntu:/lib/modules/3.4.29+#mkdir build root@ubuntu:/lib/modules/3.4.29+#cp ../linux-sunxi/sun4i_defconfig ../build/.config |
Before we build the kernel, we need to install some necessary packages:
1
|
root@ubuntu:/lib/modules/3.4.29+#sudo apt-get install u-boot-tools libncurses5 libsysfs-dev |
Now we need to configure the kernel:
1
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi#make menuconfig O=../build |
The menu looks like the following:
We first enter into ‘General setup —>’ by moving the cursor to that line and press ‘ENTER’:
As shown on the above figure, we locate the line “Initial RAM filesystem and RAM disk (initramfas/initrd) support, and press ‘ENTER’ to remove the asterisk ‘*’.
Return to the previous interface by navigate to ‘Exit’, and then locate the line begins with ‘Device Drivers’:
Press ‘ENTER’ , and locate the line ‘Staging drivers”, and press ‘SPACE’ to enable it:
Press ‘ENTER’, and a new interface shows up:
Press ‘M’ on ‘USB/IP support (EXPERIMENTAL)’, [M] on ‘VHCI hcd’, and [M] on ‘Host driver’:
Press ‘Exit’ to exit, and save the new configuration:
Change into the ‘build’ directory, and build the kernel:
1
|
root@ubuntu:/lib/modules/3.4.29+/build#make |
The above process will take about 4 hours. Please wait patiently.
1
2
3
|
root@ubuntu:/lib/modules/3.4.29+/build#make modules root@ubuntu:/lib/modules/3.4.29+/build#make modules_install root@ubuntu:/lib/modules/3.4.29+/build#make uImage |
As we are build the kernel on SD card, we need to mount ‘/dev/mmcblk0p2′. Otherwise, if we boot from NAND, we use /dev/nanda’ instead.
1
2
3
|
root@ubuntu:/lib/modules/3.4.29+/build#mount /dev/mmcblk0p2 /boot root@ubuntu:/lib/modules/3.4.29+/build#cp arch/arm/boot/uImage /boot -f root@ubuntu:/lib/modules/3.4.29+/build#reboot |
Next, we manually load the USBIP driver.
1
2
3
4
|
root@ubuntu:/lib/modules/3.4.29+/build#modprobe usbip-core root@ubuntu:/lib/modules/3.4.29+/build#modprobe usbip-host root@ubuntu:/lib/modules/3.4.29+/build#modprobe vhci-hcd root@ubuntu:/lib/modules/3.4.29+/build#nano /etc/modules |
We add the following content to file ‘modules’:
1
2
3
|
usbip-core usbip-host vhci-hcd |
Next, we are going to configure and compile USBIP. We will need source files of kernel to configure and compile USBIP.
We navigate to the working directory:
1
2
3
4
5
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace# ls AUTHORS Makefile README autom4te.cache config.h config.status configure.ac install-sh ltmain.sh stamp-h1 COPYING Makefile.am aclocal.m4 cleanup.sh config.h.in config.sub depcomp libsrc missing INSTALL Makefile.in autogen.sh config.guess config.log configure doc libtool src root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace# |
Run ‘autogen.sh’ first:
1
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace# ./autogen.sh |
This will generate a file named ‘configure’:
1
2
3
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace#./configure root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace#make root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace#make install |
After the installation, we need to install the dependency package:
1
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace#sudo apt-get install hwdata |
Now we can start the usbip process:
1
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace#sudo usbipd -D |
Next, we can check the USB devices attached on pcDuino:
01
02
03
04
05
06
07
08
09
10
11
12
13
14
|
Local USB devices ================= - busid 2-1 (1bcf:05ca) 2-1:1.0 -> usbhid 2-1:1.1 -> usbhid - busid 3-1 (1a40:0101) 3-1:1.0 -> hub - busid 3-1.1 (1058:0740) 3-1.1:1.0 -> usb-storage - busid 3-1.3 (148f:5370) 3-1.3:1.0 -> unknown |
On pcDuino, we have a WD USB drive attached to pcDuino’s USB host.
We are ready to bind the WD USB drive. The command is as following:
1
2
|
root@ubuntu:/lib/modules/3.4.29+/linux-sunxi/drivers/staging/usbip/userspace# sudo usbip bind -b 3-1.1 bind device on busid 3-1.1: complete |
In the above command ‘3-1.1′ is the USB device ID found in ‘usbip list -l’.
Until now, we are done with the part on pcDuino. Next, we move to work on a Windows PC that need to accepts the USB drive that is attached on pcDuino.
The USBIP driver for Windows can be downloaded from usbip. The downloaded usbip can be unzipped to C:.
Point the driver path to the usbip directory.
We can see that the driver is installed correctly:
Download USBIPexe, and unzip to c:usbip as we did with the driver.
1
|
C:usbipusbip -l 192.168.1.15 |
where 192.168.1.15 is the IP address of pcDuino.
Run
1
|
C:usbip>usbip -a 192.168.1.15 3-1.1 |
where 3-1.1 is the USB ID on pcDuino.
After this command is executed, we will see ‘New USB device found’ on Windows PC.
We will see the Windows PC treats the WD USB drive as if it was attached to itself:
Leave a Reply
You must be logged in to post a comment.