How to directly connect ModDuo & ModDwarf via USB to OpenWrt router

Here is a long guide on how I got my ModDuo (and also connected my ModDwarf in later comments) directly connected via USB cable to my OpenWrt router’s USB port with its USB ethernet bridged to the rest of my home LAN network with custom static ip. Make sure you know what your are doing. At the end of it, I’m able to access my mod from its new static ip address from any computer in my LAN, and my mod can access and is accessible to the outside internet.

Step zero is make sure you don’t have anything important to do with your router or ModDuo because you can easily risk bricking them. So make sure you know how to do a factory reset on both incase you misconfigure some interface and loose the ability to ssh. At this point install OpenWrt on your router if it isn’t already installed. Also I would recommend upgrading to the latest version of OpenWrt and upgrading all existing installed packages.

1. Install appropriate USB Ethernet driver in OpenWrt

Unfortunately, the initial configuration of OpenWrt does not automatically detect the ModDuo as a USB device. It doesn’t even have the ability to lsusb so show plugged in usb devices. So first need to install “usbutils” package. Packages can be installed by logging into your router’s LuCI web interface and mousing over “System” and clicking “Software” or by ssh’ing into it…see OpenWrt’s docs on how to install packages, but the command to install usbutils for me was:

opkg install usbutils

Now when I type lsusb -t without the ModDuo plugged in, I see a list of the usb hubs in my Netgear WNDR3800 router

root@OpenWrt:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M

At this point, plug in your ModDuo via USB into your OpenWrt router’s usb port. I ran lsusb -t again to see what changes in that list so I know how the ModDuo is identified:

root@OpenWrt:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M
    |__ Port 1: Dev 3, If 0, Class=Communications, Driver=, 480M
    |__ Port 1: Dev 3, If 1, Class=CDC Data, Driver=, 480M

The ModDuo presents those last two usb devices when plugged in. It turns out that second one of those (of Class “CDC Data”) is the ModDuo’s USB ethernet device.

Unfortunately typing ip addr didn’t reveal any existing USB ethernet interface. That is because there wasn’t an appropriate usb driver installed. First I installed kmod-usb-core “Kernel support for USB” and 'kmod-usb2" but that still didn’t work. After a bit of searching the packages and trying several (kmod-usb-ehci kmod-usb-net kmod-usb-ohci kmod-usb-uhci) I installed kmod-usb-net-cdc-ether “Kernel support for USB CDC Ethernet devices”, which seems to be the essential driver, because then when I typed ip addr a new interface appeared called usb0, which was the ModDuo. The short command to install that is:

opkg install kmod-usb-net-cdc-ether

2. Configure a bridged interface in OpenWrt connecting the ModDuo’s USB to the rest of your LAN

My starting point in OpenWrt was I already had created a bridged interface called “br-lan” which connected my router’s wireless interfaces with its wired ethernet interface. (I can’t recommend on the exact way to setup your bridged interface, so the exact setup will be different depending on your lan). So if you don’t have a bridged interface in OpenWrt then create one (or if you already have a bridged interface that connects your wireless to ethernet, edit it) in LuCI by mousing over the “Network” tab and clicking “Interfaces”, and either clicking “Add new interface” (or clicking edit on your existing bridged interface). For me, I set my OpenWrt with a static ip address 192.168.1.9 because my ISP router uses the 192.168.1.xxx subnet, and put my ISP’s router’s local ip address 192.168.1.254 as the gateway, so my general settings tab looks like:

In the “Physical Settings” tab I have the “Bridge interfaces” box checked, and added my ModDuo’s USB device (which for me appears as usb0) to it by clicking “Interface” drop-down menu and checking the box next to usb0 (along with the regular wired ethernet and wireless interfaces I wanted to bridge). The exact setup of the bridge might differ based on how your router is setup, but for me I set it up like:

3. Change ModDuo’s static ip to be in the same subnet

