I've done this before for Arduino development, however, the setup had some limitations. It only worked with serial devices (using ser2net), the Arduino IDE couldn't be configured to use the export serial port (is supported by AVRDude).
This time I will run through the setup that should allow almost any USB device to be used. In my case I export a USBTiny ISP and a BusPirate. On the client the devices show up as if they are plugged in locally, no special configuration required for avrdude etc.
This setup requires GNU/Linux (examples are for Debian/Ubuntu distributions).
Files
usbip-client-tools.conf
Ensures that the kernel module is loaded. On Debian systems, this should be copied to /etc/modules-load.d/
One of the downsides I've come accross is the bus pirates USB connection can be flaky at times, this manifests itself with a Kernel deadlock on the client system (whole machine freezes) I've not managed to obtain any debug information as the only way to resolve the situation is with a hard reboot.
The USB Tiny does not suffer the same issue. The work around is to simply access the Bus Pirate serial port over SSH or using the previous serial2tcp tool for the bus pirate and leaving this work around for the USBTiny.
This guide goes through the setup of both client and server. It was written with a Debian/Ubuntu GNU/Linux system in mind, however, all of the tools are common to all Linux distributions, instructions can easily be adapted (instructions will happily be accepted and added for other distributions).
This solution uses USBIP to export the USB device and some UDEV rules to automate the exporting when a device is plugged in.
Security
A note on the security of this solution. usbipd does not include any security mechanisms, similar to other UNIX protocols (eg NFS). To make this solution secure some suggestions would be:
Configure your firewall rules to only allow access from white listed IPs
Configure usbipd to listen on localhost only and tunnel over SSH
2
Step 2
Server Setup
Note: Before continuing ensure you do not have the Debian usbip package installed. This package is out of date and the project has since been merged into the kernel proper.
Install the USBIP kernel module and tools:
# Install the Linux tools package
$ sudo apt install linux-tools-generic
# Ensure the kernel module is inserted
$ sudo modprobe usbip_host
To ensure the module is loaded on restart add the following to the file /etc/modules-load.d/usbip-server-tools.conf
# USBIP Host module loaded
usbip_host
Finally start the usbip daemon to export the devices:
# Start USB IP as a daemon (-P will create a PID file /var/run/usbipd.pid)
$ sudo usbipd -D -P
Add UDEV rules to automatically export devices when they are plugged in, add the following to the file /etc/udev/rules.d/91-usbip-server-tools.rules
# Auto bind any FTDI device (well any product that includes an FTDI interface).
SUBSYSTEM=="usb" ATTRS{idVendor}=="0403" ATTRS{idProduct}=="6001" RUN+="/usr/bin/usbip bind -b $kernel"
# Auto bind a USBTiny ISP
SUBSYSTEM=="usb" ATTRS{idVendor}=="1781" ATTRS{idProduct}=="0c9f" RUN+="/usr/bin/usbip bind -b $kernel"
3
Step 3
Client Setup
Install the USBIP kernel module and tools:
# Install the Linux tools package
$ sudo apt install linux-tools-generic
# Ensure the kernel module is inserted
$ sudo modprobe vhci-hcd
To ensure the module is loaded on restart add the following to the file /etc/modules-load.d/usbip-client-tools.conf