I’ve long been a fan of open firmware for my home routers. Way back I started with DD-WRT, but more recently I’ve moved to OpenWRT paired with TP-Link Archer C7 hardware. I actually have two, one as my main gateway and a second configured as a dumb AP (access point). Running two WiFi access points means I get great coverage from the basement, to the second floor.
While I have two, they are not quite identical. One is a v5, and the other is a v2. Still, for hardware you can pick up for under $100 it fits into my sweet spot for hardware. I picked up both of mine used, for less than half the price of new hardware. The other benefit to having two which run the same software stack (OpenWRT 19.07), means I can swap hardware for the main gateway if I have a compatibility problem.
Recently the latest version (21.02) has been declared stable. It’s well past time to upgrade. With the hardware I have, OpenWRT has recently done a transition from ar71xx to ath79. Thankfully In my setup with 19.07 I’d already moved to ath79.
You can check the TARGET
that you are running by ssh’ing into the router and looking at the /etc/openwrt-release
file
|
# cat /etc/openwrt_release | grep TARGET DISTRIB_TARGET='ath79/generic' |
It is a good idea to start with the release notes. The upgrade process is 3 parts.
- Prepare
- Upgrade
- Post Install Configuration, Setup or Restore
We’ve already started the Prepare step since we have looked at the release notes and made sure we have the ath79 version running. Since we’re already on ath79 we can use the normal sysupgrade process. OpenWRT is also moving to DSA Networking, but the hardware I’m using hasn’t switched over yet – the upgrade process will detect this and refuse to upgrade if you have a problem.
I’ve got a full rsync backup of my router configuration, so if something goes really wrong I at least have the files.
Next I need to figure out which packages I have installed on the router(s). This script seems to work well, I’ll duplicate the script here.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
cat << "EOF" > /tmp/listuserpackages.awk #!/usr/bin/awk -f BEGIN { ARGV[ARGC++] = "/usr/lib/opkg/status" cmd="opkg info busybox | grep '^Installed-Time: '" cmd | getline FLASH_TIME close(cmd) FLASH_TIME=substr(FLASH_TIME,17) } /^Package:/{PKG= $2} /^Installed-Time:/{ INSTALLED_TIME= $2 # Find all packages installed after FLASH_TIME if ( INSTALLED_TIME > FLASH_TIME ) { cmd="opkg whatdepends " PKG " | wc -l" cmd | getline WHATDEPENDS close(cmd) # If nothing depends on the package, it is installed by user if ( WHATDEPENDS == 3 ) print PKG } } EOF # Run the script chmod +x /tmp/listuserpackages.awk /tmp/listuserpackages.awk |
This will dump out the list of packages that you have installed beyond the stock configuration. I’ve got rsync
installed (of course) along with the prometheus
packages. The upgrade will not automatically install these packages, so having the list of them helps us get back to the configuration we are used to.
We should now be ready to Upgrade. I found the easiest way to get the right sysupgrade package was using the Firmware Selector web tool. Since I have slightly different versions, I needed to make two downloads.
It is always a good idea to check the hash (sha256sum) of the files you download to make sure you have a good download. I’ve been burned only a handful of times by this, but once should be enough to teach you the lesson.
Using the Web UI to upgrade can be found in the menu system: LuCI → System → Backup / Flash Firmware → Actions: Flash new firmware image.
Time for a deep breath, and double check we have a backup. Time to flash, also double checking we push the right version to the right device.
After flashing the 1st device, I noted two things. The “flashing” screen seemed to get stuck – well past when the device has refreshed. Using a second browser window, I think I figured out why things got stuck. The LuCI web UI now redirects you to https:// with a self signed certificate. I think the browser on the flash screen got stuck because of the change in protocol (and the bad cert).
It’s good that the web UI is now hosted using https because now when you log in, you’re not sending your passwords in the clear. Sure it’s your own network, but I think I’d rather have to deal with clicking through the advanced screens to tell my browser to accept the self signed certificate than not have a secure connection.
For the Post Install Configuration, Setup or Restore step it’s a matter of going through the packages I’d identified above and re-installing them. As a second check, I also re-installed an re-ran the listuserpackages.awk script and got the same list back once I’d installed all the packages.
I can also verify that all of the configuration files made it by testing the functions these additional packages had. All was good, at least with my dumb AP.
My main gateway router was a bit scarier – it’s got a few more packages installed than the dumb AP and when I update it, I take an internet outage. Also, I ran into trouble trying to update some of the modules:
- kmod-usb-storage
- kmod-usb3
Both of these are related to my use of a USB drive as storage for the vnStat package. This appears to be a bug in the web UI – either way, using the cli worked fine to install things. It also looks like a fix is coming in the next patch.
The cli was happy to find the package
|
# opkg list | grep usb-storage kmod-usb-storage - 5.4.143-1 - Kernel support for USB Mass Storage devices kmod-usb-storage-extras - 5.4.143-1 - Say Y here if you want to have some more drivers, such as for SmartMedia card readers |
Where the web UI simply failed to located it.
In the end all was well, and a reboot to make sure things all came back just fine got me back to a fully working state but on the latest version. This was much easier than I had expected and I shouldn’t have stalled doing this so long.
A few housekeeping details to work through post install / basic check out. The upgrade procedure will create *-opkg
files in /etc/config
when you install the new packages. Be safe and do a quick diff and review of what has or has not changed (you may need to install the diffutils package, or move the files off the device to a machine that can diff things).
In my case – the sqm package seems to have changed at least some of the options. My setup still works, but I should probably rebase my config file.
Other stuff I have to fiddle with. WPA3 – now mainline for OpenWRT I need to figure out how to run with this new protocol (while not breaking the world). A quick look around makes it seem like WPA3 is still a bit on the bleeding edge.
There is also New network configuration syntax and board.json change which means some changes in /etc/config/network
which I should probably make sure I migrate to (the current build has some backwards compatibility – so my old file is fine for now).
Doing a planned migration / upgrade was way better than my usual emergency restore / rebuild. The last time I was messing with the router firmware I’d accidentally run an rsync backup and gotten the source / target the wrong way around – successfully sync’ing a blank directly onto my operating access point. Doh.
Anyways, hopefully this article helps me (or someone else) upgrade smoothly in the future.