USB over IP (network)

Hyper-v does not provide USB passthrough, some people use USB redirection from remote desktop RDP… A similar technology might be USB over network, but this does not always work, as many USB devices have very little tolerance for lag ! and this will introduce some lag !

My objective is to connect a MINI-VCI connected on a raspberry PI to a computer running other software to analyze the data, whether this works or not is yet to be seen.

There seems to be a few solutions online, some using generic hardware, and some using specialty hardware

The most diverse of those solutions that can work on everything from a raspberry pi to a windows computer and android phone is (https://www.virtualhere.com/), but I have not yet verified whether this software is USB/IP compatible or not

USB/IP has been built into the linux kernel for some time now, and a couple of solutions for both server and client are available on github, So here I will be investigating what I can do to bridge the Linux Raspberry PI to my windows PC,

USBIP is a protocol where the server is the machine connected to the USB device via wire, and the client is the machine that needs to use the USB device but is not connected to it via USB.

In linux, usbipd is the name of the server, and usbip being the client, In debian, both server and client are included in the usbip package, hence, on the raspberry PI and on the Linux server, we need to run the command

apt install usbip usbutils

The modules of USB/IP (usbip-core, usb-host, and vhci-hcd) are already included,

We will get to the Windows client after the Linux to Linux section

The two options

In the cases we are exploring here, the server is a Raspberry Pi (3), the client is a Windows machine, but there are a couple of things to try first, the Windows clients are KVM virtual machines, we will try

1- The client is the Linux Host machine hosting the windows virtual machines, and the USB port is passed to the virtual machine

OR

2- The Windows client has the USBIP driver directly connecting to the Raspberry PI server

The Steps

On Raspberry PI

Installing the USB/IP server on the raspberry pi “apt-get install usbip”

apt install usbip usbutils

Now, let us assume i want to connect the following device to my debian machine so that i can leave it on a different desk

lsusb
Bus 001 Device 005: ID 10c4:ea60 Silicon Labs CP210x UART Bridge

Let us start by loading the requiered kernel modules

sudo modprobe usbip-core
sudo modprobe usbip-host
echo -e "usbip-core\nusbip-host" | sudo tee -a /etc/modules

Now, we need to start the usbip deamon

sudo usbipd -D

Now, we need to list the devices all over again ! but through usbip

usbip list -l
busid 1-1.5 (10c4:ea60)
Silicon Labs : CP210x UART Bridge (10c4:ea60)

The above is the relevant one, I chose to delete the other 3 (They come with every pi)

Notice how we already have the data from the lsusb command `Bus 001 Device 005: ID 10c4:ea60 Silicon Labs CP210x UART Bridge`, but i have added this one too for completeness, and because the ids are easier to see

Binding the Device: the device needs to be off limits to the pi itself, and proxiedthrough usbip, so we bind it with

sudo usbip bind -b 1-1.5

Notice how i copied the 1-1.5 from the usbip command

We should also probably make it persistent by creating the file

sudo nano /lib/systemd/system/usbipd.service
--------
[Unit]
Description=usbip host daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/usbipd -D

[Install]
WantedBy=multi-user.target

Start and enable !

sudo systemctl daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service

Now, you may be asking, how do we “Authenticate”, and the act of the matter is, we don’t, this is an unsecured thing, and if you want security, UFW is probably your friend

On my Debian machine !

Let us connect this to my Debian machine

First, the same package has the tools for both the server (PI) and the client (My PC)

sudo apt install -y usbip

Now, we need tools to create virtual USB devices, fake device driver so to speak

sudo modprobe vhci-hcd
echo "vhci-hcd" | sudo tee -a /etc/modules

Now, list remote devices

usbip list -r 192.168.5.220
- 192.168.5.220
1-1.5: Silicon Labs : CP210x UART Bridge (10c4:ea60)
: /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5
: (Defined at Interface level) (00/00/00)

Now, all you need to do is attach the device

sudo usbip attach -r 192.168.5.220 -b 1-1.5

Now, to verify the connection

usbip port
Imported USB devices
====================
Port 00: <Port in Use> at Full Speed(12Mbps)
Silicon Labs : CP210x UART Bridge (10c4:ea60)
3-1 -> usbip://192.168.5.220:3240/1-1.5
-> remote bus/dev 001/005

Now, we are done with debian, but the truth of the matter is, we probably need this more for virtual windows machines ! in my case, the printer and scanner are the 2 things i need on windows, because of linux drivers problems !

Now, to disconnect the above

sudo usbip detach -p 00

Windows

So let us dive into windows

Install usbip-win2 (Get it here)

Now use the GUI, that is what it is for

If you insist on not doing that….


usbip.exe list -r 192.168.5.220
usbip.exe attach -r 192.168.7.220 -b 3-2
# And to disconnect
usbip.exe detach -p 1