At this point they are all one interface that is virtually bridged together, but the ModDuo’s factory setting for its static ip address of 192.168.51.1 was not reachable because it it outside my 192.168.1.xxx subnet. I suppose it could be possible to setup dhcp on the mod so that it gets automatically assigned an ip address by whatever dhcp server you use, though I didn’t want to bother doing that as I prefer static ip addresses anyway so I can remember their address.

Before changing it, first make sure your dhcp server only uses a subset of ip addresses in the local net, so that there is a range of static ip’s available to pick from to give your Mod a permanent static ip. (I personally keep a low range like from 192.168.1.1 to 192.168.1.20 to be for static ip’s only, and leave higher range for dhcp).

Then decide on a number in that static range to use for your mod…I decided on 192.168.1.2 to be my Mod’s static ip.

Now take a deep breath because it is possible to screw up setting the static ip and loosing ssh access to your mod…so again please make sure you are careful and know what you are doing and know how factory reset your mod if you screw up.

First unplug the mod’s usb from your router and plug it into your computer.

Then ssh into it with its factory default static ip:

ssh root@192.168.51.1

Then make the filesystem writable:

mount / -o remount,rw

Then setup your custom static ip address like this guide but using your desired static ip as replacement. So because I wanted to change from 192.168.51.1 to 192.168.1.2 I ran:

sed -i "s|192.168.51.1|192.168.1.2|" /etc/dnsmasq.conf /etc/network/interfaces /etc/ssh/sshd_config
sync && mount / -o remount,ro && sync && reboot

(At this point you might have lost the ability to easily ssh when the mod is directly connected into your computer, which is why you need to be careful and which is why I got the OpenWrt USB ethernet driver and bridge setup first)

Unplug your mod from your computer and now plug it back into your OpenWrt router’s USB port. If everything was done correctly, then hopefully you should be able to access the mod (both via web and ssh) at it’s new static ip address, from any computer on your LAN.

4. Expose ModDuo to outside internet

On last trick I did was give my mod duo access to the outside internet by updating /etc/network/interfaces to include the gateway for my ISP’s router. So first ssh into my mod via the new ip static ip address

ssh root@192.168.1.2

And vi /etc/network/interfaces to append a tabbed line at the end with gateway $YourGatewayIP which since my gateway is 192.168.1.254 that file now looks like:

auto lo
iface lo inet loopback

allow-hotplug usb0
iface usb0 inet static
  address 192.168.1.2
  netmask 255.255.255.0
  gateway 192.168.1.254

And after I rebooted my mod, I’m now able to ping google or any other ip address in the internet.

At this point if you really wanted to access your ModDuo from outside your home LAN you could edit your ISP’s router’s port forwarding setup to route incomming packets with whatever particular ports you wanted to your ModDuo. For instance, if you wanted to to view the web interface from outside your home LAN you would forward port 80 to to your mod’s static ip, or maybe you want to access via netJack, so maybe you would forward port 19000 (though I haven’t tried this). I intend to figure out how to get JackTrip working in my ModDuo now, so I can jam with it directly on the internet.

5 Likes

FYI, I’ve measured the roundtrip ping time from my OpenWrt through USB to the ModDuo and back to be:

round-trip min/avg/max = 0.578/0.671/0.975 ms

Also quick note, I am able to access the loading screen of the ModDuo’s web UI from outside of my home ip via port 80 forwarding, although it doesn’t get past the loading. So maybe there is something I need to unblock.

I’ve can connect via netjack (wiki) to my ModDuo from a desktop computer wired via ethernet to the OpenWrt router my Mod is on. I ran running this command on the desktop:

jackd -R -P 80 -d net -a 192.168.1.2 -C 2 -P 2 -i 1 -o 1 -l 4 -n mod-slave -s

