2013년 10월 15일 화요일

Sharing USB devices between Beaglebone board and Windows machine over TCP/IP network

This tutorial will be dedicated to setting up a sharing a USB device from Beaglebone board to Windows 7 SP1 32-bit machine. Before we get started we need to meet few initial requirements.
a)     Have a beaglebone board for acting as a server
b)     Have a Windows machine for acting as a Client

Installation

Server:
1.     Installing Ubuntu on the Beaglebone
First of all, need to install Ubuntu on Beaglebone board. For doing this, we need to flash ubuntu on sdcard.  You could take a look at following sites for doing it.
In my case, I used ubuntu-13-04-console-armhf-2013-09-26.tar.z version.
The flashing process will take some minutes. When the image has been flashed to the micro SD-card, insert it into the board. Hold down the “Boot” button, which is located directly over the micro SD-card, and power the board by either connecting it to the PC using an USB cable or by connecting a 5V power adapter. After about two or three minutes the boot process should have been finished, so you could try your Ubuntu OS on the beaglebone. You should remember that the login name is ubuntu and password is temppwd.
2.     Connection to ubuntu on the Beaglbone
You could use ssh access for connecting with the system. On the host linux machine, you could input ssh “ip address” –l ubuntu on the terminal. In another hand, we could use putty for connection to beaglebone. But problem here is ip address. The beaglebone has not yet any ip address . Therefore we could use its usb connection ip address “192.168.7.2” for first connection.
Thus you could input like ssh 192.168.7.2 –l ubuntu on the terminal of host linux machine or could use putty like following.









Login as : Ubuntu
Password: temppwd

  






3.     Configuring Network connection
After connect to the system, we should make network configuration on the system. It means we need to enable Ethernet connection of Beaglebone.
1.     Plug Ethernet cable into the Beaglebone
2.     Make network configuration on the /etc/network/interfaces

3.     #sudo  /etc/init.d/networking restart   or service networking restart
If you complete doing this configuration, you could access through your ip address to the beaglebone. Also could connect to the Internet. It will be enable you install usbip on the board.

4.     Installing USBIP
We should install usbip using source file. Do not use apt-get install usbip!!! If we install usbip through this way, it will install old version of usbip that does not match with some drivers of latest kernel. You will meet following error if your usbip version is usbip-0.1.7 on ubuntu 13.04 or ubuntu 12.04 when you execute usbipd command.
usbipd: symbol lookup error: usbipd: undefined symbol: stub_driver.
Therefore we need to install usbip using source file. For doing this, we could follow the following steps.
1. Install usbip pre-required packages.
            - sysfsutils
- libwrap0-dev
- gcc
- libglib2.0-dev
- libtool,
           - automake
           - autoconf
- pkg-config
          - libsysfs-dev
            -  ncurses-dev
 2. Download kernel source and install usbip using it
      a) # sudo apt-get install linux-source. After this step, you could see linux-source-             3.8.0.tar.bz2 file in this /usr/src/linux-source-3.8.0/ directory

      b) # sudo tar -xjvf /usr/src/linux-source-3.8.0/linux-source-3.8.0.tar.bz2
         After step “b”, you could find usbip-source file in the following directory
           /usr/src/linux-source-3.2.0/drivers/staging/usbip/userspace/
c)     # cd /usr/src/linux-source-3.8.0/drivers/staging/usbip/userspace

d)     Start to install usbip using this source.
1.     # sudo ./autogen.sh
2.     Make configuration for matching version with usbip on the windows(client).
# sudo sed -i 's%USBIP_VERSION 0x00000111%USBIP_VERSION 0x00000106%g'  configure


(Also you could find all files that have information about USBIP_VERSION 0x00000111 using  find . -exec grep -l "찾는문자열" {} \; 2>/dev/null command. Then could change 0x00000111 into 0x00000106.)

Version of usbip on the windows is 1.0.6 and version of usbip that we will install is 1.1.1.  If we do not make configuration on the server side ,these 2 versions of usbip could not work together. You could take a look at following sites to understand about it.
3.     # sudo ./configure --prefix=/usr --sysconfdir=/etc
4.     # sudo make install
After completing installation, you could check usbip version using usbip version command.  It should be like following




To use usbip on the server side
1.  # sudo modprobe  usbip-core usbip-host vhci-hcd
2.  # lsmod | grep usbip
3.     # sudo usbipd –d
4.     # sudo usbip list –l
5.     # sudo usbip bind –b 1-1

Client (on the windows machine)
Now it is time to install usbip on the client machine.
First download usbip_windows_v0.2.0.0_signed.zip file from http://usbip.sourceforge.net/, then extract it.

For windows 7
1. (Only necessary for custom builds: For x64 allow unsigned drivers: Enter "bcdedit /set testsigning on" in an administrative cmd window)
2. Uncompress the downloaded binary package to a directory.
3. Start a the Device Manager
4. Click Any hardware node
5. Choose "Add Legacy Hardware" from the "Action" menu
6. At the 'Welcome to the Add Hardware Wizard', click 'Next'.
7. Select 'Install the hardware that I manually select from the list'
8. click 'Next'
9. Click 'Have Disk', click 'Browse', choose the uncompressed directory, and click OK.
10. Click on the 'USB/IP Enumerator', and then click Next.
11. At 'The wizard is ready to install your hardware', click Next.
12. Click Finish at 'Completing the Add/Remove Hardware Wizard.'


If you installed daemon tools before, You should uninstall the daemon tools software and test usbipWhen xp(or win7) pc have been installed daemon tools, port problem must appear, such as vbus problem, no free port problem.  

To use it:

1. open a command prompt window, cd to the uncompressed directory.

2. run usbip -l 192.168.2.1 to list the exported devices from ip 192.168.2.1

3. run usbip -a 192.168.2.1 2-1 to imported the device.

(Of course, you should change 192.168.2.1 and 2-1 to something else)



Sample screens of successful sharing experiment

Server side (on the beaglebone)
   1. 


2.







 

 Client side (on the windows)