Written by Tyler

My main computer is on its own deticated desk. This is great as it creates an issolated space for when its just 'work' time, however it can be frustrating when I'm trying to experiment with embedded boards and trying to program them from my computer. Of course I could just invest in a really long USB cable, but then there wouldn't be any fun in that, therefore I setup a tool I found, usbip.

Usbip is a tool for linux, mac and (jankily) windows. The primary use is to allow for the USB protocol to be used over a network, and allow of machines to share a single USB device. This could be great for a Raspberry Pi with a camera and an at home recording studio, or for having a workshop seperate from your good computer. Because of just how useful I've found this over the past few months, I'm going to show you exactly how to do this for yourself.

Set up using two linux machines

So first things first, you need to install usbip on both machines. Do this with whatever package manager your distro(s) use.

After this you need to load the kernel module for usbip on the host machine (this is the machine which the physical USB device will be connected to). To do this, run 'sudo modprobe usbip_host'. This will load the kernel module. To make it so that you only have to do this once, we can set up the module to be loaded on boot. To do this, edit the shown file.

#file /etc/modules usbip_host

One you've added that to the file, we can start setting up the usb device to be shared. To do this, run 'lsusb' and find the device you want to share. We are looking specifically for the value after 'ID'. Now, run 'usbip list -p -l', and you will see a list of devices that can be shared. Find the device that matches the ID from lsusb. Now we need the busid for that device. Its probably of format '1-X.X.X' or something like that. The number of 'X's can be different, and I believe it has to do if the device is on a hub.

So now that we have the busid, we can bind that device to usbip, so that remote clients can use it. To do this, run 'sudo usbip bind --busid=<BUSID>', where <BUSID> is replace with the busid you found earlier. Now all we have to do is run 'sudo usbipd', and the machine is now listening for clients! Now lets set up the client.

So on the client we also want to have usbip installed as well of course. No we must load a kernel module here too, 'vhci-hcd'. This can be loaded the same way as above, by running the command 'sudo modprobe vhci-hcd'. Feel free to add that name to the same file as we added 'usbip_host' above.

Now we can add our client to the server with a single command and get access to our USB device. We do this by running 'sudo usbip attach -r <SERVER_IP> -b <BUSID>'. Be sure to replace all of the apropriate fields with their appropriate values. After this it should all be working, and you should have full access to the remote USB device!

Note for kernel options

On some systems, especially those were you configured your own kernel, it may be necessary to add support into your kernel for USB over IP if you didn't add it before. To do this, enable the shown options.

#Enable these options in your kernel CONFIG_USBIP_CORE CONFIG_USBIP_VHCI_HCD CONFIG_USBIP_HOST #Set these to your use case CONFIG_USBIP_VHCI_HC_PORTS #default is 8 ports CONFIG_USBIP_VHCI_NR_HCS #default is 1 port

All of these are in Device drivers -> UBS Support. Be sure to recompile your kernel and you should be able to use usbip.

Thats all I have on usbip, hope this helped you set it up!