Add usbip

This commit is contained in:
Tyler Perkins 2022-12-26 20:22:05 -05:00
parent d7dda9b026
commit fa90af7e63

86
USBIP.html Normal file
View File

@ -0,0 +1,86 @@
<div class="row no-gutters">
<div class="col-sm-12">
<p>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.</p>
<p>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.</p>
</div>
</div>
<div class="row no-gutters">
<div class="col-sm-12">
<h4>Set up using two linux machines</h4>
<p>So first things first, you need to install usbip on both machines. Do this
with whatever package manager your distro(s) use.</p>
<p>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.</p>
<blockquote class="code-block">#file /etc/modules
usbip_host
</blockquote>
<p>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.</p>
<p>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=&lt;BUSID&gt;', where &lt;BUSID&gt; 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.</p>
<p>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.</p>
<p>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
&lt;SERVER_IP&gt; -b &lt;BUSID&gt;'. 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!</p>
<h4>Note for kernel options</h4>
<p>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.</p>
<blockquote class="code-block">#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
</blockquote>
<p>All of these are in Device drivers -&gt; UBS Support. Be sure to recompile
your kernel and you should be able to use usbip.</p>
<p>Thats all I have on usbip, hope this helped you set it up!</p>
</div>
</div>