Access a directly-attached USB device (UltraLite-mk5) on a Raspberry Pi 4 from another networked device

ipnetwork-adapternetworkingusb

I run Ubuntu 21.04 server (GNU/Linux 5.11.0-1016-raspi aarch64) on a Raspberry Pi 4 which is connected to my LAN through its ethernet port.

I have a MOTU UltraLite-mk5 soundcard attached directly by USB to the Raspberry Pi 4 so that the UltraLite-mk5 outputs sound streamed to the Raspberry Pi 4. I would like to be able to simultaneously access the UltraLite-mk5 over the network from my Mac in order to configure the UltraLite-mk5.

Is there a way I can configure the Raspberry Pi 4 to allow the UltraLite-mk5 to be addressed using a unique IP address which can be reached from the LAN?

Background

If the UltraLite-mk5 is directly connected by USB to my Mac, I can direct sound to the UltraLite-mk5 and simultaneously access the UltraLite-mk5 using control software provided my MOTU (CueMix5). When my Mac is connected to the UltraLite-mk5 directly, it sees the UltraLite-mk5 though the USB connection as a multi-function device:

  1. firstly as a sound card device, and…
  2. secondly as a network device through the Mac's network device en11.

So when directly connected, the UltraLite-mk5 is listed in the Mac's System Preferences | Network tab as connected with an Automatic Private IP address of 169.254.152.243. I've also noted that the CueMix5 app can connect to a UltraLite-mk5 over the network if given the UltraLite-mk5's IP address, but I've not tested that since I don't know how to connect the UltraLite-mk5 directly to the network by USB … hence the question!

Potential answer outline

So I'm guessing the steps (none of which I fully understand!) will involve the following. I'm looking for help to firstly confirm that this sounds like the right approach, and then also help with what the right CLI commands are needed. So the plan involves:

  1. getting a second LAN IP address on the Raspberry Pi 4's NIC (so the CM5 software can address that IP address from another networked machine). I know an NIC can have more than one IP address. I'd like to set up a second address, ideally acquired from the network's DHCP server (not sure if this is really necessary to avoid an address clash on the LAN), but the key thing is that this second IP address needs to work with the rest of the setup, in particular, step (3). For that reason, does this second LAN IP address need to be static? And what CLI instruction do I need to set it up?

  2. configuring a USB network service on the Raspberry Pi 4 to the UltraLite-mk5 so both Raspberry Pi 4 and UltraLite-mk5 can talk to each other. I can see that the MOTU software installation on my Mac for the UL5 creates a USB network service (called UltraLite-mk5) and if I knew the relevant CLI instructions for Mac I could examine what has been set up so I could reproduce it on the Raspberry Pi 4. But I don't know yet how to do this. Can you help me with this?

  3. mapping/routing/virtual switching (on the Raspberry Pi 4) that second IP address set up in (1) to the Raspberry Pi 4's USB network connection to the UltraLite-mk5, so that network traffic addressed to the UltraLite-mk5's network IP is forwarded directly by the Raspberry Pi 4 via the USB network service to the UltraLite-mk5, and vice versa. Sounds simple enough! And if you know what the CLI instructions are, I guess it is. Help!

No doubt you can tell from my description that I don't have a deep understanding of networking, and I've only recently started to get to grips with the CLI of Ubuntu, so please pitch your replies at that level. Many thanks for reading.

Best Answer

Have a look at usbip. It will forward the USB protocol over IP.

So you can install the server part on your RaspPi, and access it through whatever networking the RaspPi is connected to, under the IP address(es) of the RaspPi. It will not get it's own address (unless configure this somehow on the RaspPi, and give the RaspPi a dedicated IP address for it), but a specific IP address shouldn't be necessary, so you can probably skip all the networking steps.

It will also complete forward the USB device, which means you won't be able to use the device locally from the RaspPi.

The downside is that usbip clients currently exist only for Windows and Linux. So to access it from the Mac, you either can run Windows or Linux in a VM on the Mac, or you need to understand the Mac USB framework, and adapt USB (which is open source) to work with it.


If all you are interested is forwarding the sound, you could also use a Pulseaudio module on the RaspPi which can stream over a standard protocol (e.g. ROAP/Apple Airtunes), and then access this from the Mac.

This should work out of the box, but doesn't forward the USB device directly.


Note that with either solution (and all potential other solutions) you'll add latency.


(Please update your question with the information you put in the comments about a network interface appearing and working on the RaspPi).

To allow access of the network interface of the USB device from the outside, you need to set up ordinary routing (all operations need root):

  1. Both your RaspPi and your MAC probably got a DHCP-assigned private-range IPv4 address on your LAN. Find some subnet that doesn't overlap with your LAN subnet. For example, if your LAN subnet is 10.23.5.*/24 (the /24 means the first 16 bits count, there are 256 addresses in this subnet), use e.g. 10.23.6.*/24.

  2. Assign an IP address from this subnet to the USB network interface:

    ip addr add 10.26.6.1/24 dev enx0001f2fff397

  3. Enable forwarding on your RaspPi

    echo "1" > /proc/sys/net/ipv4/ip_forward

  4. On your Mac, add a route to this address via the RaspPi address. Let's assume your Mac got 10.26.5.12 and your RaspPi got 10.26.5.23, then you do

    route -n add -net 10.23.6.0/24 10.26.5.23

  5. You should now be able to ping the USB interface from your Mac (ping 10.23.6.1).

  6. You cannot use the link-local FE80::... IPv6 address for anything like this.

  7. There are various ways to automate all this, but for now, try to get it working manually.

  8. I have no idea how a network interface like this would actually work to control the sound card. The manual doesn't mention any details. I would expect a second network address behind the one assigned to the network interface, or some point-to-point interface. So while the above will allow access to a network interface, it may or may not work for whatever funny things they are doing on that soundcard.

If this was my hardware, the first thing I'd do is to run Wireshark on my Mac to see what is actually going on there.

Related Question