A cohesive article on how to share ** multiple ** USB devices over a network using USB / IP (universal serial bus extension over IP network) ** for free ** (without paying license fees) I didn't have it, so I wrote it.
However, it is a personal memo, so I would appreciate it if you could see it for reference.
Connect a device such as a USB memory to the Raspberry Pi and exchange the information with other PCs via a wired LAN.
Similar methods include ** VirtualHere ** and IO-DATA ** net.USB **. ** Virtual Here ** can be used simultaneously up to 1 device in the free version. To connect to the network additionally, you cannot bind multiple devices without paying a license fee of nearly $ 50 per device. It's very easy to set up, so if you only have one device to share, this is fine. ** net.USB ** is a product for network sharing, so it naturally costs money to install and is not compatible with linux.
So, this time, I tried with ** free and open technology that doesn't cost money **.
server | Raspberry Pi 3 Model B, Raspbian GUN/Linux 10 client | Ubuntu 18.04.05 LTS Communication is performed via a router and a wired LAN.
The result of a project to share USB devices over IP networks. It was developed by NAIST around 2007 and was merged into the kernel in Linux 2.6.38.
The USB / IP project aims to develop a general purpose USB device sharing system over IP networks. To share USB devices between computers, USB / IP encapsulates "USB I / O messages" in TCP / IP payloads and communicates between computers. ArchWiki
Please read the reference URL for details.
To connect the device, bind with server (raspi) and then attach with client (ubuntu). To remove it, detach it on the client and then unbind it on the server.
It may not be accurate because it is my image. ** bind ** | To be able to share on the server side. When viewed from the server, binding makes the device appear to be disconnected. ** attach ** | Mount a device that is in a sharable state (bind) on the client side. ** detach ** | To unmount the attached device. For the device to be detached, check the port and specify the port (the method will be described later).
You only need to run it the first time.
Settings that should be done with Raspberry Pi. The setting on the raspberry pi side is fixed IP,
$ sudo apt install usbip
It's pretty easy to do by hitting or googled, so omit it. I plan to add it soon.
Settings to be done on ubuntu. For USB / IP, it is necessary to open port 3240 in advance. Open the port using ufw.
$ sudo ufw allow 3240/tcp
$ sudo ufw enable
$ sudo ufw reload
USP / IP is in a package called linux-tools-generic, so install it using apt.
$ sudo apt install hwdata linux-tools-generic
The commands that need to be executed on the raspberry pi side are shown below. This time, the ip of raspberry pi used in the experiment is fixed at 192.168.0.161. bind Allow sharing on the server side. When viewed from the server, binding makes the device appear to be disconnected.
$ ​sudo modprobe usbip_host
$ usbip list -l
// Check the kernel module load and the busy (= ?????) of the device you want to bind
$ sudo usbip bind -b ?????(ex.1-1.2)
$ sudo usbipd -D
// Specify the bus id and bind, and start the daemon. unbind Detach (described later) on the client and then unbind.
$ sudo usbip unbind -b ?????(ex.1-1.2)
The commands that need to be executed on the ubuntu (main PC) side are shown below. attach Mount the device that is in a sharable state (bind) on the client side.
$ sudo modprobe vhci-hcd
$ /usr/lib/linux-tools/$(uname -r)/usbip list -r 192.168.0.161(This IP is from Raspberry Pi)
// Check the loading of the kernel module and the busy (= ?????) of the device you want to bind. // You can enter $ (uname -r) in path with tab completion.
$ sudo /usr/lib/linux-tools/$(uname -r)/usbip attach -r 192.168.0.161 -b ?????(ex.1-1.2)
detach Unmount the attached device. For the device to be detached, check the port and specify the port.
$ /usr/lib/linux-tools/$(uname -r)/usbip port
// Find out the port (= ??) of the device you want to detach
$ sudo /usr/lib/linux-tools/$(uname -r)/usbip detach -p ??(ex.00)
// Specify port and perform detach.
The approximate usage is like this. By the way, the part up to / usr / lib .... / usbip may be easier to use if you devise a symbolic link.
Recommended Posts