I’ve measured the roundtrip delay with jack_delay, and it is exactly 768 frames or 16 milliseconds, without wavering. I am able to reduce -l down to the minimum possible of 0 and jack_delay reports exactly 256 frames or 5.33 ms, without wavering. (Keep in mind the inherent time of a 128-frame buffer is 2.67 milliseconds.)

5 Likes

ModDwarf’s usb ethernet is able to receive a proper driver after installing kmod-usb-net-cdc-subset, which also must be manually installed in OpenWrt because it is not included in fresh OpenWrt install images.

my Netgear WNDR3800 router only has one usb port to plug into. But using an additional USB hub in between, I am able to get access to both my ModDuo and ModDwarf together. Here is output of lsusb in regular format and in tree format:

root@OpenWrtTea:~# lsusb
Bus 001 Device 004: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
Bus 001 Device 002: ID 1a40:0201 Terminus Technology Inc. FE 2.1 7-port Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@OpenWrtTea:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/7p, 480M
        |__ Port 3: Dev 3, If 0, Class=Wireless, Driver=, 480M
        |__ Port 3: Dev 3, If 1, Class=CDC Data, Driver=cdc_subset, 480M
        |__ Port 4: Dev 4, If 1, Class=CDC Data, Driver=cdc_ether, 480M
        |__ Port 4: Dev 4, If 0, Class=Communications, Driver=cdc_ether, 480M

The ModDuo is Dev 4 with Driver=cdc_ether, and the ModDwarf is Dev 3 with Driver=cdc_subset.

Though the ModDwarf still has a “Wireless” subdevice listed. I also went and installed kmod-usb-net-rndis and that results in an updated tree with Driver=rndis_host:

root@OpenWrtTea:~# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci-platform/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/7p, 480M
        |__ Port 3: Dev 6, If 0, Class=Wireless, Driver=rndis_host, 480M
        |__ Port 3: Dev 6, If 1, Class=CDC Data, Driver=rndis_host, 480M
        |__ Port 4: Dev 4, If 1, Class=CDC Data, Driver=cdc_ether, 480M
        |__ Port 4: Dev 4, If 0, Class=Communications, Driver=cdc_ether, 480M

The ModDwarf’s networking wouldn’t properly until I also installed the rndis_host driver, but I’m not entirely sure if I needed to install both or just the rndis_host. At this point, running ip link or ip addr shows the presence of two separate usb ethernet devices now, “usb0” and “usb1”.

2 Likes

now I’m able to add the second usb ethernet device “usb1” to the bridged interface along with the first usb ethernet device “usb0”:

2 Likes

at this point I followed the earlier instructions on renaming static ip, and gave my ModDwarf 192.168.1.3, and so now both ModDuo and ModDwarf are accessible by any computer on my LAN, and they’re even able to ping eachother!

1 Like

curiously I measured 30 pings from my OpenWrt router to the ModDuo with the hub inbetween (which is also connected the Dwarf), and measured:

round-trip min/avg/max = 0.569/0.655/0.803 ms

Which is somehow slightly faster than my earlier measurement of 30 pings when they were directly connected without a hub inbetween:

round-trip min/avg/max = 0.578/0.671/0.975 ms

And the measurement from OpenWrt through the hub to the ModDwarf is also not noticeably slower.

round-trip min/avg/max = 0.572/0.667/1.246 ms

So it doesn’t seem like the hub adds much latency. But I would still recommend avoiding hubs if will be sending time-critical audio.

1 Like

Thank you so so much for sharing this and sharing it soooo detailed! :star_struck: :slightly_smiling_face:

1 Like

note, if you enable the USB midi mode in newer Mods like ModDwarf, will need to install kmod-usb-audio for the USB audio driver and alsa-utils and alsa-utils-seq.

I’ve verified I’m able to now run amidi --dump on my OpenWrt and see received midi messages from the Mod Dwarf via USB midi.

1 Like

Since you have a dwarf, that means v1.10, so the WiFi steps should work there.
Might be more useful than connecting to the router.