01Why bother
The router my ISP gave me ran vendor firmware I couldn't inspect or update. I wanted a router I control: a current kernel, WPA3, a guest network that's really isolated, and logs I can read. The hardware was fine. The software was the problem.
02Making it boot, and keep booting
The port is more than a device tree. The router has two firmware slots and a vendor bootloader stage that has to stay intact, so I wrote install and upgrade scripts that work with the A/B slots instead of fighting them, plus a way back to stock.
The Wi-Fi calibration data was the awkward part. It doesn't sit in a raw flash partition. It lives only as a compressed file inside the stock firmware's UBI config volume. The installer copies it once into its own volume, and the kernel reads it from there through NVMEM, so both radios come up calibrated.
03Bug one: half the interrupts waited for the timer
Pings to the router cycled between 1 and 11 ms. A pattern like that, short then long, then short again, usually means work is waiting for a timer tick.
In the mode this board uses (no VEIC), the interrupt controller can raise the CPU on several interrupt lines, IP2 to IP6. The driver only chained one of them. Anything that arrived on the other lines sat there until the next timer interrupt happened to run the handler.
The fix is three small patches: let the binding describe up to six parent interrupts, chain the handler to all of them, and connect the controller to IP2–IP6 in the device tree. Ping went from cycling 1–11 ms to under 1 ms.
$ git log --format=%s -3
mips: dts: Connect the EcoNet EN751221 intc to IP2-IP6
irqchip/econet-en751221: Chain the handler to all parent interrupts
dt-bindings: interrupt-controller: econet,en751221-intc: Allow up to 6 parent interrupts
04Bug two: a router that was deaf on some boots
Every so often the router came up and its Ethernet received nothing. A reboot fixed it, which is the worst kind of bug. It came down to a race: the driver could lose the very first RX interrupt, and then the port never picked up any traffic. The fix makes sure that first interrupt isn't lost (econet_eth#19).
05Bug three: TRGMII lock-ups
The SoC talks to the switch over TRGMII, and that link could lock up. I fixed this one in the port too, so the switch link comes up and stays up.
06Getting it upstream
A fix that lives only on my router helps nobody else, so all of it went to the right maintainers.
Sent the interrupt series to the Linux kernel lists, and opened openwrt#26744 and econet_eth#19.
Caleb James DeLisle, who works on the EcoNet port upstream, tested the series on his hardware and gave a Tested-by.
Sent v2 with the review fixes, and opened the device support pull request, openwrt#26932, which passes OpenWrt's formality checks.
Answered the review on #26932, including a build-time size check so a bigger kernel can never overwrite the bootloader stage that sits right after it in flash.
Thomas Gleixner, the Linux interrupt maintainer, applied all three kernel patches to the tip tree's irq/drivers branch, which feeds mainline.
“I tested and confirm that hardware indeed behaves as described.”
Caleb James DeLisle, on the kernel series
07A second unit, and a home network I can read
I also installed OpenWrt on a second unit, a Tata Play router whose bootloader menu is locked, by working through its stock A/B firmware slots instead of the bootloader. The two routers now run my home network:
- WPA3 with PMF on the main network, and an isolated guest network.
- AdGuard Home on the second router for DNS filtering, with logs and backups on its USB stick.
- 802.11k/v/r roaming. My OpenWrt image only had the basic hostapd, so I rebuilt the full one from the firmware's exact source. To prove the build matched the firmware, I rebuilt the basic variant the same way and checked it byte for byte against the shipped binary.
- SMP packet steering tuned for the dual-thread MIPS 34Kc, with a clean 10-hour soak test.
- A watchdog that reboots the second router if it loses the main one, kernel crash logs kept in pstore, and a restore kit with scripts for both routers.
My notes and tools for the Tata Play unit are public in my Hardware-Hacking repo: how I booted OpenWrt from RAM over UART, how its firmware slots and boot flags work, and how I recovered its locked bldr> password.