Categories
Raspberry Pi

USB over IP, extend the network, Wifi – to use Arduino over Raspberry Pi as gateway

USB over IP – First contact point:

Actions on the server side – Raspberry Pi

USB over IP is to be available on the Raspberry Pi from kernel Linux 3.17 without further installation.

Check what kernel I have:

17:45:46|pi@raspberrypi:~|$ uname -r
4.1.13+

Kernel version is higher :-)
Test:

17:49:05|pi@raspberrypi:~|$ usbip
-bash: usbip: Command not found.

That’s not much good. :-(

Continue with the tips from the forum: https://www.raspberrypi.org/forums/viewtopic.php?p=121691

install usbip

17:49:25|pi@raspberrypi:~|$ sudo apt-get install usbip

loading the Kernel module

17:54:16|pi@raspberrypi:~|$ sudo modprobe usbip-host

Starting the usbip daemon

08:52:50|pi@raspberrypi:~|$ sudo usbipd -D

listing USB devices (without Arduino)

18:01:48|pi@raspberrypi:~|$ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.

and listing USB devices (with Arduino plugged in)

18:02:30|pi@raspberrypi:~|$ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 005: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

In my case is the ID of the USB device: 1a86:7523
The same again with the program usbip

18:05:21|pi@raspberrypi:~|$ sudo usbip list -l
Local USB devices
=================
 - busid 1-1 (0424:9512)
         1-1:1.0 -> hub
 
 - busid 1-1.1 (0424:ec00)
         1-1.1:1.0 -> smsc95xx
 
 - busid 1-1.2 (1a86:7523)
         1-1.2:1.0 -> ch341

Binding of the USB device

09:22:48|pi@raspberrypi:~/deb_pakete|$ sudo usbip bind -b 1-1.2
bind device on busid 1-1.2: complete

Actions on the client side – in my case a laptop with Ubuntu

Install usbip

Take a look at: https://wiki.ubuntuusers.de/USBIP/

sudo apt-get install linux-tools-generic

loading Kernel module

10:06:22|henry@t410:~/deb_pakete|$ sudo modprobe vhci-hcd
10:08:30|henry@t410:~/deb_pakete|$ lsmod | grep vhci
vhci_hcd               33435  0 
usbip_core             27617  1 vhci_hcd

Listing the USB devices that are provided on the PI

10:11:10|henry@t410:~/deb_pakete|$ sudo usbip list -r 192.xxx.xxx.xxx
Exportable USB devices
======================
 - 192.xxx.xxx.xxx
      1-1.2: QinHeng Electronics : HL-340 USB-Serial adapter (1a86:7523)
           : /sys/devices/platform/bcm2708_usb/usb1/1-1/1-1.2
           : Vendor Specific Class / unknown subclass / unknown protocol (ff/00/00)
           :  0 - Vendor Specific Class / unknown subclass / unknown protocol (ff/01/02)

adding the USB Device

10:24:20|henry@t410:~/deb_pakete|$ sudo usbip attach -h 192.xxx.xxx.xxx -b 1-1.2
10:24:45|henry@t410:~/deb_pakete|$ lsusb
Bus 003 Device 002: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

Check with the Arduino IDE

USB over IP Arduiono Remote programmiert über IP

Actions on the server side – Raspberry Pi

After using on the server side – releasing the USB device

09:22:54|pi@raspberrypi:~/deb_pakete|$ sudo usbip unbind -b 1-1.2
unbind device on busid 1-1.2: complete