Updating OpenWrt when you need a USB Ethernet driver

I've been using OpenWRT on various WiFi routers for a while. When I update the router to a new version of OpenWRT, it wipes out all of my packages, so I just ssh to the router and paste in a little script I have to re-install the necessary packages. This works because the packages I need (ddns, 6in4, etc.) aren't required for basic IPv4 connectivity. Hence, my router works well enough to bootstrap itself back to fully operational.

Now, however, I would like to place my WiFi access points in a different location and use OpenWRT for a non-WiFi router. I got a Raspberry PI 4b and an ASUS USB-C2500 Ethernet dongle, and was hoping to use the built-in Ethernet port for the WAN and the faster 2.5GBaseT USB adapter for the LAN. (The Ethernet adapter seems to work under archlinuxarm.)

Unfortunately, the Ethernet dongle does not work out of the box on OpenWRT, because it requires installation of a separate driver package (presumably kmod-usb-net-cdc-ether or similar). I could install the driver now before deploying the Raspberry Pi as my router. The problem is that if I do so, it will no longer be simple to upgrade OpenWRT, as I will lose the ability to ssh into the box when the USB driver has been deleted after an upgrade.

Does anyone have suggestions on how best to handle this situation? I've considered using VLANs to connect the Raspberry Pi twice to the LAN, once on some management VLAN. Or I thought of making the raspberry pi a client on the WiFi network. But these are kind of gross solutions. Is there a cleaner way to update OpenWRT when it needs an Ethernet driver?

VLANs would work as long as you have a smart/managed switch, but there is an easier way...

since you're using a Pi, you have a built-in console. Simply connect a monitor and a keyboard. You can login directly to OpenWrt on the pi. The built-in ethernet port (eth0) will be LAN by default, but you can change it to WAN pretty easily and then connect it to your upstream device. From there, use the console to install the packages necessary to get your USB ethernet adapter running.

Another option is to use the image builder to create an image that is pre-loaded with your packages (and optionally your configuration files) so that it is ready to go out of the box. You may want to do the console thing first to get a working configuration and to test the drivers for your ethernet adapter.

1 Like

The VLAN situation is not ideal. I do have one managed switch, but I don't really have a spare port.

Unfortunately, I also cannot really fit a monitor where my router lives.

I can, however, easily remove the sd card briefly when I need to upgrade, so maybe I should investigate using the image builder.

So just to conclude this thread, in case people later come across it, the image builder was a good solution. The information is readily available, but I'll summarize it here for anyone who comes across this thread.

First, you need to figure out what driver you need. To do this, you can plug the device into a desktop/server linux distribution, or a full-fledged arm distro on your Raspberry Pi (e.g., archlinuxarm). In my case, after doing this, the command ip link revealed that the USB Ethernet interface was called enp99s0u1u1c2. So then I ran:

$ ls -l /sys/class/net/enp99s0u1u1c2/device/driver/module
lrwxrwxrwx 1 root root 0 Nov 28 18:13 /sys/class/net/enp99s0u1u1c2/device/driver/module -> ../../../../module/cdc_ncm

which showed that the module I needed was cdc_ncm. So then updating the package list (opkg update) and searching for cdc on the luci gui software page, or running opkg list | grep cdc, shows the corresponding package iskmod-usb-net-cdc-ncm. The only tricky thing is changing the underscore _ to a hyphen - in the package name, since modules use underscore where packages use hyphens.

Now to get the image builder. When you click the "All firmware images" link on the openwrt.org home page and click through to your platform, there are some extra files to download at the bottom. For example, the Raspberry Pi 4b is the bcm27xx/bcm2711 target, so you can go to https://downloads.openwrt.org/releases/21.02.1/targets/bcm27xx/bcm2711/ to download release 21.02.1. At the bottom of the page is a file openwrt-imagebuilder-21.02.1-bcm27xx-bcm2711.Linux-x86_64.tar.xz, which you can download and unpack.

In the unpacked imagebuilder directory, run:

make image \
     PROFILE="rpi-4" \
     PACKAGES="luci-ssl kmod-usb-net-rtl8152 kmod-usb-net-cdc-ncm"

This adds the extra Ethernet drivers that I need (I actually have two different USB Ethernet dongles, so am adding drivers for both). You need to add luci-ssl as well, because the image builder by default gives you everything except the web interface. You can add other packages here, as well as extra configuration files by including a FILES=files argument and the placing the files you want to overlay onto the image in a files subdirectory you create.

Finally, you will get a file bin/targets/*/*/openwrt-*-squashfs-sysupgrade.img.gz that you can use to upgrade your system. Either upload it in the "flash firmware" page of luci, or copy it to /tmp on your router with the scp command and then run sysupgrade -v openwrt-*-sysupgrade.img.gz on the router.

Once you know the exact make command you want, this is really not much harder than upgrading from the stock release--there's just one extra command you need to run to generate the image.

2 Likes

Just one more note that I mentioned using the ASUS USB-C2500, but actually this adapter does not work under linux, despite claims. I had two adapters, both were recognized, and the non-ASUS one worked. So now I'm using a StarTech US5GA30, with the kmod-usb-net-aqc111 package. It doesn't get anywhere near the 5Gbps link speed it negotiates, but I've been able to transmit at over 2Gbps, so it's better than the built-in 1000BaseT.

I've seen review where the AQC111U chip max out at around 3.5, 2 is a little (s)low.

Actually, it's worst than that. I had the AQC111U on the Raspberry Pi plugged into a 10G switch, and a server plugged into the same switch. The server was using 10GBaseT, but if I downgraded it it to 2.5GBase-T, then I could get close to 2.5Gbps, but when the server had its native 10G link speed, the throughput was worse. Also iperf3 reported a bunch of retransmissions. Then I tried it with a laptop, and it was a bit better.

However, the ACQ111 really fell over when I actually started routing through my raspberry pi. It cut download throughput almost in half, from 920Mbps with the Gigabit adapter to around 500 Mbps. So basically I decided to use the r8153 adapter instead. Kind of a waste of a port on my 10Gig switch, but the 1Gig adapter just works better than the 5Gig one in practice.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.