[{"content":"Why I built it A lot of my work is supporting on-site PCs over remote access. When an on-site worker plugs one of our in-house router products into the PC, the routing table changes and remote support can no longer connect.\nWith no way in remotely, the routing table has to be fixed on site, and the workers, naturally, do not know Windows commands like route print or route delete. Reading commands out one character at a time over a call, first on Skype and now on Teams, only went so far.\nSo, to prevent that situation, I built a small GUI tool that shows the routing table as a list and lets you add, edit and delete routes on screen without knowing any commands.\nFeatures IPv4 / IPv6 routing table view: column sorting and filtering Add / edit / delete routes Enter a gateway and the interface on the same subnet is selected automatically Host bits in the destination are cleared to the network address, with a preview of what will be applied Multi-select and bulk delete: Explorer-style Ctrl+click, Shift+click, Ctrl+A, Esc and Delete Persistent routes: implemented on the same registry store as route -p (IPv4 routes with a gateway). I have not yet confirmed myself that they are applied after a reboot. Copy as command: from the right-click menu, copy the selected routes as the commands that add the same routes (route add for IPv4, netsh for IPv6) Routes on disconnected interfaces are hidden by default, as in route print, and a checkbox shows them What I paid attention to 1. No route.exe Running route.exe and parsing its output is simple, but the output text changes with the Windows display language, and the cause of a failure is hard to pin down. So the tool calls the Windows IP Helper API directly.\nAction API List GetIpForwardTable2 Add CreateIpForwardEntry2 Change metric SetIpForwardEntry2 Delete DeleteIpForwardEntry2 It works regardless of locale, and when a call fails it gets the Win32 error code directly and can show the cause along with the number.\n2. Metrics that look different from route print The Metric the API returns is the route metric, while the value route print shows is route metric + interface metric. Showing the raw value would not match route print and would confuse people, so the list shows the sum and the add/edit form takes the route metric.\n3. Edits that change the key are \u0026ldquo;add, then delete\u0026rdquo; If the destination (including the netmask), gateway and interface stay the same and only the metric changes, the tool uses SetIpForwardEntry2. If any of them changes, it adds the new route first and deletes the old one only if that succeeded. That way a failure partway through never leaves you without the original route.\n4. Administrator rights only when needed Viewing works with normal rights, so the tool does not raise a UAC prompt every time it starts. To change routes, the \u0026ldquo;Restart as administrator\u0026rdquo; button in the app (관리자 권한으로 다시 시작) relaunches it through UAC.\n5. The \u0026ldquo;On-link\u0026rdquo; label At first, routes without a gateway were labelled \u0026ldquo;연결됨 (on-link)\u0026rdquo; (\u0026ldquo;connected (on-link)\u0026rdquo;), but rows on disconnected interfaces also said \u0026ldquo;connected\u0026rdquo;, which was confusing. On-link has nothing to do with link state, so the label is now just \u0026ldquo;On-link\u0026rdquo;, and rows on disconnected interfaces are dimmed with \u0026ldquo;(연결 끊김)\u0026rdquo; (\u0026ldquo;disconnected\u0026rdquo;) next to the interface name.\nDevelopment environment Language: Rust (edition 2024, MSVC toolchain) GUI: eframe / egui 0.37 + egui_extras (tables) Windows API: the windows 0.62 crate, windows-registry for the registry Size: about 2,100 lines (src/*.rs), 16 tests (14 pure-logic tests + 2 smoke tests that only read the live routing table and registry) UI language: Korean License: MIT cargo build --release # target\\release\\dhrouteview.exe cargo test Download Repository: https://github.com/pdh0085/DHRouteView Release v0.1.0: https://github.com/pdh0085/DHRouteView/releases/tag/v0.1.0 DHRouteView.exe: a single exe that runs without an installer DHRouteView-v0.1.0-windows-x64.zip: the exe + LICENSE + README The exe is not code-signed, so Windows SmartScreen may warn the first time you run it. Changing routes requires administrator rights.\nWrapping up For a developer this is a few lines of commands, but for an on-site worker who does not know the commands it is not easy. Since routes can now be checked and cleaned up on screen in a few clicks, I expect it to make it much easier to deal with remote support dropping. Next, I am thinking of adding features such as exporting and importing the route list.\n","permalink":"https://pdh0085.github.io/posts/dhrouteview-windows-routing-table-gui/","summary":"When an on-site worker plugs a router into a PC, the routing table changes and remote support drops. A small Windows tool written in Rust that lets people check and fix the routing table on screen without knowing any commands.","title":"A GUI Instead of the route Command: DHRouteView, a Windows Routing Table Tool"},{"content":"If you work on home routers, LTE/5G CPEs or ISP operations, you know the two standards behind remote device management: TR-069 (CWMP), the SOAP-over-HTTP protocol that most CPEs in the field speak, and TR-369 (USP), its successor, which runs over MQTT, WebSocket or STOMP. The server side of TR-069 is called an ACS; the server side of USP is a Controller.\nI have just published Dhonomos, an ACS and a USP Controller in one Rust program, under the Apache-2.0 license:\nhttps://github.com/pdh0085/dhonomos\nThis post explains why it exists, what it does today, and what it does not do yet.\nWhy Another ACS? I am a software developer at Lightspeed International, a Taiwanese maker of routers and LTE/5G CPEs. Testing firmware means talking to the devices the way an operator\u0026rsquo;s server does: reading parameters, changing settings, pushing firmware, and waking devices that sit behind NAT. For that we needed a server we could run in the lab, read the code of, and change when a device did something unusual.\nThe open-source choices were few. Commercial ACS products are expensive and closed. The best-known open-source ACS is licensed under the AGPL, which many companies will not run or modify. And open-source USP Controllers that a small team can actually deploy are rare, even though USP Agents (such as the open-source obuspa) are already in products.\nSo Dhonomos started as a test helper in our lab and grew into a full server. The company agreed to release it as open source.\nWhat It Does CWMP ACS\nTR-069 Amendment 6 sessions (CWMP 1.0-1.4) over TLS, with Digest or Basic auth. Per-device credentials bound to their device, optionally issued on first contact. After that, the shared credential no longer works for that device. Zero-touch onboarding: a new device is read in full on its first Inform, under a policy (accept all, quarantine, pre-registered only, OUI allow-list). Connection Requests over HTTP, over UDP with a built-in STUN server, and over XMPP with a built-in XMPP server. XMPP matters for CPEs behind carrier-grade NAT: the device keeps a TCP connection open to the server, and the wake-up goes down that connection with a delivery confirmation. A built-in file server for firmware and configuration files, with signed links and bandwidth limits. USP Controller\nMTPs: MQTT 5 (through an external broker such as Mosquitto, or a broker built into Dhonomos), WebSocket in both directions, and STOMP 1.2 with a built-in broker. Its own CA for Agent certificates, with issuing, an expiry list and revocation. An EndpointID that has a certificate cannot be claimed over a weaker MTP. Operations\nA task queue with retries, presets (YAML or web UI) and sandboxed provisioning scripts in Rune, a small embeddable language for Rust. Bulk jobs and firmware campaigns with canary stages and an automatic pause when too many devices fail. Diagnostics with one result format for CWMP and USP: ping, traceroute, DNS, TR-143 speed tests, Wi-Fi neighbours. Configuration backup, drift detection, restore and device replacement. WireGuard tunnels to devices, managed from the server, with an optional hub program. A REST API with an OpenAPI 3.1 document, a web UI (SvelteKit) built into the binary, roles, device scopes per team, OpenID Connect single sign-on, TOTP two-factor authentication and an audit log. The whole server is one executable plus PostgreSQL. The container image is a static musl binary on an empty base image, about 22 MB.\nHow It Performs On a 12-core Xeon E5-2630 (2.3 GHz) with PostgreSQL on the same host, a simulator drove 50,000 virtual CPEs at about 2,000 periodic Informs per second for 60 seconds: no errors, Inform p50 9.9 ms and p99 441 ms, and 113 MB of memory for the server. That run used a larger database pool and session limit than the defaults (96 connections, 4,096 concurrent sessions); with the defaults the same load gets 5.7% of sessions turned away with 503. The simulator and the benchmark harness are in the repository (crates/simulator, cargo xtask bench), so you can repeat the measurement.\nWhy Rust A management server sits on the internet edge of an ISP and parses input from tens of thousands of devices it does not control. Memory safety matters there, and so does a small, predictable footprint. Rust gave us both, plus a strong ecosystem for the parts we needed: tokio and axum for the network side, sqlx with compile-time checked queries for PostgreSQL, prost for USP protobuf, rustls for TLS. unsafe is forbidden in every crate but one, which has a single, documented getsockopt call, and the protocol parsers have fuzz targets.\nWhat It Does Not Do Yet Honesty first:\nIt is pre-1.0. There are no releases yet; you build it from source. Flags, the API and the database schema can still change. There has been no external security review yet, only internal ones. The operations guides are in Korean; the README and the installation guide are in English. Full multi-tenancy is not there yet. It has been tested with OpenWrt-based CPEs and with simulators. Devices from other vendors may show behaviour we have not met yet. Reports are very welcome. Try It git clone https://github.com/pdh0085/dhonomos.git \u0026amp;\u0026amp; cd dhonomos docker build -t dhonomos:dev . cp deploy/dhonomos.env.example deploy/dhonomos.env # fill in the secrets, CPE credentials, ACS cert docker compose -f deploy/docker-compose.yml up -d Then point a CPE\u0026rsquo;s ACS URL at the server. The installation guide walks through TLS, the first CPE and the first USP Agent.\nThe Name Dhonomos is \u0026ldquo;DH\u0026rdquo; (my initials) plus oikonomos, the Greek word for the steward of a household, and the root of the word economy. A server that looks after the devices in subscribers\u0026rsquo; homes seemed a fitting job for a steward.\nIf you run an ACS today, build CPEs, or are looking for a USP Controller, I would like to hear what you need. Issues are open on GitHub.\n","permalink":"https://pdh0085.github.io/posts/dhonomos-open-source-acs-and-usp-controller/","summary":"I have released Dhonomos, a TR-069 (CWMP) ACS and a TR-369 (USP) Controller in one Rust program, under Apache-2.0. Why it exists, what it does today, and what it does not do yet.","title":"Dhonomos: An Open-Source TR-069 ACS and USP Controller in One Rust Binary"},{"content":"Why I did this Over about seven weeks in autumn 2026 I moved the Maxon / RF Industries MA-2080X cellular router off its vendor Linux 3.2 firmware and onto OpenWrt 25.12.5. The result, OS-DHP 2.2.6, runs on two bench units with A/B updates, a web UI, TR-069 / TR-369 management and almost every feature the vendor firmware had.\nThe MA-2080X is a modular industrial router: a TI AM3352 board, an eMMC, a Sierra Wireless cellular module, two SIM slots, serial ports, digital I/O and GNSS. Its stock firmware still ran a 3.2 kernel from more than a decade ago. That means no current security fixes, an old TLS stack and no realistic way to add modern management protocols.\nThe product will not ship with it, so this post is the record: what the port involved, what bit me, and what I would do the same way again.\nThe starting point I started with a 2015 schematic, the vendor\u0026rsquo;s Linux 3.2 source tree, and two bench units. Where the schematic and the vendor board file disagreed, the board file won: it is what actually shipped.\nWhat the hardware turned out to be:\nSoC and memory: TI AM3352 (Cortex-A8), 512 MB RAM, an eMMC as the only storage. Every GPMC pin is reused for eMMC data, the second RGMII port or GPIO. Ethernet: two separate EMACs, not a switch. OpenWrt\u0026rsquo;s omap target already moves am335x boards back to the legacy cpsw driver, so the device tree uses two plain MAC ports. Cellular: a Sierra Wireless module on the expansion socket, two SIM slots behind a mux, SIM presence read through an ADC voltage band. GNSS comes from the module on production boards. Field I/O: serial ports used as a TCP/serial gateway, digital inputs and outputs, analogue inputs, status LEDs and a reset button. The eMMC carries the vendor\u0026rsquo;s partitions: MLO and U-Boot in p1/p2, a vendor \u0026ldquo;nvram\u0026rdquo; settings store in p3, the U-Boot environment in p4, two kernel slots in p5/p6, and a media partition in p7.\nThe vendor firmware runs entirely from RAM (root=/dev/ram0), packed as an Android boot image inside a small vendor container with a 16-bit checksum. I reverse-engineered that container and reproduced it byte for byte. Its packer even wrote two header fields from uninitialised stack, so they differed on every run.\nBring-up: OpenWrt first, the bootloader later The plan was to change one irreversible thing at a time, so a unit in the field would never need a site visit.\nPhase 1, OpenWrt on the vendor bootloader. The vendor U-Boot (2011.09) boots an Android boot image with a fixed load address and command line. I built OpenWrt for target/linux/omap as a kernel plus initramfs in exactly that format, so the first migration is a single upload through the vendor\u0026rsquo;s own web page. The first OpenWrt boot on the board was on 11 September. Phase 2, a new U-Boot on the bench. The vendor bootloader had no fallback at all: a bad image dropped it to a prompt for ever, and its SPL turned the watchdog off. I ported U-Boot 2025.10 to the board, first by chainloading it from the vendor prompt, then from a microSD card with two bare pads bridged to change the boot order. That SD path became the proven brick-recovery route before anything touched MLO in the eMMC. Phase 3, the bootloader from the web UI. Every OS image carries its matching MLO / u-boot.img pair. An install job checks the board, the partition table and the current checksums, writes p2 then p1, reads each back and restores the old one on a mismatch. With the new U-Boot the two kernel slots become a real A/B pair. Sysupgrade writes the inactive slot, verifies it and only then flips ab_primary. U-Boot counts boot attempts; after three failures it boots the other slot, and the hardware watchdog turns a hung kernel into such a failure. A boot that reaches a healthy userspace clears the counter.\nA bad image falls back to the other slot by itself Write the spare slotand verify it Flip ab_primary,arm the boot counter U-Boot countsone more attempt Over 3 attempts? Boot ab_primary Boot the other slot Userspace healthy? Boot confirmed,counter cleared Watchdog resetsthe board no yes yes no, it hangs reset, then the next attempt A/B update and fallback · U-Boot boot counter with bootlimit 3 No human is needed between a bad upgrade and a working unit: a hang becomes a watchdog reset, and after three failed attempts U-Boot boots the slot that worked before.\nOne more problem came from the RAM root. OpenWrt\u0026rsquo;s normal overlay needs pivot_root, which the kernel refuses on an initramfs. So a preinit hook mounts a new ext4 config partition and overlays /etc alone. On a unit fresh off the vendor firmware, an earlier hook recognises the factory partition table by its checksum, shrinks the media partition, and writes a new GPT from bytes computed ahead of time. Then an importer reads the vendor\u0026rsquo;s p3 settings store (more on that below).\nThe first real bootloader install on a unit still found a bad bug. The write and read-back verify passed, but the unit never autobooted again because a hand-edited patch had a wrong hunk header, so one boot variable was never defined. The serial console and a careful write order turned it into a fix, not a dead unit.\nFeature parity with the vendor firmware A new base system is worthless to an operator if the router stops doing its job. So after bring-up most of the time went into the features the vendor firmware had, built on dhplab, a shared OpenWrt application framework I also use for other products. In October a survey of the vendor source found what OS-DHP still lacked; 14 feature branches closed that gap, and each went through a review before it was merged.\nArea What OS-DHP does Cellular Dual SIM with failover (no signal, failed connections, roaming, data limit), per-SIM APNs, uplink switching between Ethernet and cellular, data usage per SIM, network time from the cell network Serial TCP / UDP serial gateway with the vendor\u0026rsquo;s AT-command \u0026ldquo;IPStack\u0026rdquo; set, dial emulation, AT over IP, back-pressure instead of dropped connections Industrial protocols Modbus (including the vendor\u0026rsquo;s FTP upload formats), DNP3 outstation with dial-out and unsolicited reports I/O and alarms Digital and analogue I/O, alarm events to SMS and e-mail groups, SMS commands (status, SIM switch, APN, reboot and more), user scripts on events GNSS Position from the cellular module, NMEA and tracking reports to servers, geofences Networking IPsec (including IKEv1 aggressive mode), OpenVPN with a certificate store, PPTP, VRRP, SNMP with the vendor\u0026rsquo;s MIB, content filtering, scheduled reboots, power saving Management Web UI, TR-069, TR-369 / USP over WebSocket and STOMP, RADIUS login, log export, signed plugins The settings importer is what makes this a migration rather than a reinstall. It reads the vendor settings on the first boot and writes the matching OpenWrt configuration, so a unit comes up after the upload with its LAN, APNs, serial ports, I/O and alarm contacts as they were. The work included a 236-page user manual for the new firmware.\nThings that bit Most of the lost days came from things that failed silently. These are the ones worth passing on.\nHardware\nSignal names lie. Several GPIOs (SIM mux, modem power, RF enable) had the opposite polarity to their names. The vendor code and a measurement were right; the schematic net names were not. One part can wedge a whole bus. On development boards the discrete GNSS receiver held I2C0, so the power-management IC behind it became unreachable. The fix was to keep the receiver in reset until the I2C users had probed, and to let CPU frequency scaling switch itself off when the PMIC never appears (720 MHz instead of 1 GHz). Analogue thresholds depend on the board revision. SIM presence is an ADC voltage band, and the bands differ between PCB revisions. A wrong revision setting gives no error, only wrong answers. Software\nucode compiles regexes with REG_NEWLINE by default. In ucode 2026.04.24, unless a regex carries the s flag, ^ and $ match at every line, so an anchored validator accepts \u0026quot;ok\\nevil\u0026quot;. A newline then passed into a shell command line. An audit fixed every validator and sanitiser in the framework and the product layer. Stock sysupgrade refuses backups on a RAM root and still exits 0. On this board the root is always a ramdisk, so \u0026ldquo;Download settings\u0026rdquo; produced an empty file on every build until 2.2.4. Nothing reported an error; a restore test found it. A non-blocking socket is not a reliable one. The serial gateway dropped a TCP connection on EAGAIN. When a peer paused, about 45 KB later the connection closed and the rest of the stream was parsed as AT commands. Bounded queues with UART back-pressure fixed it. The vendor had bugs worth not copying. Its geofence mixed up degree formats and never worked, its power-save setting put the serial transceiver into loopback, and its DNP3 class masks did not map one-to-one. The importer translates these instead of copying them. The build system can drift without telling you. Run through a pipe into a log, ./scripts/feeds update printed \u0026ldquo;failed.\u0026rdquo; while the build script saw exit status 0, and a make defconfig after a feed change once reset a vendor prefix option. A build guard now refuses any build whose .config or feed pins differ from the recorded ones. Overlays never forget. A file copied by hand into /etc is copied up into the persistent store and masks the image\u0026rsquo;s version of it for ever. How the work was organised Discipline mattered more than speed, because every mistake on a unit in the field costs a site visit.\nTwo different bench units. One had a dead PMIC bus and ran at 720 MHz, the other was a healthy older board revision at 1 GHz. Each change ran on both, identified by MAC address before any write. Serial consoles stayed attached, and a small on-unit checker ran a soak test every six hours. Every build is a record. A wrapper numbers each clean build, backs up the images with their checksums and pins, and refuses to build when the configuration or a feed pin has drifted. More than 80 builds have a release-notes entry saying what changed and what was checked on the units. One flash procedure. Checksum, settings backup, upload, verify on the unit, upgrade, then check the slot, the boot counter, the configuration store, the boot log and the cloud links. Always from the backed-up image, never from the build directory. A real management server. A test server ran TR-069, TR-369 (USP), XMPP and STUN, so remote configuration, backup and restore were tested end to end instead of assumed. AI-assisted, human-decided. I did the work with Claude Code: a lead session planned and reviewed, worker agents wrote code and ran bench checks, and a separate session that owns the shared framework reviewed every branch. Builds, flashes, bootloader writes and every product decision waited for my word. Where it ended OS-DHP 2.2.6, built on 27 October, is the final release. It runs on both bench units with every check passing, and it comes with a 236-page user manual, a four-page overview and release notes.\nI offered it to the company that sells the MA-2080X, and they decided not to ship it. That decision was about the product, not the port, and I understand it.\nNot much of the work is lost. Most of the features above were built in the shared dhplab framework and are already used by other products: SMS commands, the serial gateway\u0026rsquo;s back-pressure, signed plugins, the security fixes and the ucode newline audit. The board port, the U-Boot patches and the build records stay in the archive, ready if they are ever needed.\nWhat I would do the same way again Make the recovery path work before the risky write. The SD-card boot was proven before MLO was ever touched, and that is what made the bootloader work calm. One irreversible change per step. OpenWrt first on the old bootloader, the new bootloader later and separately, never both in one unattended boot. Treat \u0026ldquo;exit 0\u0026rdquo; as a claim, not a result. The empty backups, the silent feed failures and the regex anchors all passed every check that only looked at return codes. Test the outcome: restore the backup, diff the configuration, send the bytes. Trust what shipped and what you measure. The vendor board file over the schematic, a measurement over a net name. Write it down as you go. Release notes per build, engineering notes per finding. That record is also what this post was written from. The MA-2080X goes into the cabinet. The things it taught me do not.\n","permalink":"https://pdh0085.github.io/posts/from-linux-3-2-to-openwrt-25-12/","summary":"About seven weeks moving the MA-2080X industrial cellular router off its vendor Linux 3.2 firmware and onto OpenWrt 25.12.5: one irreversible change at a time, feature parity with the vendor firmware, the bugs that failed silently, and why the result will not ship.","title":"From Linux 3.2 to OpenWrt 25.12: Porting the MA-2080X Cellular Router"},{"content":"This started as a quick check: does the new Wi-Fi 7 adapter work on Linux, and what does iperf3 say. The adapter came up in five minutes. The rest of the day went to everything stacked on top of it. To give away the ending, nothing was wrong with the adapter.\nI\u0026rsquo;ve left my wrong conclusions in rather than editing them out. The interesting part of an elimination hunt is usually where it slips, not where it lands.\nThe device under test is an MT7927 (Filogic 380). Host is Ubuntu 26.04 on kernel 7.0.0-31-generic; the other end is an OpenWrt AP running a 3-link MLD (2.4G ch6 20MHz / 5G ch100 160MHz / 6G ch37 320MHz).\nIf 6GHz Isn\u0026rsquo;t There, Look at the Regulatory Domain First lspci saw it, mt7925e bound to it, the interface came up. And not a single 6GHz channel showed up in a scan.\n$ iw reg get global country 00: DFS-UNSET $ iw phy phy0 info | grep 6135 * 6135.0 MHz [37] (disabled) With the domain set to world (00), 6GHz is locked out entirely. One iw reg set KR brought the channels back at 15 dBm, and only then did the AP\u0026rsquo;s 6GHz link appear in the scan. That\u0026rsquo;s the place to look before you start suspecting antennas or drivers.\nThen came the plumbing. The session was remote over SSH, so polkit refused to let me drive NetworkManager, and wired and wireless sat on the same subnet, which made routing pick the wrong one. Specifying a source IP was not enough; the interface has to be pinned as well.\n$ iperf3 -c \u0026lt;server\u0026gt; -B \u0026lt;wifi-ip\u0026gt;%wlp3s0 -t 5 ... wlp3s0 TX delta: 489 MB enp1s0 TX delta: 0 MB Skip that byte-counter check and you will happily report wired throughput as a wireless result. -B \u0026lt;ip\u0026gt; alone changes the source address while the route still goes out the wire.\nThe First Numbers Were Low Because the Driver Wasn\u0026rsquo;t Inbox The first run gave 497 Mbps up and 705 Mbps down against a PHY rate of 2882 Mbps, so roughly 20% efficiency. The wired path from AP to server ran at 2.36 Gbps, so the bottleneck really was on the wireless side. I eliminated TCP multistream, powersave, signal quality and host CPU in turn. Four streams were not faster than one (488 against 497), the average was -37 dBm with tx failed 0, and the retry rate was 2.1%. Congestion control or window sizing would have shown up as a gain on multistream.\nThen modinfo gave me pause.\n$ modinfo mt7925e | head -2 filename: /lib/modules/7.0.0-31-generic/updates/dkms/mt7925e.ko.zst $ dkms status mediatek-mt7927/2.11, 7.0.0-31-generic: installed Not the inbox driver at all, but a vendor DKMS package, and v2.11 dated 2026-04-15 when v2.14 was current. Moving to 2.14 took uplink to 705 Mbps. What actually changed was a transmit power reporting bug: txpower had been frozen at 15.00 dBm in 2.11 and came up to the regulatory limit of 23 dBm in 2.14. That explains why switching the domain from KR to TW, which raised the limit by 8 dB, had moved uplink by nothing at all. The ceiling went up; the actual output never followed.\nDownlink wandered between 637 and 1190 Mbps across the 160MHz runs. With the signal unchanged and only the receive MCS drifting between 8 and 5, that reads as interference, not as a fix. Uplink was the only number that moved for a reason.\nEvery Condition Says 320, the Negotiation Says 160 This is where the day went. Everything I could check pointed at 320MHz.\nCondition Measured AP operating width 320 MHz, center 6105 (actual chandef, not config) AP EHT Operation Channel Width: 320 MHz AP EHT Capabilities 320MHz in 6GHz Supported Regulatory rule (TW) 5945-6425 @320 MHz Adapter capability 320MHz in 6GHz Supported, MCS Map BW=320 Negotiated 160 MHz The kernel left this behind:\nwlp3s0: regulatory prevented using AP config, downgraded I took that as evidence and concluded it was a regulatory problem. Wrong. Reading the source later, here is where the line comes from:\nif (chanreq-\u0026gt;oper.width != ap_chandef-\u0026gt;width || ap_mode != conn-\u0026gt;mode) link_id_info(sdata, link_id, \u0026#34;regulatory prevented using AP config, downgraded\\n\u0026#34;); It prints whenever the final width differs from the AP\u0026rsquo;s, whatever the reason. A message saying \u0026ldquo;regulatory\u0026rdquo; does not make regulatory the culprit. Kernel messages are strings somebody typed, same as any other.\nWhat the Tools Don\u0026rsquo;t Show You To see whether the channel carried something like no 320MHz, I went through iw phy info. Nothing there. So I ruled regulatory out. Also wrong.\nAs it turns out, iw cannot print that flag at all. For channels it only renders disabled, no IR and radar detection, never a width restriction. So I wrote a tool that parses nl80211 directly and looked again, and got the same answer. At the time I concluded that the kernel never exports the flag over nl80211. That was wrong too: nl80211 does put NO_320MHZ into the split wiphy dump, right next to NO_HT40_MINUS and INDOOR_ONLY. So either the two readings below were not as simultaneous as I believed, or my parser missed the attribute. I never pinned down which.\nraw attributes for 5955 MHz: FREQ, MAX_TX_POWER, NO_HT40_MINUS, INDOOR_ONLY, OFFSET (no NO_320MHZ) chan-\u0026gt;flags inside the kernel at the same moment: 0x80220 = NO_320MHZ | INDOOR_ONLY | NO_HT40_MINUS Absent from what I could see in user space, set inside the kernel. \u0026ldquo;I looked with the tool and it wasn\u0026rsquo;t there\u0026rdquo; is not evidence. Whether the tool can see the thing has to be established first. I fell into that twice, once with iw and once with a tool I had written myself.\nGoing Inside If it can\u0026rsquo;t be seen from outside, look from inside. ftrace first, to catch what mac80211 decided.\ndrv_add_chanctx: ap(6135MHz, width:13, center 6105) \u0026lt;- AP parsed as 320MHz chandef(6135MHz, width:5, center 6185) \u0026lt;- actually used, 160MHz Width 13 is NL80211_CHAN_WIDTH_320, 5 is 160MHz. The parse was correct and something downstream cut it. Next, a kprobe on the return values of the decision functions.\ncfg80211_chandef_valid (320MHz) ret=1 valid cfg80211_chandef_usable(320MHz) ret=0 rejected And there I stalled. The 320MHz branch of _cfg80211_chandef_usable() has only a handful of ways to fail, and every value I had measured satisfied the passing conditions. Observation and source disagreed.\nSo I disassembled the module, took addresses for each branch inside the function, and put kprobes on them.\nbr320 -\u0026gt; bandok -\u0026gt; bittest -\u0026gt; found -\u0026gt; retfalse subchannel loop: freq=5955000 flags=0x80220 prohib=0x80041 -\u0026gt; no pass intersection 0x80000 = IEEE80211_CHAN_NO_320MHZ (BIT 19) It dies on 5955 MHz, the first subchannel of the 320MHz block. cfg80211 puts NO_320MHZ into the prohibited mask when checking a 320MHz width, the channel carries that bit, and it returns false immediately. mac80211 then drops one step to 160MHz and prints the misleading line from earlier.\nCulprit found: every 6GHz channel had NO_320MHZ set. Except that nothing in the regulatory rules or the driver\u0026rsquo;s channel table sets it.\nThe Culprit Was CLC, in the Firmware One path left. The mt7925 family has a feature called CLC, Country Location Control: the driver reads a per-country restriction table carried in the firmware and overwrites channel flags with it. There\u0026rsquo;s a module parameter to turn it off.\nRead the source and CLC looks like it only sets NO_EHT (BIT 20) and DISABLED (BIT 0), and in upstream mt7925 its channel loop really does write only those two. The bits didn\u0026rsquo;t match, so I decided it wasn\u0026rsquo;t CLC. That was my third wrong call: whatever path put NO_320MHZ (BIT 19) on the channels in the DKMS driver I was running, it went away with CLC.\n$ modprobe mt7925_common disable_clc=1 channel 37 (6135 MHz), width: 320 MHz, center1: 6105 MHz rx bitrate: 3459.3 MBit/s 320MHz EHT-MCS 8 EHT-NSS 2 One line, and it opened. Regulatory domain unchanged, AP config unchanged.\nMeasurement 160MHz 320MHz TCP uplink 705 Mbps 1080 Mbps TCP uplink, 4 streams 488 Mbps 1690 Mbps TCP downlink 637 Mbps 1380 Mbps UDP downlink loss 21% 0.06% The loss figure is the one that stands out. It had simply been unable to push the traffic through the width it had.\nThis needs stating plainly: disable_clc=1 turns off a regulatory compliance mechanism. It belongs in lab verification only, and in a real deployment you have to confirm separately that the region permits 320MHz on 6GHz. Every 320MHz number above was taken under that condition.\nMLO Had the Same Root The AP runs a 3-link MLD normally, and the STA associated on 6GHz alone. I found where the driver declares its number of simultaneous links as one, changed it, and nothing happened at all. So I read the gate above it with a kprobe.\nchip_cap = 0x0000000000000000 set bits: (none) chip_cap is filled from the MT_NIC_CAP_CHIP_CAP TLV the firmware sends. On MT7927 it arrives empty, and every capability gate downstream stays shut.\nBit Capability Effect BIT(4) 11D_EN regulatory goes through CLC instead of regulatory_hint() BIT(8) MLO_EN WIPHY_FLAG_SUPPORTS_MLO never gets set BIT(9) MLO_EML_EN EML disabled The line I had edited sits below that gate, so it was dead code that never ran. No wonder changing it did nothing.\nForcing the gate open brought all three links up, each with its own local address, and the AP\u0026rsquo;s debugfs agreed.\nwlp3s0: [link 0] local 36:2e:4a:xx:xx:xx \u0026lt;- AP 06:0c:43:xx:xx:xx (2.4GHz) wlp3s0: [link 1] local e6:e0:10:xx:xx:xx \u0026lt;- AP 42:0c:43:xx:xx:xx (5GHz) wlp3s0: [link 2] local 6a:e0:6c:xx:xx:xx \u0026lt;- AP 00:0c:43:xx:xx:xx (6GHz, assoc) The datapath was another matter. Uplink rose to 1330 Mbps while downlink collapsed from 1380 to 371 Mbps and retries climbed to 718. MT6639 shares RF1 between 5GHz and 6GHz, so binding both links at once appears to tangle the receive path. That matches upstream\u0026rsquo;s own conditions for bringing MLO back, which list further fixes this driver doesn\u0026rsquo;t have yet. Opening the capability bits was never going to be enough on its own.\nWhat I Took Away Nothing was wrong with the adapter. The MT7927 hardware is capable of both 320MHz and MLO, and the code for both is present in the kernel and the driver.\nWhat blocked them was what the firmware reported. 320MHz was blocked because, with CLC on, every channel ended up carrying NO_320MHZ; MLO was blocked because chip_cap arrived as zero and shut the capability gates. Both are at the firmware level, and they share a root.\nAnd none of that showed up in my user-space tools. Not in iw, which cannot print the flag, and not in the nl80211 tool I wrote myself, which should have seen it and didn\u0026rsquo;t. Until ftrace and kprobe let me look inside the kernel, I was stuck at \u0026ldquo;the AP, the regulator and the adapter all agree, so why doesn\u0026rsquo;t it work\u0026rdquo;.\nCollecting the wrong calls:\nWhat I concluded What was true Driver doesn\u0026rsquo;t implement 320MHz It does, and it wasn\u0026rsquo;t part of this decision Regulatory domain problem Fooled by the message text; the rules were innocent No restriction flag on the channel iw can\u0026rsquo;t print it, and my own dump missed it The kernel doesn\u0026rsquo;t export the flag It does, in the split wiphy dump Not CLC, the bits don\u0026rsquo;t match CLC was the culprit AP service died from FD exhaustion My own routing change caused it Five of the six were cases of believing I had checked something when I hadn\u0026rsquo;t. Elimination only works when each candidate can actually be observed, and the fact that my instruments couldn\u0026rsquo;t observe this one was the last thing I learned, not the first. Next time I plan to establish what a tool is able to print before I trust what it doesn\u0026rsquo;t.\nThe whole reproduction fits in these few lines.\n# open 6GHz sudo iw reg set TW # open 320MHz (lab only): reload the driver with CLC off sudo modprobe -r mt7925e mt7925_common sudo modprobe mt7925_common disable_clc=1 sudo modprobe mt7925e # force the measurement onto wireless iperf3 -c \u0026lt;server\u0026gt; -B \u0026lt;wifi-ip\u0026gt;%wlp3s0 -t 10 -P 4 # look inside the kernel echo \u0026#39;p:usa cfg80211_chandef_usable width=+8($arg2):u32 prohib=$arg3:x32\u0026#39; \\ | sudo tee /sys/kernel/tracing/kprobe_events echo 1 | sudo tee /sys/kernel/tracing/events/kprobes/usa/enable Test setup was an MT7927 (Filogic 380) on Ubuntu 26.04 with kernel 7.0.0-31-generic and mediatek-mt7927 DKMS 2.14-6, against an OpenWrt AP on kernel 6.18 running 3-link MLO. Every figure is a single 10-second run, and downlink drifted between 637 and 1390 Mbps over the session with interference.\n","permalink":"https://pdh0085.github.io/posts/chasing-320mhz-into-the-kernel/","summary":"The AP, the regulatory rules and the adapter all said 320MHz, and the negotiation still stopped at 160. The kernel message blamed regulatory; every tool I had said there was no restriction on the channel. Neither was true. The culprit was a country restriction table living in the firmware, and the flag it led to never showed up in my user-space tools.","title":"Chasing 320MHz Into the Kernel"},{"content":"We build a commercial router on an MT7628 (MIPS 24Kc, 8 MB flash, 64 MB RAM) running OpenWrt 24.10. Its web UI had lived on LuCI for a long time, and every page navigation visibly stuttered. This time we removed LuCI from the image entirely and replaced it with a browser runtime we wrote ourselves (ls-webui). On the server side there is no CGI, no dispatcher, no templates. uhttpd serves static files and relays /ubus JSON-RPC, and that is all it does.\nThe short version: the login screen went from 459 ms to 48 ms, the fixed cost of a page navigation from 368 ms to 6 ms (then 0 from cache), and not a single line of the 57 existing views was modified.\nThis post is a record of what we measured, why we chose this structure, and where the traps were.\n1. Catching the Culprit by Measurement \u0026ldquo;LuCI is slow\u0026rdquo; is a common sentiment, but until you measure you don\u0026rsquo;t know exactly what is slow. On real hardware, after subtracting the TLS handshake (128 ms), the pure server time came out as:\nRequest Server time Static file ~2–10 ms /ubus JSON-RPC ~5 ms /cgi-bin/luci/ 430 ms (warm) / 3,400 ms (cold) uhttpd itself is innocent. Static files are fast, and uhttpd\u0026rsquo;s built-in /ubus relay is fast. The only slow thing is the LuCI dispatcher path. The dispatcher forks on every page navigation, re-parses all of menu.d/*.json and acl.d/*.json, and only then produces its first byte. On a 580 MHz single-core MIPS, that cost repeats on every request.\nSo the fix was not \u0026ldquo;optimize LuCI.\u0026rdquo; It was to remove the forking path altogether.\nThe measurement itself had one trap. curl\u0026rsquo;s --next does not reuse connections with this combination (uhttpd + TLS); every request shows num_connects=1, so a 125 ms handshake swallows every number. We had to hold the connection open ourselves with Python\u0026rsquo;s http.client before the server time became visible.\n2. The Structure: Remove Code from the Server Browser ──HTTPS──► uhttpd (no forks) ├── / → index.html (static shell) ├── /ls-static/* → runtime JS·CSS·menu.json·i18n (static) ├── /ubus → in-process JSON-RPC ─► rpcd ─► uci/file/session/… └── /cgi-bin/cgi-* → cgi-io only (firmware upload · backup download) The key observation: LuCI\u0026rsquo;s modern views are already client-side rendered. JavaScript runs in the browser and fetches data over ubus. What server-side LuCI actually did was assemble the menu tree, check ACLs, and generate the initial HTML shell, all of which can be precomputed or moved to the client.\nThe HTML shell becomes one static file. The menu tree is baked once at boot: menu.d/*.json is merged into /www/ls-static/menu.json, written only when the content changed to avoid overlay wear. ACLs and sessions were always rpcd\u0026rsquo;s and uhttpd\u0026rsquo;s job anyway. uhttpd\u0026rsquo;s /ubus relay checks permissions against the session token, and that layer survives with LuCI gone. For i18n, instead of converting .po to .lmo (mmap\u0026rsquo;d by the dispatcher), we convert .po to JSON and the browser fetches one file per language. The only thing left on CGI is cgi-io. Firmware image uploads and backup downloads are too big to ride /ubus as JSON+base64, so exactly two file-transfer CGIs remain.\n3. A Compatibility Layer That Leaves 57 Views Untouched This migration was feasible for one reason. When we exhaustively surveyed which LuCI client APIs the views actually use, it came to 43 symbols (form.*, ui.*, uci.*, rpc.*, fs.*, L.*). Write a new runtime that preserves the install paths and the signatures of those 43 symbols, and the 57 existing views plus the theme run unmodified.\nWe didn\u0026rsquo;t even need the heavyweight modules like the 125 KB network.js. The network.* the views call turned out to be a ubus object name, not a client module.\nThere was a bonus, too. We made ubus calls issued in the same synchronous block coalesce in a microtask and go out as one HTTP request, so the status page\u0026rsquo;s 6 calls became a single round trip (280 ms individually, 72 ms batched). That optimization was structurally impossible in the dispatcher era.\n4. Sessions: No Cookies, So No CSRF Session handling actually got simpler. We use no cookies. The session id travels inside the JSON-RPC payload and uhttpd authenticates with it. Since no ambient credentials ride along with requests, CSRF as a problem simply does not arise.\nInstead, chasing a real-world \u0026ldquo;I keep getting logged out\u0026rdquo; symptom turned up two causes:\nNobody was refreshing the session. rpcd resets the TTL every time a session is used, but leave a page open untouched and nothing touches the session, so an hour later you get kicked mid-edit. We now send a keepalive (session.get) every third of the session lifetime. Mistaking -32002 for expiry. uhttpd answers \u0026ldquo;session expired\u0026rdquo; and \u0026ldquo;this call is not permitted\u0026rdquo; with the same -32002 Access denied. Open a page that happens to include one call missing from the ACL, and the client was terminating a perfectly healthy session by itself. Now -32002 only triggers a session liveness probe, and only the probe\u0026rsquo;s result logs you out. 5. The Minefield: What Silently Disappears When LuCI Goes The real cost of this migration wasn\u0026rsquo;t writing code. It was discovering the things LuCI had been providing implicitly, all of which share one property: they vanish without any error.\nThe luci ubus object belongs to luci-base, not rpcd-mod-luci. The name suggests the latter; it isn\u0026rsquo;t. Remove luci-base and six methods disappear: setPassword (the password-change page!), getConntrackList, getTimezones, getInitList, setInitAction, setLocaltime. We reimplemented exactly those six as a ucode rpcd plugin. The switch page\u0026rsquo;s backend has the same root. getSwconfigFeatures/getSwconfigPortState are luci-base\u0026rsquo;s too, so with it gone there was no way to read hardware state from a swconfig switch. We added a new ubus switch object via an rpcd script. rpcd\u0026rsquo;s uci.commit requires the config argument (missing it fails with status 2). The LuCI runtime had been supplying it silently, so we didn\u0026rsquo;t know, and for a while Save \u0026amp; Apply on every page was committing nothing. You must fetch the changed-config list from uci.changes and commit each one. Same for revert. file.stat requires the list permission, not read. luci-base\u0026rsquo;s ACL had been quietly slipping in \u0026quot;/\u0026quot;: [\u0026quot;list\u0026quot;]; omit it and every file-existence check dies. Environment values like L.env.cgi_base were injected by the dispatcher. They became empty strings, and firmware upload, backup download, and restore all returned 404: precisely the three features we had kept cgi-io for. 6. \u0026ldquo;Renders\u0026rdquo; ≠ \u0026ldquo;Works\u0026rdquo; The most expensive lesson. We confirmed all 57 views render and thought we were done; exhaustive on-hardware verification then produced ten bugs in the save/apply/upload paths. The uci.commit and cgi_base items above are the poster children. The screens were perfect while Save \u0026amp; Apply was a no-op.\nA render sweep only validates the read path. Write paths (save/apply/rollback), file transfers, and the \u0026ldquo;apply cuts my connection\u0026rdquo; rollback scenario are all separate paths that had to be exercised on real hardware. In particular, an apply that changes the device\u0026rsquo;s address makes rollback confirmation structurally impossible: the confirm goes to a session on the old address, which doesn\u0026rsquo;t exist at the new one. We solved that by detecting it up front and offering the user an unprotected apply.\n7. Results A/B measured on two identical units (TLS handshake excluded, connections reused):\nLuCI ls-webui Login screen 459 ms 48 ms Per-navigation fixed cost 368 ms every time 6 ms, then 0 from cache Status page, 6 data calls — batched 72 ms (280 ms individually) First-visit transfer 313 KB 267 KB 52 concurrent requests 3 ucode forks + queueing 0 forks /www size 1,229 KB 778 KB Image size — −315 KB compressed On 8 MB of flash, 315 KB is a number you can feel. We deliberately make no claim about steady-state RAM. The measurement conditions differed enough that the comparison would be murky, and the win of this architecture is \u0026ldquo;no fork per request,\u0026rdquo; not resident memory.\n8. When This Approach Applies It\u0026rsquo;s only fair to state the preconditions that made this work:\nThe views were already client-side rendered. With a pile of legacy server-template views, a compatibility layer wouldn\u0026rsquo;t have cut it. Every server capability we needed already existed in rpcd/ubus. What didn\u0026rsquo;t (switch state, etc.) we added as rpcd script plugins, which is work you\u0026rsquo;d have to do with LuCI present anyway. We control the UI. This is a product image with a closed set of views. If your users must be able to install arbitrary luci-app-* packages, this is a different conversation. Conversely, if you\u0026rsquo;re building an OpenWrt product with its own UI on a low-end SoC, the dispatcher\u0026rsquo;s fork cost was the single largest performance budget we could reclaim without touching the hardware. And most of that work wasn\u0026rsquo;t writing code. It was making a list of everything LuCI had quietly been doing for us.\n","permalink":"https://pdh0085.github.io/posts/openwrt-webui-without-luci/","summary":"On an MT7628 router (580 MHz MIPS, 8 MB flash), the LuCI dispatcher was charging 430 ms per page navigation. We removed LuCI from the image entirely and rewrote the runtime on nothing but static files and /ubus JSON-RPC. Login went from 459 ms to 48 ms, and all 57 existing views run unmodified.","title":"What Dropping LuCI Bought Us"},{"content":" It Ended with 3.0.0 The results fit in one paragraph. Our Yocto-based firmware became OpenWrt 25.12; cellular and GNSS moved to ModemManager; boot became a squashfs on FAT plus a fallback ladder; the web UI became a LuCI-based app of our own. The 3.0.0 production release shipped on July 15, 2026.\nThis final post is a retrospective on the way we worked rather than on the results. The thing that consumed the most time in this project was not any difficult bug. It was wrong certainty: incorrect facts that had been written down as \u0026ldquo;already confirmed.\u0026rdquo; A record like that narrows the search space of the next person, who is usually yourself a few weeks later. Here are the four beliefs this series disproved.\nWrong Belief 1: \u0026ldquo;Verified by GPIO Readback\u0026rdquo; This one is from the serial post. A readback only confirms that the intended value landed in the register. It says nothing about what that value means to the hardware. In reality the code had SER_MODE0 and SER_MODE2 swapped, so requesting RS-232 actually selected RS-485 half-duplex. But the document said \u0026ldquo;verified,\u0026rdquo; and that single word kept everyone from re-reading the software. In its place a hardware conclusion took root: \u0026ldquo;SP336 TX charge pump dead.\u0026rdquo;\nWrong Belief 2: Plausible Causality There was a comment: \u0026ldquo;powering the modem early makes it contend with Wi-Fi enumeration on the shared EHCI bus.\u0026rdquo; Physically plausible, and it even matched a symptom observed long ago. Except Wi-Fi enumerates about 3 seconds into kernel boot, before init scripts even exist. A sentence that welds an observation to a cause loses the observation over time; only the cause survives. That one comment pinned the modem power script at START=99 and pushed the modem\u0026rsquo;s USB appearance out to about 162 seconds. After moving it, about 50.\nWrong Belief 3: The Metric That Looks Good A record claimed \u0026ldquo;this work freed about 147 MB of memory.\u0026rdquo; What actually moved was peak boot RAM (initmem freed went from 67456K to 1564K), while steady-state MemAvailable stayed essentially unchanged at roughly 116–134 MB. Those 67 MB were being returned by the kernel during boot anyway. The most common lie in optimization write-ups is not inventing numbers. It is choosing the metric that looks improved.\nWrong Belief 4: The Failure Record Nobody Retried There was a record that the EC25-AU fails on one domestic carrier\u0026rsquo;s network with sim-missing. Retried on a shipping board with a real SIM, it did not reproduce: the modem registered, got an address over QMI, and passed data with 0% ping loss. Failure records outlive success records, because nobody ever tries again.\nFive Methods That Actually Worked The four cases share one thing: progress happened only when the evidence came from what the hardware was saying right now, not from documents, comments, or memory.\nRead the answer off a working system. The ACPI RSDP address and the correct RS-232 GPIO values were both lifted straight from the old Yocto firmware booting happily on the bench. Faster than re-reading schematics. Deliberately make the suspected condition worse. The modem-power hypothesis was disproved by repeating the test under three conditions: idle, heavy CPU load, and during a live Wi-Fi firmware upload. All three enumerated cleanly in 9–10 seconds with zero errors. Verify at the far end. An interface holding an IP address is not proof of connectivity (the modem post), and a successful file write is not proof the configuration reached the daemon (the routing post). Break it on purpose. Until we physically pulled 12V in the middle of a sysupgrade, the fallback design was just a plausible story. Log close to the hardware. The early-boot /init and the init-script profiler both write to /dev/kmsg, so with a serial console you see everything even when networking is dead. How We Write Documents Now Every fact carries how we know it. Not \u0026ldquo;verified\u0026rdquo; but \u0026ldquo;confirmed on a real board with this command.\u0026rdquo; The rule goes down to a single connector name (a document said CON8; it was actually CON6). Items proven wrong are not deleted. They stay, together with the reason they were overturned. Delete them and the next person rebuilds the same hypothesis from scratch. The rule \u0026ldquo;never put logic where the field can\u0026rsquo;t update it\u0026rdquo; (from the uci-defaults post) applies to documents too. A document nobody reads might as well not exist. What Remains Boot still takes about 190 seconds. We closed one large hole; the rest of the profile (S95frr at about 30 seconds, among others) is still uninvestigated. TR-069 (icwmp) has never been tested against a real ACS. Two backends the UI references but that do not exist (battery-mgrd, xoleds) are still outstanding. Leaving the unfinished list in plain sight is part of the record too. The thing I did most often on this project was not fixing code. It was taking something that someone, usually me, had written down as already confirmed, and confirming it again in front of the hardware.\n","permalink":"https://pdh0085.github.io/posts/hardware-is-the-truth/","summary":"The port ended with the 3.0.0 release. Looking back, the most expensive thing was never a hard bug. It was wrong records like \u0026ldquo;freed about 147 MB\u0026rdquo; and \u0026ldquo;verified\u0026rdquo;. The four beliefs this series disproved, and the habits that replaced them.","title":"Epilogue: Hardware Is the Truth"},{"content":" What We Built (Briefly) We removed the legacy vendor UI and built our own app plus our own theme on top of LuCI. The theme is UniFi-style: an icon rail with a pinned panel, a unified top band, an account menu, an off-canvas drawer on mobile, and a slide-over shell. To meet WCAG contrast requirements we re-derived the color token ramps from scratch. The pages cover uplink/failover, SIM and APN, modem status, serial ports, routing, data usage, and so on.\nThat\u0026rsquo;s it for the screens. The real content of this post is the traps we hit along the way.\nTrap 1: There Is No Way to Pass a Secret One page needed to accept a server authentication token and hand it to a backend helper for storage. Walk through the paths from browser to backend one by one:\nargv? No. It shows up verbatim in ps. stdin? LuCI\u0026rsquo;s fs.exec has no stdin. And the third argument looks like it might be stdin, but it is actually an environment table. Pass it a string and if (!L.isObject(env)) env = null silently discards it. That one kept me staring at \u0026ldquo;token is empty\u0026rdquo; errors for quite a while. Environment variables? The backend refuses them. rpcd rejects caller-supplied env on session (ACL-checked) calls: when both sid and env are present, the call fails with PERMISSION_DENIED. Which is the right security decision, because otherwise a caller could change the behavior of a command the ACL had approved. All three paths blocked. The solution was a staging file: the page writes the value with fs.write into a 0700 directory (the ACL permits exactly that path and nothing else), and the helper script moves it into a 0600 token file. The value never appears in the process list or in a URL.\n\u0026ldquo;How do I pass a secret\u0026rdquo; turned out not to be a UI question at all. It\u0026rsquo;s a privilege-boundary question, and the blocked paths were mostly blocked for good reasons.\nTrap 2: Saving Deletes My Own UI I had appended a token input and a payload preview into the form\u0026rsquo;s DOM, and they disappeared on every Save \u0026amp; Apply. The cause is simple: LuCI\u0026rsquo;s form.Map re-renders itself on save, and anything appended directly inside it is gone on the next render.\nThe fix was structural: return the custom elements as siblings of the map instead of appending into it. In a framework with declarative rendering, anything you attach to the DOM imperatively lives exactly until the next render.\nTrap 3: The Save Worked, but the Screen Says It Failed Pressing Save \u0026amp; Apply produced an error, yet checking the config showed the values had been saved correctly.\nThe cause: m.save() had already committed everything, so the delta to apply was empty, and calling uci.apply() on an empty delta makes ubus throw NO_DATA (code 5). A perfectly normal situation, rendered on screen as \u0026ldquo;apply failed.\u0026rdquo; In this case NO_DATA has to be recognized and swallowed.\nAs a bonus, uci.apply() doesn\u0026rsquo;t touch LuCI\u0026rsquo;s own change indicator, so the navigation bar sat frozen at \u0026ldquo;Unsaved Changes: 1.\u0026rdquo; After the commit you have to call ui.changes.setIndicator(0) yourself.\nJust as \u0026ldquo;no error\u0026rdquo; is not the same as \u0026ldquo;success,\u0026rdquo; an error is not always a failure.\nBonus: Data Usage Grows by 4 GiB per Reboot Once the data usage page was in place, we noticed the statistics jumped by about 4 GiB every time the board rebooted.\nThe symptom: vnstat totals leapt by roughly 4 GiB on every reboot or reconnect. The decisive clue was in the database. One five-minute row recorded rx ≈ 4294965968, almost exactly 2^32, while the kernel counters for the same window showed a few hundred KB. The byte counters on wwan0 reset to zero on every reboot/reconnect, and vnstat interprets that decrease as a 32-bit wraparound, adding 2^32 = 4.00 GiB.\nOur first fix was forcing 64bitInterfaceCounters 1 (the default is -2, auto), shipped in two places: uci-defaults for new and factory-reset boards, and a hotplug script for boards already in the field, because uci-defaults never runs again on a config-preserving upgrade. That is the exact lesson from an earlier post in this series. We recorded that fix as verified, and it was later disproved: the setting does not stop vnstat from treating a reset as a 32-bit wrap. What fixed it was keeping vnstat\u0026rsquo;s working database on tmpfs and the long-term totals in a separate ledger. One last thing: history that was already polluted only goes away when the user resets the usage statistics once. A fix only stops new inflation; the past stays as it is.\nSmall Things The band display showed values like enum 8. The daemon was already parsing AT+QENG=\u0026quot;servingcell\u0026quot; and reporting real band numbers (3 = B3, 8 = B8), but the LuCI-side decoder was re-interpreting those numbers through an old Qualcomm/QMI NAS enum table. When the data source changes, the display layer has to change with it.\nWe also found two backends referenced by the UI that don\u0026rsquo;t exist at all: battery-mgrd behind the battery widget and xoleds behind the LED toggle. With no package present, they silently do nothing. A widget that fails leaves no trace, which is exactly why it survives so long.\nWhat Automated Verification Taught Us We automated the screen verification with Playwright and lost time to three things we didn\u0026rsquo;t know:\nSetting inputs via .value or page.fill() does not trigger LuCI\u0026rsquo;s change tracking. Only real simulated keystrokes (pressSequentially) are recognized, and \u0026lt;select\u0026gt; elements need an explicit dispatchEvent('change'). A plain \u0026ldquo;Save\u0026rdquo; only accumulates session deltas. What\u0026rsquo;s actually on disk can only be verified after Save \u0026amp; Apply. On a 400 MHz board, unless you poll until \u0026ldquo;Loading view…\u0026rdquo; disappears, the status pages screenshot as blank. Lessons A framework\u0026rsquo;s security constraints are design inputs, not obstacles to route around. The blocked paths are usually blocked for a reason. DOM attached imperatively to a declarative UI lives for exactly one render. Counter bugs accumulate. Fixing the bug doesn\u0026rsquo;t fix the past, and the later the discovery, the higher the price. The path that reaches new boards and the path that reaches fielded boards are different. A fix isn\u0026rsquo;t done until it covers both. ","permalink":"https://pdh0085.github.io/posts/rebuilding-the-web-ui/","summary":"We rebuilt the LTE572W\u0026rsquo;s web UI on top of LuCI. The screens themselves are the short part of the story. The real content is a secret value with all three delivery paths blocked, custom UI that vanished on every save, and a counter bug that inflated data usage by exactly 2^32 bytes (4 GiB) per reboot.","title":"Rebuilding the Web UI on LuCI"},{"content":" The Symptom This product has routing pages for RIP, OSPF, and BGP. Hit save and it saves, no errors. But open vtysh and the routing daemons know nothing.\nI split the check into three steps: save in the UI, then inspect the file contents, then inspect the actual running-config. Steps one and two succeeded. Only step three was empty. A successful save proves nothing about arrival.\nThe Cause: The Moment frr.conf Exists The pages were writing to /etc/frr/{ospfd,ripd,bgpd}.conf. The problem is that FRR\u0026rsquo;s startup script, frrcommon.sh, switches to integrated-config mode the moment /etc/frr/frr.conf exists:\ndaemon_prep(): [ -r \u0026#34;$C_PATH/frr.conf\u0026#34; ] \u0026amp;\u0026amp; return 0 # per-daemon .conf never prepared or used vtysh_b(): [ -r \u0026#34;$C_PATH/frr.conf\u0026#34; ] || return 0 # pushes frr.conf into every daemon And this board had shipped with that file from the factory. Which means the pages had spent years dutifully writing to a file that nobody read. The reason OSPF had never once been proven end-to-end wasn\u0026rsquo;t the daemons. The writes were going into thin air.\nDeciding Who Owns the File The fix wasn\u0026rsquo;t about patching a few fields. It was about deciding ownership.\n/etc/config/frr (UCI) → frr-gen → /etc/frr/frr.conf → FRR │ └─ vtysh -C dry-run gate The web pages become structured forms over UCI instead of raw file editors, and a generator, frr-gen, renders frr.conf itself (its init script runs at START=94, one slot ahead of FRR\u0026rsquo;s S95). Five design decisions:\nDry-run parse with vtysh -C before installing. A single syntax error takes down the entire routing stack on the next restart. If the config is rejected, the previous one keeps running and the page says so. Exit codes as a contract. 0 = new config installed (restart), 2 = no change (do NOT restart, because a pointless restart tears down adjacencies), 1 = rejected. Without a distinct \u0026ldquo;no change\u0026rdquo; outcome, every press of the save button shakes the routing. Keep an escape hatch. Any FRR syntax the schema can\u0026rsquo;t model is emitted verbatim from per-section raw lists. FRR\u0026rsquo;s configuration surface is wider than any schema; without this, a UCI frontend is a feature regression. Make ownership explicit. UCI is the sole owner of frr.conf. A single setting, frr.global.managed='0', hands ownership back to a human, and the pages then show a \u0026ldquo;manual mode\u0026rdquo; banner. Don\u0026rsquo;t pretend to be the owner when you\u0026rsquo;re not. Never delete the existing file. If a hand-written frr.conf already exists, it gets imported wholesale into frr.global.raw, with the original preserved as frr.conf.pre-uci. The flock 1000 Trap frr restart takes tens of seconds on this board, far past rpcd\u0026rsquo;s exec timeout, so LuCI\u0026rsquo;s Save \u0026amp; Apply dies with an XHR timeout. So I detached the restart. After which every subsequent start/reload hung forever.\nThe cause was procd. Its procd.sh takes a per-service lock with exec 1000\u0026gt;...; flock 1000, and fd 1000 has no close-on-exec. The detached process inherits that fd, and then watchfrr, mgmtd, zebra, and ospfd inherit it in turn. The routing daemons hold our service\u0026rsquo;s lock for as long as FRR runs. The only fix is closing the fd at spawn time:\n( exec 1000\u0026gt;\u0026amp;- ; setsid /etc/init.d/frr restart \u0026lt;/dev/null \u0026gt;/dev/null 2\u0026gt;\u0026amp;1 \u0026amp; ) \u0026amp; I hit the same trap again in a Wi-Fi reapply script. On this system, \u0026ldquo;detached execution\u0026rdquo; now implies \u0026ldquo;fd cleanup\u0026rdquo; as a rule.\nVerification Enable OSPF in the UI and it flows through uci, the generator, and frr.conf; the running-config shows router ospf with the router-id and networks.\nvtysh -c \u0026#39;show running-config\u0026#39; | grep -A5 \u0026#39;router ospf\u0026#39; vtysh -c \u0026#39;show ip ospf interface br-lan\u0026#39; show ip ospf interface shows br-lan in area 0 as No Hellos (Passive interface). This was the first time on this board that routing configured from the UI verifiably reached FRR. One small detail: in FRR 10, passive-interface X is deprecated (it isn\u0026rsquo;t VRF-aware), so the generator emits the per-interface ip ospf passive form instead. The generated file and the running-config need to match character for character, so the next person never has to wonder which one to trust.\nLessons The first question when building a configuration UI isn\u0026rsquo;t \u0026ldquo;which fields do we expose,\u0026rdquo; it\u0026rsquo;s \u0026ldquo;who owns this file.\u0026rdquo; After that comes the tooling: a generator without validation (a dry run) and no-change detection is a dangerous tool, and a schema-based UI needs an escape hatch, because without one users route around the UI and the ownership contract breaks right there. And finally: \u0026ldquo;saved\u0026rdquo; is not \u0026ldquo;applied,\u0026rdquo; and \u0026ldquo;applied\u0026rdquo; is not \u0026ldquo;working.\u0026rdquo; Always verify at the far end.\n","permalink":"https://pdh0085.github.io/posts/the-config-file-nobody-read/","summary":"Saving OSPF settings in the web UI succeeded without a single error, and the routing daemons never heard about any of it, because the file the pages wrote to was never read by anyone. This is the story of rebuilding that pipeline on UCI, and of a detached restart that inherited fd 1000 and froze every start/reload forever.","title":"The Config File Nobody Read"},{"content":" Background The LTE572W has an industrial serial port. One UART (ttyS0) runs through an SP336 transceiver out to a DB9 connector, and the line mode is selected by three GPIOs (SER_MODE0/1/2). The SP336 datasheet\u0026rsquo;s mode table looks like this:\nMode MODE2/1/0 RS-232 001 RS-485/422 full duplex 101 RS-485 half duplex 100 Sleep 110 One prerequisite worth noting: to see these GPIOs at all, the kernel needs CONFIG_LPC_SCH. Without it there is no error; the sch_gpio chip simply never appears. That alone was one trap along the way.\nThe Symptom Software says the port is in rs232 mode. Reading the GPIOs back returns exactly the values we wrote. And yet no RS-232 levels come out of the pins.\nThe Existing Conclusions This symptom already had a history. The internal documentation had closed it out as a hardware failure: \u0026ldquo;the SP336\u0026rsquo;s TX charge pump is dead.\u0026rdquo; One piece of evidence was the observation that a DB9 pin that should have been an output carried no signal. But this board\u0026rsquo;s DB9 layout is non-standard, and that pin is actually an input (CTS), not an output. An input pin sitting at 0 V is normal. What had been read as proof of a failure was, in fact, correct behavior. On top of that, a loopback test had returned zero bytes of RX, which was being blamed on flow control on the PC side. Both explanations were plausible, and both were wrong.\nI believed that document too, and spent a while staring only at the hardware. When wrong conclusions stack up two layers deep, they narrow the search space in exactly the wrong direction.\nComparing Against a Known-Good System On this same board, the Yocto firmware produces RS-232 just fine. Which means there is one question worth asking: what are the GPIOs set to then?\nKnown-good Yocto RS-232 boot: three mode GPIOs = 0/0/1 Our OpenWrt: three mode GPIOs = 1/0/0 Completely different. Yet our code insisted it had written the requested values, and readback agreed. So what was wrong wasn\u0026rsquo;t the values. It was the interpretation of the values.\nThe Root Cause The code had its bit-to-pin mapping inverted. The mapping the code assumed and the actual board wiring were swapped on two of the signal lines, SER_MODE0 and SER_MODE2, which we confirmed against the schematic. So a request for rs232 (mode 001) actually put the chip into mode 100: RS-485 half duplex. With the SP336 sitting in RS-485 half duplex, of course it produced no RS-232 levels. That is what made it look like a dead charge pump.\nFixing that one mapping line cleared three unresolved items at once. The \u0026ldquo;dead charge pump\u0026rdquo;: the chip was healthy, and the port had simply never been in RS-232 mode. The zero-byte loopback was not a PC flow-control problem, same cause. And a dry-contact test that had been logged as \u0026ldquo;failed\u0026rdquo;: same cause again. When a single root cause explains three open issues simultaneously, that is a good sign you have actually found it.\nWhat \u0026ldquo;Verified\u0026rdquo; Really Meant So why did nobody know? An earlier comment in the code read: \u0026ldquo;verified by GPIO readback.\u0026rdquo;\nReadback only confirms that the value you intended landed in the register. It says nothing about what that value means in hardware. That comment used the word \u0026ldquo;verified\u0026rdquo; to seal in an unverified assumption, and it sent the next person (me) in the wrong direction more than once.\nA Side Story: The Kernel Patch That Did Nothing From the same serial work, I also inherited an RS-485 kernel patch, and on inspection it was doing nothing at all. The patch installed two callbacks in a setup function, but the probe code called the common initialization function on the very next line, and that function reassigned the same two pointers, plus two more the patch had missed. Everything the patch wrote was always overwritten. With the patch removed, a TIOCGRS485/TIOCSRS485 prober confirmed RS-485 still worked, so the patch was deleted. Same lesson: \u0026ldquo;there is a patch for it, so it must be working\u0026rdquo; is not verification either.\nOne last note. The serial daemon (serialgw) that owns this port reads /sys/class/tty/console/active and refuses to open whatever the system console device is. In an earlier part of this series, ModemManager probed the console UART and wrecked the console. Once was enough.\nLessons Readback is not verification. You have to observe the result in hardware, either an actual signal or a comparison against a known-good system. If another firmware works correctly on the same board, it is the most accurate reference document you have. Dumping and diffing GPIO state was faster than re-reading the documentation. A wrong conclusion does not stay where it was written. It enters the documentation and narrows the next person\u0026rsquo;s search space. Because of one line that said \u0026ldquo;charge pump failure,\u0026rdquo; nobody looked at the software side again. ","permalink":"https://pdh0085.github.io/posts/the-real-reason-rs232-was-dead/","summary":"The industrial serial port produced no RS-232 signal, and the internal docs blamed a dead charge pump in the transceiver. Then we read the three mode GPIOs from the known-good Yocto firmware: 0/0/1. Ours were driving 1/0/0. The chip was fine.","title":"The Real Reason RS-232 Was Dead"},{"content":" Background: There Is No Single Modem The LTE572W ships with several modem models. The Quectel EG25-G and EC25-AU are option + qmi_wwan modules, so they expose ttyUSB*, cdc-wdm0, and wwan0. The Cinterion PLS83-EP / PLS83-W are cdc_acm + cdc_ether modules: ttyACM* and wwan0, with no cdc-wdm at all.\nThat means code on this board must never depend on tty names or USB VID/PID. The one fact we allow ourselves to depend on is that the modem is always the USB device on EHCI port 1-1 (Wi-Fi is 1-2). Whatever module is fitted, that doesn\u0026rsquo;t change. It\u0026rsquo;s a fact of the PCB.\nThis post is a record of two failures in that cellular stack. They share one property: in both cases, every status indicator looked perfectly healthy.\nPart 1: The Silent Demotion from QMI to AT+PPP The Symptom Was That There Wasn\u0026rsquo;t One At some point the modem started attaching fine. Data flowed. But the CPU was strangely busy, and there wasn\u0026rsquo;t a single error in the logs.\nThe cause was a ModemManager fallback. When MM can\u0026rsquo;t see a QMI control port, it silently falls back to AT + PPP. PPP is userspace HDLC, which is a disaster on a 400 MHz single core. And because the modem still connects, the failure hides itself.\nWhy the QMI Port Went Missing cdc-wdm has no hotplug event of its own. It\u0026rsquo;s the QMI/MBIM control node: it gets discovered through the network interface\u0026rsquo;s sysfs and reported separately, under the usbmisc subsystem. In an earlier post in this series I described a no-bus guard we added to the hotplug scripts (if MM isn\u0026rsquo;t up yet, cache the event and skip the mmcli fork). The first version of that guard did its exit 0 before the code path that reports usbmisc devices.\nThe result: cdc-wdm0 was never reported to MM, so MM marked the interface wwan0 (ignored), which meant demotion to AT+PPP. Not one line of error output.\nHow to Tell Which Path You\u0026rsquo;re On This is the most practically useful part of the post. Two lines of mmcli -m N output tell you which path the modem attached over.\nState primary port manufacturer Where the value comes from Healthy (QMI) cdc-wdm0 QUALCOMM INCORPORATED QMI DMS response Demoted (AT+PPP) ttyUSB2 Quectel AT +CGMI response Same modem, different manufacturer string. Where the string comes from tells you which path you\u0026rsquo;re on: ask over QMI and the chipset vendor answers; ask over AT and the module vendor answers.\n# check that you\u0026#39;re on the healthy QMI path mmcli -m 0 | grep -E \u0026#39;primary port|manufacturer\u0026#39; primary port: cdc-wdm0 manufacturer: QUALCOMM INCORPORATED One more thing: this bug is invisible on the PLS83, because that module has no cdc-wdm to lose. It only shows up with a Quectel module fitted: a bug that requires a hardware configuration change to become observable. A classic trap for a product that ships multiple module variants.\nPart 2: The Half-Failure of APN Auto-Profiling Every Surface Signal Was Green We booted with a SIM from a domestic carrier. mmcli said connected. wwan0 got an address (a 102.x one that even looked like a public IP), and a default route appeared. On paper, perfect.\nBut no data flowed at all. ICMP was dropped, and every TCP connect came back with EPERM.\n# the signature of \u0026#34;connected\u0026#34; with no data path ping -I wwan0 8.8.8.8 → 100% loss curl https://... → connect: Operation not permitted (EPERM) Cause and Fix For this SIM, APN auto-profiling silently half-fails. The modem attaches, but to a bearer that passes no data. Setting the carrier\u0026rsquo;s correct APN explicitly made it immediately reattach to a real bearer (10.x/23), and ping, HTTP, and HTTPS all worked.\nThe rule that came out of this:\n\u0026ldquo;The interface is up and has an IP\u0026rdquo; proves nothing. A connection is one successful real TCP request.\nThe same rule applies directly to health-check design. A health check that judges uplink health by link state or the presence of an IP will classify this exact state as healthy.\nThe Product Decision We did not put that APN into the firmware defaults. The product is not tied to any one carrier; the user sets the APN in the UI. Baking one carrier\u0026rsquo;s convenience into the defaults would manufacture exactly this kind of silent failure for every other carrier.\nPart 3: The Time the Documentation Was Wrong Our internal records said the EC25-AU \u0026ldquo;fails on a certain domestic carrier with USIM application state illegal / sim-missing.\u0026rdquo; We tried it on an actual shipping board with that carrier\u0026rsquo;s SIM, and it did not reproduce. The EC25-AU registered and attached normally, got a 10.x address over the cdc-wdm0/QMI path, and passed data (ping 8.8.8.8 -I wwan0, 0% loss).\nWe corrected the record but didn\u0026rsquo;t delete it. A wrong record shouldn\u0026rsquo;t be erased; it should be kept alongside the reason it was overturned. That practice comes back in the epilogue.\nFor contrast: with no SIM inserted at all, mmcli reports failed / sim-missing and wwan never comes up. That\u0026rsquo;s not a lie, that\u0026rsquo;s correct behavior. The problem was always the states that looked healthy and weren\u0026rsquo;t.\nLessons In a cellular stack, the only trustworthy signal is end-to-end traffic. connected, an IP address, a default route: we confirmed twice that all of them can be false positives. A product that supports multiple modules will inevitably grow bugs that only one module can reveal, so code should depend on invariants (here, the USB port position 1-1) rather than on models. Fallbacks look like kindness, but a silent fallback hides bugs. If the QMI-to-PPP demotion had logged even one line, we would have found it far sooner. Related habit: read diagnostic output for where a value comes from, not just what it says. Which protocol answered the manufacturer query is what told us which path we were on. ","permalink":"https://pdh0085.github.io/posts/when-the-modem-says-connected/","summary":"The modem reported connected, and wwan0 had an IP address and a default route. Not a single packet went out. Two silent failure modes of an LTE modem on a 400 MHz single-core board, both with perfectly green status indicators, both only detectable by pushing real traffic.","title":"When the Modem Says 'Connected'"},{"content":" The Starting Point This board is slow to reach init complete (still about 190 seconds after everything in this post), and it idles at a loadavg of about 4. On a single 400 MHz core some of that is unavoidable, but a loadavg of 4 also means something is doing work. To separate the slowness you\u0026rsquo;re stuck with from the slowness you\u0026rsquo;re paying for, you first have to measure.\nLet me say up front that this is not a \u0026ldquo;we cut boot from three minutes to one\u0026rdquo; success story. What actually happened is that I closed one large hole and knocked down one inherited hypothesis.\nHow I Measured It Every OpenWrt init script sources /etc/rc.common. So one file is enough: stamp entry and exit into /dev/kmsg there, and you get per-script timings on the same axis as the kernel\u0026rsquo;s own timestamps.\n# near the top of /etc/rc.common echo \u0026#34;rc: \u0026gt;\u0026gt; $1 $2\u0026#34; \u0026gt; /dev/kmsg trap \u0026#39;echo \u0026#34;rc: \u0026lt;\u0026lt; $1 $2\u0026#34; \u0026gt; /dev/kmsg\u0026#39; EXIT One trap within the trap: inside rc.common, $0 is always /etc/rc.common. The actual script path is $1. Log $0 and every line comes out with the same name, telling you nothing.\nCulprit 1: usb-modeswitch This was the most satisfying find. The hotplug hook that the usb-modeswitch package installs is effectively one unguarded line:\n# usb-modeswitch\u0026#39;s hotplug hook — effectively this one line /etc/init.d/usbmode start # no ACTION guard, no DEVTYPE guard No ACTION check, no DEVTYPE check, so it runs on every USB uevent. And one modem generates ten of those: one device plus nine interfaces. Each run re-parses the 55 KB, 3,359-line /etc/usb-mode.json from scratch, which costs about a second on this CPU.\nHere is what the measurement actually showed. It was taken after the modem power had already moved to S11 (culprit 2 below) and before usb-modeswitch was removed:\n51s modem appears on USB 51s – 96s usbmode runs back to back (starving the hotplug queue — even unrelated events are delayed 6–9 seconds each) 102s eth0 comes up 115s Wi-Fi AP comes up The absurd part is that every modem we ship enumerates as a modem from the start. There is nothing to switch from storage mode. Forty-five seconds of diligent parsing, and the answer was \u0026ldquo;nothing to do\u0026rdquo; every single time.\nRemoving the package saved 25 seconds. In case someone reinstalls it later, I left a separate safeguard that installs the missing ACTION/DEVTYPE guards, so the regression can\u0026rsquo;t quietly come back.\nCulprit 2: Modem Power at the Very End of Boot The modem power-up script was START=99. From rail power to USB enumeration takes about 7 seconds (a property of the module itself, not an ordering problem), and since S99 runs at around 155 seconds, the modem didn\u0026rsquo;t appear until about 162 seconds. The device that needs the longest lead time was being powered last.\nSo just move it earlier, right? Except the script carried this comment:\nPowering the modem early makes it compete with Wi-Fi enumeration on the shared EHCI bus, causing repeated cdc_ether … -71 (EPROTO) errors and USB disconnects.\nIt\u0026rsquo;s plausible. The modem and Wi-Fi really do share one EHCI controller, and -71 is a real error. I believed this comment for quite a while myself.\nAnd it was wrong.\nDisproving It First, a fact check. dmesg shows that Wi-Fi enumerates at about 3 seconds into the kernel boot, before init scripts even exist. So whether the modem powers up at S11 or S99, racing Wi-Fi enumeration is chronologically impossible. The only late Wi-Fi USB activity is the firmware upload when the AP is brought up.\nThe logic was already broken, but I ran the experiment anyway. I deliberately made the suspected conditions as bad as possible: on a fully booted board, I re-applied modem power under three conditions.\nCondition Situation Result (a) idle clean enumeration in 9–10 s (b) 4 CPU load hogs (loadavg 7.65) clean enumeration in 9–10 s (c) during an actual wifi up firmware upload clean enumeration in 9–10 s All three runs: zero -71 errors, zero USB disconnects. The failure the comment warned about would not reproduce even under the worst conditions I could construct.\nSo I moved the script to START=11. The modem now appears on USB at about 50 seconds instead of about 162, and Wi-Fi is essentially unaffected (phy0-ap0 at 90.5 s versus 87.5 s before).\nI want to be clear about one thing: whoever wrote that comment wasn\u0026rsquo;t incompetent. They probably really did see -71 errors on that board at that time. But \u0026ldquo;verified\u0026rdquo; in a comment usually means observed once, under those conditions. It doesn\u0026rsquo;t mean causation. I carried that belief around for weeks, and there was only one way to test it: deliberately construct the worst case and try to reproduce.\nCulprit 3: The Problem I Expected Early Power to Cause The modem now shows up before ModemManager (S70). That\u0026rsquo;s fine: the hotplug script from an earlier post in this series caches the kernel events and the MM wrapper replays them at startup. I verified that a modem appearing roughly 90 seconds before MM is picked up normally by mmcli -L.\nWhat the profiling did expose along the way: 23 mmcli forks during boot. mmcli is a glib+dbus binary, which costs 6–9 seconds per invocation on this core, or 6–13 seconds when it fails because the bus isn\u0026rsquo;t up yet. A whitelist filter plus a no-bus guard took that from 23 forks to 0. The full story is in that earlier post.\nNot Done Yet After all of this, init complete still lands at about 190 seconds. Overlaid, the three stages look like this:\nstart (power at S99): … ~162s modem USB … 87.5s Wi-Fi AP power at S11, 3s Wi-Fi enum … 51s modem USB … 96s usbmode done usb-modeswitch present: … 102s eth0 … 115s Wi-Fi AP after both fixes: 3s Wi-Fi enum … 50s modem USB … 90.5s Wi-Fi AP … ~190s init complete (usb-modeswitch removal: −25 s; mmcli forks during boot: 23 → 0) Metric Before After Modem appears on USB ~162 s ~50 s Wi-Fi AP (phy0-ap0) 87.5 s 90.5 s mmcli forks during boot 23 0 The modem shows up 112 seconds earlier and the wasted work is gone, so why does init complete still land at about 190 seconds? The rc.common profile shows the remaining chunks plainly: S95frr about 30 seconds, S10boot about 16, S80ucitrack about 12, S19firewall about 11, plus a late-boot stretch where things like sysntpd, mwan3, dnsmasq, and firewall get invoked over and over. I have not investigated these yet. I have the numbers and not the causes. That\u0026rsquo;s the list for next time.\nLessons Price a hotplug hook per event, not per script. A \u0026ldquo;one-second script\u0026rdquo; fired by ten events is ten seconds. Decisions about start order (START=) belong to experiments, not comments. If you want to disprove a claim, deliberately construct the worst case for it and try to reproduce the failure. A design that avoids contention by starting late is usually a sign that nobody understood the cause. Once you do, the ordering becomes free. ","permalink":"https://pdh0085.github.io/posts/dissecting-a-190-second-boot/","summary":"The LTE572W takes about 190 seconds to reach init complete. Profiling showed usb-modeswitch eating 25 of them, and the modem\u0026rsquo;s power rail wired to the very end of boot. A code comment gave a \u0026lsquo;verified\u0026rsquo; reason why the modem couldn\u0026rsquo;t be powered earlier. The experiment said otherwise.","title":"Dissecting a 190-Second Boot (and Disproving My Own Hypothesis)"},{"content":"Why Truck Rolls For an FWA or broadband operator, the thing scarier than the cost of the device is the truck roll. One technician visit can burn the price of several units. So the real value of a device like our LS500X/NM500G (Qualcomm IPQ8072, based on OpenWrt 25.12) isn\u0026rsquo;t the feature list. It\u0026rsquo;s the fraction of incidents that end without anyone driving anywhere.\nWe turned that into a table. Left column: the reason a truck rolls. Middle: our product\u0026rsquo;s defense against that cause. Right column: how we know the defense works.\nThe third column is what this post is about.\nThe Four Grades of Evidence \u0026ldquo;How we know\u0026rdquo; is never written as yes/no. It\u0026rsquo;s written as one of four words.\nGrade Meaning measured We actually induced that failure, and the numbers are on record armed We verified the code is shipped and running, but we have never induced the failure it\u0026rsquo;s supposed to catch inference It should work by design. Never demonstrated gap There is nothing The point of this grading is not bragging, it\u0026rsquo;s self-regulation. The first line of the document reads: \u0026ldquo;Quote measured rows freely; never promote the other rows to measured in prose.\u0026rdquo; RFP answers are given not as \u0026ldquo;yes\u0026rdquo; but as one of these four words.\nAnd I should say it up front: the table still has gap rows. We wrote them down instead of erasing them, and the last section of this post is exactly those rows.\nA low-graded row wants to be upgraded, and there is only one way to do that: actually break the thing. Here are four cases where we did.\nCase 1: The Zombie Modem A 5G module doesn\u0026rsquo;t die in just one way. Two ways we induced:\nRegistered but passing nothing. The link looks fine, so naive monitoring is fooled. The defense is a keepalive aimed at a real upstream destination. The way we induced it was fun: point the keepalive at a documentation-only reserved address, and you get precisely that state, where the line is up and nothing arrives. Result: three failures at 45-second intervals, then a hardware reset, 93 seconds from the first failure.\nThe zombie. The interface exists but nobody answers. We created a logical USB disconnect with every power rail still healthy. Detection came at 41 seconds, the reset followed, the module re-enumerated 32 seconds later, and 104 seconds after the disconnect everything was back to normal. No human involved.\nThat 104 seconds is the number for this specific failure shape. It is not \u0026ldquo;all modem failures recover in 104 seconds\u0026rdquo;; writing that would break the very rule this table exists to enforce.\nBut the real ending of this case isn\u0026rsquo;t the number. The drill caught a defect. The reset procedure started checking for USB presence immediately after the reset, at which point the pre-reset enumeration was still lingering, so it read \u0026ldquo;ready in 0 seconds.\u0026rdquo; The actual module dropped off the bus about a second later, but the watchdog only noticed at its next check, 31 seconds later, and misdiagnosed the missing module as a zombie. So every hardware reset was silently escalating straight to a power cycle: a two-rung recovery ladder collapsed into one.\nThe fix was ordering. First wait for the module to disappear from the bus, then confirm its return (measured: gone at 1 second after reset, back at 30). In the re-drill the ladder stopped at the first rung, as designed.\nIf we had never induced the failure, this defect would have stayed invisible forever, because recovery \u0026ldquo;was working.\u0026rdquo; It was just recovering harder than necessary, every single time.\nCase 2: When One Bad Config Kills the Line Change a setting remotely, break the WAN, and you\u0026rsquo;ve also just destroyed your remote path to fix it. A classic truck-roll generator.\nThe defense: keep a last-known-good snapshot of the network, firewall, DHCP, and failover configuration, and if the line isn\u0026rsquo;t alive after a change, restore the snapshot and re-apply the affected services.\nWe drilled it with the grace period shortened. We applied a bad WAN config, the snapshot was restored at 124 seconds, and the line was back to normal at about 130 seconds with no human intervention. That 130 seconds is a drill value with the grace shortened; the shipping default grace is 10 minutes.\nWe drilled the false-positive defenses too. A change made while the line is already dead is accepted, not reverted, since otherwise the mechanism would fight the very repair work being attempted. And a revert never happens twice.\nThis row also carries a gap row right next to it. The device\u0026rsquo;s only health signal is the WAN, so a firewall mistake that leaves the line alive but blocks only the path to the management server is not caught. Changes outside the watched files aren\u0026rsquo;t caught either, and that part is deliberate: this mechanism must never revert a password or an SSID the customer chose on purpose.\nWe write down what our product cannot do before anyone else does. That is the whole reason the table exists.\nCase 3: The Last-Resort Reboot, and Why Only Three If no upstream line comes back for 30 minutes, the device reboots itself once. Attempts are spaced at least 4 hours apart, and after 3 attempts it gives up.\nThe reason it gives up is the best part of this case: a reboot erases the logs the device itself left behind. The log buffer is finite, and it\u0026rsquo;s the only evidence anyone will have for a post-mortem. An infinite reboot loop destroys its own evidence. So we chose to automate less. Deciding the ceiling of your automation is design work too.\nCase 4: The Row Where Our Document Was Wrong The table had a row that read \u0026ldquo;no physical factory-reset path (gap).\u0026rdquo; Serious, because it means phone support has no last resort.\nIt was wrong. The reset path had existed for a very long time: holding the WPS button for more than 3 seconds wiped the configuration. It just wasn\u0026rsquo;t documented anywhere.\nAnd acting on that wrong row (\u0026ldquo;there\u0026rsquo;s none, so let\u0026rsquo;s build one\u0026rdquo;) produced two reset paths, both firing on a single button press, because the system runs both kinds of button handler.\nCleaning it up, we fixed three things at once:\nRaised the threshold to 10 seconds. Three seconds is far too easy to trip by accident. Added a model check. The file defining this behavior lives in a location shared across products built on the same chipset family, and because of that file structure, other companies\u0026rsquo; devices on the same chipset had been shipping the same \u0026ldquo;hold WPS 3 seconds and your config is gone\u0026rdquo; behavior. The model condition closes that path. Made the reset leave a kernel log entry. We drilled it with three real presses. One second gets you WPS pairing. Six seconds gets you nothing at all, though that press would have wiped the box under the old threshold. Eleven seconds gets you a factory reset, with the device back up in about 30 seconds. And we read the reset log back after the reboot, so this reset is auditable after the fact.\nA feature the design document said didn\u0026rsquo;t exist actually did, and acting on the false belief created a real defect. There is no better argument for why the table has to be filled in.\nFinding the Cause Without Rolling a Truck Beyond the drills, briefly, the other rows.\nLogs that survive a reboot. Kernel messages from just before a restart are kept in a DRAM region and read back on the next boot. Measured twice; a marker planted before the restart was read back byte-for-byte afterwards (63 KB). One thing we only learned by measuring: the ordinary console output path never reaches this store. There is a path that looks plausible and leaves nothing. Remote log collection. The management server pushes four parameters and the device uploads a diagnostic bundle. Isolation was proven by refusal: aiming at another device\u0026rsquo;s area gets an authentication denial. The bundle also deliberately excludes one specific log file, because at debug level that file contains management credentials in plaintext. Delivering improved defaults to fielded units. How do you get a better default into devices already sold? We rejected \u0026ldquo;just push it from the management server,\u0026rdquo; because this product ships with no management server address configured, so that answer would freeze every retail unit at factory defaults forever. Instead we built a numbered migration scheme and induced-tested that the failover-timer improvement from an earlier post in this series (51.30 s down to 9.58 s) actually reaches a unit that never had it. After a settings-preserving upgrade the value converged, and on the second reboot nothing happened at all. It\u0026rsquo;s idempotent. The most important thing about migrations is not the mechanism but the boundary: a migration fixes only what is measurably wrong and never touches a value the customer chose. There is no mechanism enforcing that boundary; it is held by discipline. The document says exactly that, too.\nThe Numbers Measured rows only.\nTruck-roll cause Defense Measured Bad firmware A/B rollback 26.5 s / 43.5 s; ~75 s on kernel panic Wired line failure 5G failover 9.58 s Modem zombie Staged recovery ladder 104 s unattended Modem unresponsive (registered) keepalive → hardware reset 93 s from first failure Bad configuration Last-known-good restore 130 s drilled (grace shortened); shipping default 10 min Install-day misprovisioning Zero-touch 101.5 s Phone-support last resort 10-second button → factory reset back up in ~30 s, auditable Post-mortem evidence Reboot-surviving logs 63 KB recovered, verified twice What Isn\u0026rsquo;t Measured Yet Honesty is the product here, so the closing section is the low-graded rows.\nThe hardware watchdog. We verified it is shipped and running (30-second period), but we have never induced the hang it is supposed to catch. Grade: armed. Which is why nowhere in this post is the watchdog called a safety net. Remote management over the 5G path. Every management-session measurement was taken over Ethernet. It should work over 5G by design; it has never been demonstrated. Grade: inference. A bad config that blocks only the management server while the line stays up. That\u0026rsquo;s the gap row from Case 2. Grade: gap. We are spending next quarter erasing these three lines.\nWhat We Keep \u0026ldquo;It works\u0026rdquo; is not an answer. The grade of evidence behind the claim is the answer, and four grades have been enough for us. The only way to upgrade a row is to actually break the thing, and a drill\u0026rsquo;s real payoff is rarely the number. It\u0026rsquo;s the defect hiding inside something that everyone thought was working. The rows I value most are the gap rows. They are what keep the measured rows from being inflated.\nTwo smaller things worth keeping as well. Put a ceiling on your automation: a reboot erases its own logs, so after three attempts we stop and preserve the evidence instead. And the boundary of automatic fixes is discipline, not technology. Fix only what is measurably wrong, never touch what the customer chose, and write that discipline into the document.\n","permalink":"https://pdh0085.github.io/posts/four-grades-of-evidence/","summary":"The real value of an FWA device isn\u0026rsquo;t its spec sheet; it\u0026rsquo;s the fraction of incidents that end without a truck roll. So we built a table of truck-roll causes and their defenses, and graded every row measured, armed, inference, or gap. A zombie modem recovered unattended in 104 seconds. The table still has gap rows, and we wrote them down instead of erasing them.","title":"Four Grades of 'It Works': measured, armed, inference, gap"},{"content":" Four Bytes on the Console Every time the board booted on a fresh overlay, at about 185 seconds (right around init complete) roughly 25 bytes of binary noise appeared on the serial console. Then normal output resumed. Perfectly reproducible, cause nowhere in sight.\nThe thing to do in that situation is to actually read the bytes. The same four bytes appeared every time:\n... 00 78 f0 7e ... ← HDLC: command 0x00 + CRC 78 f0 + flag 7e That\u0026rsquo;s an HDLC frame, specifically a QCDM/DIAG frame. It also explains why the front of the blob looked mangled: something had opened the port, run tcsetattr to its own probe baud rate (not 115200), written AT, then written a QCDM frame and closed the port. The AT part comes out garbled; the QCDM part prints as-is. ModemManager was probing the console UART as a modem.\nWhy would it touch the console at all? On this image MM is built without udev, so the only way it learns about ports is mmcli --report-kernel-event called from hotplug.d. And the stock tty hotplug script has no port filter: every physical tty gets reported, the console UART (ttyS1) included. Only ttys under /sys/devices/virtual are skipped.\nI Wrote a Filter. It Did Nothing I wrote a report filter and dropped it into uci-defaults. The console garbage kept coming. There were two separate reasons, and those two reasons are what this post is about.\nReason 1: procd Coldplugs Before rcS kernel uevent replay (STATE_EARLY) → [preinit: where the filter must live] → rcS → S10boot (uci-defaults) ← already too late here → S60 dbus → S70 ModemManager → cache replay → (without a filter) console UART probe Kernel uevents are replayed in procd\u0026rsquo;s STATE_EARLY. By the time uci-defaults (S10boot) or any init script runs, it\u0026rsquo;s already over: the stock script has processed ttyS0/ttyS1 and pushed them into the event cache, and MM replays that cache when it starts, probing the console UART. The only code that runs before procd is exec\u0026rsquo;d is preinit. So preinit is the answer.\nReason 2: uci-defaults Never Updates on This Board This is the more important discovery. A uci-defaults script is rm\u0026rsquo;d after it runs. But on a persistent overlay, rm isn\u0026rsquo;t deletion; it leaves a whiteout in the upper layer:\n/overlay/upper/etc/uci-defaults/ c--------- 1 root root 0, 0 ... 99-something A config-preserving sysupgrade replaces only the squashfs and leaves the overlay alone, so the uci-defaults shipped by every new image is masked forever. Check a real board and the merged /etc/uci-defaults is empty. Stock OpenWrt doesn\u0026rsquo;t hit this because its sysupgrade formats rootfs_data. Ours doesn\u0026rsquo;t.\nAnd no, this can\u0026rsquo;t be fixed by adding a version marker: the script that would read the marker never runs in the first place. Which yields a general rule. Logic that must be updatable in the field does not belong in uci-defaults. /lib/preinit and /etc/init.d are squashfs files, so they can\u0026rsquo;t be whited out, and they always come from the new image.\nWhat the Correct Filter Looks Like Whitelist ttys: ttyACM*, ttyUSB*, cdc-wdm*. That covers every modem we ship. Blacklist net interfaces, because a modem\u0026rsquo;s network interface name is unpredictable (wwan0/usb0/\u0026hellip;). Whitelist those and one day your WAN dies silently. Add a no-bus guard. The modem gets power at S11 and enumerates around 50 seconds, but MM is S70, so most port events fire while MM doesn\u0026rsquo;t exist yet. Calling mmcli at that point burns 6–13 seconds and fails with couldn't get bus. So the guard caches the event and skips the fork. Nothing is lost, because the MM wrapper replays the cache at startup; a modem that showed up about 90 seconds before MM was still listed correctly by mmcli -L. Bottom line: mmcli forks during boot went from 23 to 0. What that means for boot time gets its own numbers in the next part. The guard hid one trap of its own, too. cdc-wdm control nodes have no hotplug event of their own, and an early version of the guard swallowed their report, silently demoting the modem to AT+PPP. That story belongs to the cellular part of this series.\nA Bonus Trap: Partial Marker Matches A copy of this hotplug script lives in /etc, on the persistent overlay, which means old copies outlive firmware updates. So the \u0026ldquo;already patched?\u0026rdquo; marker is a versioned string (QUARK-MM-HOTPLUG-vN) checked with an anchored exact match. A substring check (grep -q QUARK-MM-HOTPLUG) also matches -v1 or -OLD, and one stale copy really did survive an \u0026ldquo;update\u0026rdquo; that way. Finding it took a while.\nLessons When choosing where a script lives, ask not only \u0026ldquo;when does this run?\u0026rdquo; but \u0026ldquo;does it run again after an update?\u0026rdquo; On overlay-based systems, deletion isn\u0026rsquo;t deletion, it\u0026rsquo;s masking. Auto-probing is as dangerous as it is convenient: the target might be your console. We later made our own serial daemon refuse to open the console device for exactly this reason. A blob of mystery bytes can simply be read. Protocol frames usually tell you who they are. ","permalink":"https://pdh0085.github.io/posts/code-that-never-updates-in-the-field/","summary":"Every boot on a fresh overlay, about 25 bytes of binary garbage hit the serial console around the 185-second mark. The culprit was ModemManager probing the console UART as if it were a modem. I wrote a filter and put it in uci-defaults, and it did nothing, for two separate reasons.","title":"Code That Never Updates in the Field"},{"content":"What One Visit Costs The most expensive event in the CPE business is not a technical failure. It is a human being getting into a truck.\nOne truck roll, counting only labor and vehicle costs, is worth several units of hardware. Add the hours the customer spent waiting and the call center time on top. And most of those visits are made to do something a remote hand could have done: reboot the box, or roll back a setting.\nSo on our 5G CPE we approached this not as feature development but as a problem to work backwards from.\nList every situation that forces a person to physically go to the site, and for each path ask: \u0026ldquo;can the box do this by itself?\u0026rdquo;\nFive paths came out of that exercise. And the thing we learned along the way is that the hard part was never the fixing logic.\nThe Five Paths 1. Nobody knows why it rebooted The most common call-center conversation goes like this: \u0026ldquo;the internet suddenly dropped yesterday and then came back.\u0026rdquo;\nAt that point we know nothing. Did the unit reboot? If so, was it a power outage, a kernel panic, the watchdog, or an operator pressing a button? The logs vanished with the reboot.\nSo the first guard is not recovery, it is record-keeping. On every boot, the unit writes one line saying why the previous shutdown happened. Intentional reboots carry a tag: operator command, firmware upgrade, or one of the other guards. A death with no tag means a power loss or a crash.\nIt is a boring feature, but the four guards that follow all stand on top of this record. You cannot count \u0026ldquo;failed boots\u0026rdquo; until you can tell them apart from \u0026ldquo;intentional shutdowns.\u0026rdquo;\n2. One config line severs the management path It is easy, when changing configuration remotely, to close the door you came in through. Firewall zones, routing metrics, the WAN interface: one wrong change and the device is unreachable from that moment on. And the only way to undo it is also remote.\nThe second guard starts a clock whenever a watched setting changes. Within a fixed window, the unit must actually confirm \u0026ldquo;is this device still reachable?\u0026rdquo; If confirmation never arrives, it reverts to the configuration as it was just before the change.\nThe judgment criterion is the whole point. The question is not \u0026ldquo;is the configuration valid?\u0026rdquo; but \u0026ldquo;can we actually reach the box?\u0026rdquo; A syntactically perfect configuration can isolate a device just as thoroughly as a broken one.\n3. Cellular is attached but no data flows There is a state where the modem reports \u0026ldquo;registered,\u0026rdquo; the interface is up, and no packets move. To the user this is simply \u0026ldquo;the internet is down.\u0026rdquo;\nOur original watchdog had exactly one move here: bounce the interface. If that didn\u0026rsquo;t work, it had nothing left.\nThe third guard turned that one move into a ladder.\nLevel Action Limit L1 Restart the interface up to 3 times L2 Network reselection (AT+COPS re-registration) 2 per 6 hours L3 Reboot once per day, at least 30 minutes after boot, only when the clock is trustworthy Designing L2, the hardware taught us something. The original plan was an RF cycle (turn the radio off and back on, the textbook move). But on this modem, sending that command was irreversible. Once off, every attempt to bring the radio back failed, and a reboot was the only way to recover. A measure meant to fix \u0026ldquo;no data\u0026rdquo; would have put the entire box to sleep instead.\nSo L2 became network reselection, not an RF cycle. We were lucky not to have assumed that the action written in the plan would work as-is on this hardware.\nLook at L3\u0026rsquo;s restrictions and the character of this ladder becomes clear. Once per day, 30 minutes after boot, trusted clock: every one of them is a condition not for rebooting, but for not becoming a reboot loop.\n4. It boots, but it can\u0026rsquo;t be managed There is a state where the unit boots but the management surfaces (the web UI, the remote management daemon) never come up. A box that is alive but untouchable.\nThe fourth guard: if a boot fails to reach a \u0026ldquo;usable state\u0026rdquo; three times in a row, revert to the last known-good configuration and reboot.\nTwo places where the design deliberately deviates from the plan.\nWe did not use \u0026ldquo;previous boot lasted under 60 seconds counts as a failure.\u0026rdquo; We use a health marker instead. When a boot first reaches a manageable state it writes the marker; the next boot judges the previous one by that marker\u0026rsquo;s absence. It is simply the better question: a unit that stayed up for 10 minutes without its management daemon is exactly as unreachable as a unit that panicked after 4 seconds. Both need the same prescription.\nAnd if the configuration already matches the baseline, do nothing. This safeguard was not in the plan. In that case the configuration is not what broke the boot, so reverting changes nothing, and rebooting anyway would be precisely the loop we ourselves built.\n5. The data path is dead entirely Every guard above matters only while the box can still be reached in some form. When cellular fails completely, remote management dies with it.\nThe fifth guard is a text message. Even when cellular data is dead, SMS often survives on its separate path. A single signed text can trigger a small set of remote actions.\nThe security design is most of this feature.\nThe sender\u0026rsquo;s number is not authentication; it can be spoofed. Authentication is an HMAC signature made with a per-unit secret key. Replay attacks are blocked. Every command carries a counter, and numbers already used are rejected. There is an hourly processing limit, and rejected commands count against it too. There is no shell-command capability. Commands come from a fixed list only: reboot, APN reset, temporary SSH opening (auto-closed after 24 hours), management-server address restore. Factory reset is excluded from the default list. An operator has to enable it explicitly. The Actually Hard Part: Knowing When to Stop That was the feature list. But it is not where most of the time in this work went.\nAutomatic recovery features share one trap: building the fixing logic is easy; building the stopping conditions is hard. And a recovery feature that doesn\u0026rsquo;t know when to stop is not a recovery feature, it is a new outage.\nNowhere was this sharper than in the second stage of guard 4: \u0026ldquo;if reverting the configuration still doesn\u0026rsquo;t produce a good boot, factory reset.\u0026rdquo;\nIt is the logically natural next step, and we could not build it. Here is why.\nOn this platform, factory reset erases the configuration area from outside Linux. But our record saying \u0026ldquo;we already tried a reset\u0026rdquo; lives inside that same area. The moment the unit resets, it forgets that it reset. What cannot remember cannot stop, and a guard that cannot stop is a guard that reinstalls the factory image forever.\nSo before writing any code for this stage, we ran an experiment. We planted markers in seven locations, ran one factory reset, and measured what survived.\nThe result: the reset erased less than folklore said. It wiped the overlay\u0026rsquo;s contents, not the volume itself, and a separate volume holding factory provisioning data survived untouched. That was where the counter belonged.\nAnd as a side effect, that experiment exposed a problem we did not know we had.\nSelf-Reset Was Invalidating the Call Center\u0026rsquo;s Key The SMS secret key from guard 5 lived in the area the reset erases. Which means the moment a unit factory-resets itself, the key the call center holds for that unit becomes invalid.\nAt precisely the moment when the lifeline is the last resort. The box believes it has healed itself, when in fact it has cut its own last remaining remote path.\nWe moved the key to the volume the reset cannot erase. This key is not customer data; like a MAC address, it is a device credential, never something a factory reset should have been erasing in the first place.\nTwo Records That Answer Two Different Questions One more from the same thread. At first we kept a single record meaning \u0026ldquo;a reset has been attempted.\u0026rdquo; Live testing exposed the flaw.\nWhen a reset succeeds, that record gets cleared (the unit booted healthy, so returning the permission is correct). But the reset also erases the boot log that contained the reset event. Net result: when a reset succeeds, every trace of it disappears.\nThat is the state in which you tell a customer whose configuration vanished overnight: \u0026ldquo;nothing happened.\u0026rdquo;\nSo we split the record in two.\nRecord Question it answers When it is cleared A May we do this again? one healthy boot → cleared B Has this box ever reset itself? never They are different questions. Merge them into one record and one of the two answers is guaranteed to be wrong.\nAnd This Stage Ships Disabled We built it, then set the shipping default to OFF.\nHere is the reasoning. This action discards all customer configuration and cannot be undone. Meanwhile its trigger (\u0026ldquo;the management daemon didn\u0026rsquo;t come up\u0026rdquo;) is a condition that one bad release can create across the entire fleet at the same time.\nWorst case, a single firmware we got wrong factory-resets every device in the field simultaneously. That risk belongs to the fleet operator, not to us, so the decision to turn it on must be the operator\u0026rsquo;s too.\nThe Guard That Watches the Guards Finally, the most instructive incident of this whole series.\nAlongside the guards above, we built a pre-flash firmware check: verify the image before burning it, so a truncated download or a corrupted file gets rejected before storage is wiped. It is the prevention-side answer to the bricking problem an earlier post covered.\nWe took the first image carrying this check to the bench to flash it, and it was rejected.\nThe image was fine. Byte-for-byte it had the same structure as the previous, already-verified version. The fault was in the check itself. It looked for a particular entry inside the archive; that entry was a directory, so the listing showed its name with a trailing slash. The check demanded an exact match, so it never matched.\nIn other words, this guard was rejecting every valid image. A feature built to prevent bricks had nearly blocked all firmware updates instead.\nMore important than the embarrassing cause is why we didn\u0026rsquo;t catch it. We had tested this check diligently. Truncated files, missing members, insufficient storage, low battery: it rejected every one of them, correctly.\nWe had only tested the rejection paths. We never tested acceptance.\nWhen you test a guard, checking only that it blocks what it should block is seeing half the picture. You must also check that it passes what it should pass, and feed it real production artifacts to prove it.\nSince that incident, our release procedure includes running two real built images through the checker each image ships.\nLessons Approach truck rolls as paths, not features. Start from the situations that force a person to go, not from \u0026ldquo;what feature should we add.\u0026rdquo; All automatic recovery stands on records. If you can\u0026rsquo;t tell intentional shutdowns from accidents, you can\u0026rsquo;t count anything. Judge by reachability, not by state: not \u0026ldquo;is the configuration valid\u0026rdquo; but \u0026ldquo;can we actually reach the box.\u0026rdquo; The hard part is the stopping conditions, not the fixing logic. Ship irreversible actions disabled by default, especially when the trigger can fire across the whole fleet at once. Test guards in both directions, on what they block and on what they let through. And all of this is visible from the remote management server. Which unit fixed what by itself, when and why it rebooted, whether it has ever reverted its configuration: an operator can see it before deciding whether to dispatch.\nThe surest way to reduce truck rolls is to give operators, remotely, the evidence to decide whether the truck needs to go at all.\n","permalink":"https://pdh0085.github.io/posts/engineering-away-the-truck-roll/","summary":"We worked backwards from every situation that forces a field visit and built five guards into our 5G CPE. The hard part was never the fixing logic; it was the stopping conditions. A recovery feature that doesn\u0026rsquo;t know when to stop isn\u0026rsquo;t recovery, it\u0026rsquo;s a new outage.","title":"Engineering Away the Truck Roll"},{"content":" Recovery features have one nasty property: nobody uses them day to day, so when they break, nobody notices. This post is the record of finding two such paths on the LTE572W, both silently dead. Each of them reported success, error-free, while doing nothing at all. They broke for different reasons, too: one at a process boundary, the other inside an abstraction that misfired.\n1. sysupgrade -n Doesn\u0026rsquo;t Wipe the Configuration The symptom: flash new firmware with the \u0026ldquo;reset settings\u0026rdquo; option, and the old settings are still there. Worse, because the overlay survived, the uci-defaults scripts never run again either. The \u0026ldquo;factory-fresh new firmware\u0026rdquo; was not fresh in any way.\nThe code looks perfectly fine. Inside platform_do_upgrade there was this check:\n[ \u0026#34;${SAVE_CONFIG:-1}\u0026#34; != \u0026#34;1\u0026#34; ] \u0026amp;\u0026amp; rm -f \u0026#34;$overlay_img\u0026#34; The syntax is correct and so is the logic. The problem is that the variable never makes it to that line.\nplatform_do_upgrade runs in stage 2. After ubus call system sysupgrade, procd execs into a fresh environment, and the only values that cross that boundary are prefix / path / force / backup / command / options, which reach stage 2 as $IMAGE, $UPGRADE_BACKUP, $WDTFD, and $UPGRADE_OPT_*.\nstage1 (/sbin/sysupgrade) SAVE_CONFIG=1 export ─────────┐ ubus call system sysupgrade │ what crosses this boundary: │ prefix / path / force / backup / command / options ▼ stage2 (procd execs a fresh environment) $IMAGE $UPGRADE_BACKUP $WDTFD $UPGRADE_OPT_* ← $SAVE_CONFIG does not exist here (empty → defaults to \u0026#34;keep config\u0026#34;) $SAVE_CONFIG is exported in stage 1 and dies there. So the test always reads an empty variable, falls into the :-1 default, and behaves as \u0026ldquo;keep the configuration.\u0026rdquo; Every single time, -n or not.\nThe correct signal was already crossing the boundary. Stage 1\u0026rsquo;s sbin/sysupgrade only puts backup into the ubus call when SAVE_CONFIG=1, so the absence of $UPGRADE_BACKUP is the wipe signal. I switched the condition to that and verified both directions on the serial console: with -n, the overlay-removal log line appears and the planted markers (an APN, the hostname) are gone; with a normal upgrade, they survive.\nThe lesson fits in one line. Shell\u0026rsquo;s ${VAR:-default} is convenient, but it cannot tell \u0026ldquo;the variable is unset\u0026rdquo; apart from \u0026ldquo;the variable holds the default.\u0026rdquo; In code that crosses a process boundary, that\u0026rsquo;s dangerous.\n2. Factory Reset Was Broken Twice, for Different Reasons Background first. On this board, a single factoryreset binary serves firstboot, the hardware reset button, and TR-069\u0026rsquo;s rpc-sys factory. Fix it once and all three are fixed; break it once and all three break together.\nFirst failure: the volume can\u0026rsquo;t be found. The stock code starts with volume_find(\u0026quot;rootfs_data\u0026quot;). On a board with real flash partitions that\u0026rsquo;s a perfectly sound assumption, but our overlay is a loop-mounted ext4 image file sitting on FAT, so none of the drivers can match it. Not mtd (there is no /proc/mtd at all), not ubi, not partname.\nfactoryreset: MTD partition \u0026#39;rootfs_data\u0026#39; not found Then it aborts. Every reset path quietly did nothing. Up to this point the cause is our unusual layout, not the code.\nFirst fix, which then rotted. I added a fallback: \u0026ldquo;if the volume can\u0026rsquo;t be found, wipe the mounted /overlay.\u0026rdquo; It worked. Right up until the root filesystem moved to a squashfs loop.\nSecond failure: the abstraction succeeds. Once the root became squashfs, the rootdisk driver started binding. That driver looks for a squashfs superblock on the root block device and declares everything after it to be rootfs_data. For a board with squashfs on a real partition, that\u0026rsquo;s a reasonable rule. But what sits after our squashfs is 256 KB of alignment padding on a read-only loop device. So:\nvolume_find() succeeds, so the fallback never fires it returns an unwritable device a few KB in size factoryreset then tries to run mkfs.ext4 on it Filesystem too small for a journal mkfs.ext4: I/O error while writing out and closing file system factoryreset: /dev/loop2 will be erased on next mount And then it returns 0. Nothing erased, no reboot. Every reset path was silently dead again. In the first failure the volume layer answered \u0026ldquo;I don\u0026rsquo;t know,\u0026rdquo; which left room for a fallback to live. This time it answered confidently while being wrong, and that confidence is exactly what disarmed the fallback.\nThe final fix was to remove the condition altogether. Stop asking the volume layer entirely: if /overlay is mounted, delete its files. This is precisely what jffs2_reset() does for a mounted volume anyway, so volume-based boards are unaffected. As a bonus I fixed LuCI\u0026rsquo;s reset page too; it never checked the exit code, so it had been reporting the failed resets above as successes.\nOne small postscript. firstboot -y erases but does not reboot. Wiping the overlay also wipes the ssh host keys, so a board left running after it will thoroughly confuse whoever connects next. Always add -r.\nLessons Recovery features are never exercised by normal use, so the only option is to actually press them, every release. Neither of these bugs would have surfaced on the happy path. And \u0026ldquo;failed, but returned 0\u0026rdquo; is the worst kind of failure. The harder a feature\u0026rsquo;s outcome is to observe (resets, upgrades), the more its exit code and its post-state both need checking.\nThe abstraction story deserves its own sentence. An abstraction can coexist with a safety net only when it admits what it doesn\u0026rsquo;t know. rootdisk answered confidently without understanding our layout, and that confidence killed the fallback. Of course, half the cause is our own odd loop-ext4-on-FAT arrangement. If you choose to live outside the world an abstraction assumes, doubting its answers becomes your job too.\n","permalink":"https://pdh0085.github.io/posts/silently-dead-recovery-paths/","summary":"\u003ccode\u003esysupgrade -n\u003c/code\u003e had never once wiped the configuration, and factory reset was broken twice, for two different reasons. Both reported success without doing anything. One died at a process boundary; the other because a volume abstraction confidently declared 256 KB of alignment padding to be rootfs_data.","title":"Two Recovery Paths That Were Silently Dead"},{"content":"Why Router Spec Numbers Lose People\u0026rsquo;s Trust We measured every performance figure destined for the datasheet of our 5G FWA routers, the LS500X and NM500G (Qualcomm IPQ8072, based on OpenWrt 25.12). Before starting, we wrote down the two ways router specs usually get inflated.\nMeasuring on the device. Run the traffic generator on the router itself and the kernel\u0026rsquo;s local-endpoint optimizations kick in, producing numbers far above reality. But a router\u0026rsquo;s job in the field is to forward other people\u0026rsquo;s traffic. Calling \u0026ldquo;connected\u0026rdquo; a success. The ping comes back, the status page is green, done. So we set two rules:\n① Every number is measured on the forwarded path, through the device. ② A number is only recorded after a counter proves the traffic actually took that path.\nRule ① is common sense. Rule ② was born in the middle of this campaign; the story of why is below. Every measurement shares the same conditions: single stream, 20 seconds, median of 3 runs.\nWired NAT Path Up Down Gateway CPU (upstream) Plain NAT 896 938 Mbit/s 2.28 of 4 cores We measured a control alongside: take the router out and connect the hosts directly, and you get 929 Mbit/s. The cost of going through the box is not measurable. Adding streams (four instead of one) doesn\u0026rsquo;t raise the number, which is the classic signature of the gigabit port being the limit, not the box.\nThere\u0026rsquo;s a footnote to attach, though. This line rate comes from software forwarding, and it pays for itself with roughly two of the four cores. Getting those two cores back via hardware offloading is still an open task.\nVPN Tunnel Up Down Gateway CPU (upstream) WireGuard (ChaCha20-Poly1305) 529 461 2.51 of 4 cores IPsec (IKEv2, ESP AES-GCM) 520 372 1.54 of 4 cores OpenVPN / UDP (AES-256-GCM) 223 169 1.34 OpenVPN / TCP 157 135 1.27 IPsec Delivers the Same Speed on 40% Less CPU The first two rows are the headline. Upstream throughput is effectively identical, 529 versus 520, but WireGuard takes 2.51 cores where IPsec takes 1.54. The reason is whether the cipher is accelerated by this SoC\u0026rsquo;s ARM64 cryptography extensions. AES-GCM is (5.4 Gbps raw); ChaCha20-Poly1305 is not.\nThis difference doesn\u0026rsquo;t show up as speed. It shows up as headroom. On a box that already spends two cores on forwarding, whether the tunnel eats 1.5 cores or 2.5 decides whether anything else can still run. On a spec sheet the two rows look interchangeable; in practice, one of them consumes the box.\nOpenVPN\u0026rsquo;s Ceiling Is One Core When OpenVPN is the bottleneck, total device CPU sits near 1.4 cores. That looks like headroom, but it isn\u0026rsquo;t. Inspecting the single process showed it pushing 217 Mbit/s in that run while using 91% of the only core available to it. Two footnotes fall out of this:\nMaking the forwarding path faster won\u0026rsquo;t raise the OpenVPN numbers. That work touches NAT\u0026rsquo;s two cores, not this one core. Conversely, OpenVPN is the cheapest tunnel to run alongside other work: it hammers one core and leaves the rest alone. So we position OpenVPN by reachability, not speed. Its TCP transport is 30% slower than UDP, but on networks that block ESP and non-web UDP outright, it is the only tunnel left standing.\nOur First IPsec \u0026ldquo;Success\u0026rdquo; Was Plaintext This is where rule ② comes from.\nIn the first IPsec measurement, pings returned in 0.74 ms, faster than WireGuard. The security association read ESTABLISHED, the child SA INSTALLED, every status light green. But the SA counters said:\nin 0 bytes / out 0 bytes The packets weren\u0026rsquo;t entering the tunnel at all; they were going straight to the neighboring device. The firewall\u0026rsquo;s address translation was rewriting the source address before the encryption policy lookup, so the policy never matched. \u0026ldquo;Huh, that\u0026rsquo;s fast\u0026rdquo; was actually \u0026ldquo;huh, that\u0026rsquo;s not encrypted.\u0026rdquo; No status light distinguishes those two.\nFrom then on, every number was gated on counters:\nTunnel Path proof WireGuard Interface TX counter increments across 5 pings IPsec ESP byte count grows 672 MB → 4.76 GB during the run OpenVPN Daemon\u0026rsquo;s own status file counts 92 MB, matching data moved The Numbers You Must Not Quote Measured on the device, WireGuard does 840/889 Mbit/s, because the kernel can use segmentation offload on locally generated traffic and there\u0026rsquo;s no forwarding. That is not what a site-to-site gateway does, so we do not use those numbers. The forwarded-path figures in the table above are the honest ones.\nWAN Failover The core FWA feature: the wired WAN dies, the box moves to 5G. Here, too, how you measure decides the number.\nScenario Meaning Measured (median) Blackhole Upstream silently dies, link stays up 9.58 s Link down Someone pulls the cable 0.85 s Recovery Wired WAN comes back 0.00 s The datasheet number is 9.58 seconds. 0.85 s is what happens when someone unplugs a cable, not when the upstream dies, and no datasheet should call that the failover time. The 0.00 s recovery also needs a narrow reading: it means no observable gap in an ICMP stream; the session view was not separately measured.\nThe initial measurement was 51.30 seconds, and the cause was simply the default timers: a 10-second probe interval times 5 failures is 50 seconds, and the measured value is that plus probe spacing and round trips. Because the model explained the number, tuning behaved as predicted: 3 seconds times 3 failures gave 9.58 s, and that setting also had the smallest variance. With a footnote attached: \u0026ldquo;the 3-second interval doesn\u0026rsquo;t flap\u0026rdquo; is based on nine minutes of idle observation and predicts nothing about a customer\u0026rsquo;s congested or lossy line. What guards against that case is the voting rule: the line is only declared dead when 2 of 4 probe destinations fail simultaneously.\nOne Missing Setting Meant Failover Never Happened At All Measured on the same board, minutes apart:\nConnection-tracking flush setting Blackhole failover Unset (as shipped) \u0026gt;120 s, never recovered Set 50.15 s Unset again (control) \u0026gt;120 s We pinned the cause by reading the source, not by guessing. The failover manager marks connections with their WAN and restores that mark onto existing connections; when the flush list is empty, it flushes nothing. So established flows keep the dead line\u0026rsquo;s mark forever. The route changes; the traffic doesn\u0026rsquo;t follow.\nAnd Then We Narrowed Our Own Finding At this point you want to write \u0026ldquo;enable the flush and sessions survive failover.\u0026rdquo; We re-measured with TCP, and no:\nFlush set Unset (control) New connections work again after 8.5–10.9 s 9.5–10.9 s Connections held across failover Stall, no response Stall, no response For TCP applications that reconnect, this setting changes nothing. A new connection is a new 5-tuple and gets marked with the live line anyway. So the setting\u0026rsquo;s real value is narrower:\nIt saves flows with a fixed 5-tuple: UDP VPN tunnels (WireGuard, IPsec) and long-lived UDP sessions. Without it, those never fail over at all. \u0026ldquo;TCP sessions survive failover\u0026rdquo; is false. Do not sell it. We shipped the setting anyway, for a clear reason: Ethernet+5G failover sells into small businesses, and the site-to-site VPN running on top is exactly that fixed-5-tuple UDP flow. We also wrote down the cost: the flush is global, so at the moment of failover it also cuts a LAN client\u0026rsquo;s unrelated download.\nOne more footnote. However fast the failover, the public IP changes. The box moves from the wired WAN to the mobile network\u0026rsquo;s CGNAT, so any upstream service doing IP-based authentication is affected regardless of timing. Leave that sentence out and the 9.58 s becomes a lie.\nWi-Fi Mesh Backhaul Item Measured Node joins the gateway as a peer 5.1 s (the UI conservatively says 25 s) Backhaul throughput 723 / 664 Mbit/s Latency 3.21 / 6.31 ms Teardown 3.2 s Both units were also wired to the same host, so these numbers could have traveled over Ethernet. We proved the path by watching the wireless interface counters increment before recording anything. Rule ② again.\nTwo footnotes: the units sat about 1 meter apart, so this is a best-case figure, and client roaming was not measured (there were no Wi-Fi clients on the bench). 723 Mbit/s is not a deployment number.\nThe Instrument Lied To assess failover stability we counted how many times the status output changed: 35 changes in 540 seconds. It was noise. The output contained an uptime string, so it differed on every poll. The meaningful counter was the online-time value that resets to zero on a flap, and it never reset once. The line was fine; the thing flapping was our measurement script.\nThe Number Card All measured. Single stream, 20 seconds, median of 3.\nItem Value NAT 896 / 938 Mbit/s (2.28 cores) · direct-connect control 929 WireGuard 529 / 461 (2.51 cores) IPsec (AES-GCM) 520 / 372 (1.54 cores; 40% less CPU per bit) OpenVPN UDP / TCP 223 / 169 · 157 / 135 (single-threaded, 91% of one core) WAN failover (blackhole) 9.58 s (51.30 s before tuning) Mesh backhaul (1 m) 723 / 664 Mbit/s, join in 5.1 s What We Keep \u0026ldquo;It\u0026rsquo;s connected\u0026rdquo; and \u0026ldquo;the traffic took that path\u0026rdquo; are different claims. If no counter moved, nothing happened, and a green status light is not evidence. A number only becomes a value once its conditions are attached: 9.58 s carries \u0026ldquo;blackhole,\u0026rdquo; 0.85 s carries \u0026ldquo;cable pulled,\u0026rdquo; 723 Mbit/s carries \u0026ldquo;1 meter apart.\u0026rdquo; A number without conditions is an inflated number. For the same reason, saying first which numbers must not be quoted is what buys trust; if you can explain why you discard 840/889 and publish 529, the rest of your numbers become believable. Narrow your own findings yourself. The flush setting rescued failover but does not rescue TCP sessions, and omitting that one line would turn a finding into an exaggeration. ","permalink":"https://pdh0085.github.io/posts/honest-router-numbers/","summary":"On our gateway, IPsec and WireGuard push almost the same throughput, but one uses 1.54 cores and the other 2.51. And our first IPsec \u0026lsquo;success\u0026rsquo; returned pings in 0.74 ms while the SA counters read zero bytes: the tunnel wasn\u0026rsquo;t encrypting anything. After that day, no number got recorded until a counter proved the traffic actually took the path.","title":"Honest Router Numbers"},{"content":" The Problem In an earlier part of this series, the root filesystem became a squashfs file sitting on the eMMC\u0026rsquo;s FAT partition. That makes sysupgrade \u0026ldquo;the act of replacing that file with a new one,\u0026rdquo; which leaves exactly one question: what if the new root fails to boot?\nIndustrial equipment usually lives where hands can\u0026rsquo;t reach it: factory ceilings, remote monitoring sites. A failed boot means a site visit. So before trusting the new boot scheme at all, we designed the failure path first. The conclusion up front: a fallback is not a nice-to-have, it is a state machine. Where does the state live, what consumes it, and what does not consume it? The design boiled down to those questions.\nThree Design Principles Write the marker immediately before entering the dangerous path, just before the point of no return. The marker is a file, not an environment variable (reasons below). A failed validation does not consume the marker. A missing or broken fallback image must never cost the board a boot attempt. The Ladder A single one-shot marker file on the FAT, boot_state, drives five rungs:\nno boot_state ─→ primary + persistent overlay │ (hang) boot_state=primary ─→ golden + persistent overlay │ (hang) boot_state=golden ─→ golden + volatile overlay │ (hang) boot_state=golden-noovl ─→ primary + volatile overlay ← the rung that actually saves boards │ (hang) boot_state=primary-noovl ─→ rescue shell (auto-reboot after 300 s) failed validation (file missing / mount failure / vermagic mismatch) = skipped WITHOUT writing the marker → a skipped rung falls through to the next one within the same boot The marker is written right before switch_root, and an S99 script deletes it once the boot comes up healthy. So if the loader finds the marker still present, that means exactly one thing: that candidate hung on the previous boot. On the serial console it reads like this:\nquark-squashfs-init: boot_state=primary → primary hung on the previous boot; escalating to golden Why There Are \u0026ldquo;No-Overlay\u0026rdquo; Rungs The most plausible cause of a boot hang is neither the kernel nor the root. It\u0026rsquo;s a badly saved configuration. In that case the right move is to boot the same root again while ignoring the config. But the root must not be mounted read-only for this: dropbear can\u0026rsquo;t write its host keys, so ssh never comes up. Losing remote access in precisely the mode where remote access matters most would be the worst outcome. So instead of a read-only root, the no-overlay rungs mount a volatile tmpfs upper: the boot comes up with clean config, and you can ssh in and repair the real overlay. As a related belt-and-suspenders choice, the LAN bridge, Ethernet, and overlayfs drivers are all built into the kernel, so ssh comes up even if module loading fails entirely.\nThe Rung That Does the Real Work Is primary-noovl Here is this post\u0026rsquo;s twist. At first glance the two golden rungs look like the heroes. But golden can do nothing at all in the two situations that matter most:\nA board fresh from the factory has no golden at all; golden is created by the first sysupgrade. After an update that changes the kernel version, the old golden has no /lib/modules/$(uname -r) and is rejected by validation. In both cases, both golden rungs get skipped wholesale. Without a primary-noovl rung, the next stop would be a rescue shell with no networking, for a board whose root was probably fine and whose only problem was configuration. Structurally, primary is the one root that is always paired with the current kernel, so \u0026ldquo;primary once more, minus the config\u0026rdquo; was a rung the ladder could not do without.\nHow it was found is worth recording too: this rung came out of a design review, not a test. I had the ladder drawn out as a table and traced \u0026ldquo;where does a factory-fresh board go if its first boot hangs?\u0026rdquo;, and there was the hole. It was a bug caught on paper, not reported by hardware, which made it scarier: the first place it would have been stepped on was the field.\nGolden Is Not a Factory Image The most counter-intuitive part of the design. Golden is not a frozen factory copy. It is the last root that booted healthily on the kernel currently sitting in the FAT. Freeze a factory copy instead, and the first kernel update makes its vermagic mismatch; the safety net dies silently, at exactly the moment it becomes needed. So golden is refreshed after every healthy primary boot, and never after booting from golden (overwriting your fallback with a fallback boot would let the ladder eat itself).\nWhy the Marker Is a File The temptation is to pass this state as an environment variable. But procd scrubs its environ before rcS, and, more fundamentally, when a human runs the script by hand over ssh, that variable simply doesn\u0026rsquo;t exist. Both failures are silent. If a safety decision like \u0026ldquo;is it safe to refresh golden?\u0026rdquo; hangs off a signal that can silently vanish, the safety net rots without a sound. A file reads the same for everyone, every time.\nThe vermagic Gate and Two Own Goals To filter out combinations where uname -r matches but the module ABI doesn\u0026rsquo;t, the loader carries the module vermagic string of its build-time kernel and compares it against a .ko read from the candidate squashfs. Implementing this cost two round trips to the hardware:\nThe substitution placeholder had to appear exactly once, but a global sed also rewrote the comparison statement itself, so the gate was comparing against itself and could never fire. After a clean build, the loader got stamped from a stale .ko while the squashfs got the new one, producing an image that rejected its own primary. The build now self-checks that loader and rootfs vermagic match. One Detail from the Rescue Shell The bottom rung, the rescue shell, prints the FAT contents and rewrite instructions, then counts down about 300 seconds, clears the marker, and reboots itself, so that a transient failure on a board with no serial attached heals on its own. Any keypress drops to an interactive shell. The fun trap: this shell is PID 1. reboot becomes kill(1, SIGTERM), and the kernel discards that signal when it\u0026rsquo;s addressed to PID 1. You have to install your own trap ... TERM or the reboot never happens.\nThe Power-Pull Test Everything up to this point is a plausible story. So we manufactured the worst case for real. At the moment sysupgrade had finished writing the squashfs but had not yet written the kernel, we physically pulled the 12V supply.\nItem Result FAT state new squashfs + old kernel + leftover .new file vermagic same build, so it matched → primary passed validation Boot primary came up clean, 144 modules loaded Brick none Not a single line of code differs between before and after that experiment. But what I trusted about this design changed completely. A failure path is not validated until you have deliberately made it fail.\nDisciplines We Picked Up Along the Way The build produces two images, but only one is flashable. The other (a kernel-only debug image with no rootfs) would leave the board rootless if installed, so the image check rejects it even under forced flashing (-F). Never overwrite a live squashfs in place. Write to .new and mv, so the active loop mount keeps the old inode. We learned this by doing cat new \u0026gt; file exactly once; uncached reads started returning I/O errors. If the loader kernel exceeds 6.5 MB, the build fails. The regression where the full rootfs cpio sneaks back into the initramfs is blocked by the build, not by human vigilance. We once made the firmware update grub.conf and then backed it out: that file is owned by the migration tool, which stamps per-board values into it. Ownership boundaries outlive convenience. Lessons A fallback is a state machine, and the central design question turned out to be what consumes the state. Only a hang consumes the marker; a failed validation skips without consuming it. That one distinction holds up the whole ladder. A safety net that isn\u0026rsquo;t regularly refreshed rots. Golden is the latest healthy boot, not a factory image. Never hang a safety decision off a signal that can silently disappear (environment variables). Design review catches a class of bugs that testing can\u0026rsquo;t. The most important rung of this ladder came from staring at a table, not at a board. A failure path is not validated until you have made it fail on purpose. Pulling the plug took one second, and that second turned this design from a story into a fact. ","permalink":"https://pdh0085.github.io/posts/boot-escalation-ladder/","summary":"Once the root filesystem became a file on eMMC, sysupgrade became the act of replacing that file. So what happens when the new root fails to boot? We built a five-rung fallback ladder driven by a single boot_state file, and validated it by literally pulling the 12V supply mid-sysupgrade. Result: 144 modules loaded, no brick. The rung that actually matters was found in review, not testing.","title":"The Boot Escalation Ladder"},{"content":"The Installer Should Type Nothing If you sell subscriber lines rather than routers, a device\u0026rsquo;s value isn\u0026rsquo;t a performance figure. It\u0026rsquo;s how little the installer has to do on install day, and how visible the device is from the office (the NOC) when something goes wrong. If a technician is standing in a living room typing an SSID into a web UI, that labor cost eats the device margin. If the NOC can\u0026rsquo;t see radio conditions, there\u0026rsquo;s no diagnosis, so the answer defaults to \u0026ldquo;roll a truck.\u0026rdquo;\nThe standard for all of this is TR-069 (CWMP). On our 5G FWA routers, the LS500X and NM500G (Qualcomm IPQ8072, based on OpenWrt 25.12), we implemented the whole path and timed it second by second, so that the answer to a carrier\u0026rsquo;s questions is session logs and numbers rather than \u0026ldquo;yes, supported.\u0026rdquo;\nOne thing to nail down before any numbers: every TR-069 measurement below was taken over Ethernet WAN. We have not yet observed a single management session over the cellular path. That path is unmeasured.\nHow a Blank Device Finds Its Management Server The mechanism fits in three sentences. When the device requests a DHCP lease on the WAN, it sends the vendor class dslforum.org and asks specifically for option 43. The operator\u0026rsquo;s DHCP server answers with the ACS address in a sub-option. Since no address is baked into the firmware, the same image ships unchanged to every operator.\nExcept the Feature Had Never Been On This is the heart of the post. The configuration switch had existed for a long time. The code behind it was complete. The build script was even set up to install it. But the package never copied the executable into the image. The binary simply wasn\u0026rsquo;t on the device.\nWorse, it failed silently. The code looks like this:\nnew_url = dhcp_discovery ? (STRLEN(dhcp_url) ? dhcp_url : url) : url; The discovered URL was always empty, so turning discovery on just fell back to the static URL. Not one line of logging. From the outside, it \u0026ldquo;worked\u0026rdquo; perfectly. Which meant every historical note saying \u0026ldquo;we tested option 43\u0026rdquo; had to be re-read as never actually executed. The switch existed, nothing was wired behind it, and even the failure looked like success.\nOn by Default, Latched After First Contact Putting the binary into the image wasn\u0026rsquo;t the end of it. If discovery is on by default, whoever controls DHCP on the WAN side can designate this device\u0026rsquo;s management server. So we made a rule: the moment the device successfully connects to an ACS for the first time, it locks. Discovery is disabled, the learned value is erased, and only the confirmed URL remains. From then on the device talks only to the ACS that provisioned it. The exposure window is the initial installation, not the device\u0026rsquo;s lifetime.\nEven that wasn\u0026rsquo;t a single flag. After latching, two variables still held the same URL, and through the retry path that meant a long ACS outage could reopen discovery, even years later. The missing step was clearing the learned value.\nThe verification is worth writing down too. We kept the ACS dead for 394 seconds and watched that discovery never reopened. We also checked that the test wasn\u0026rsquo;t spinning in place, i.e. that the daemon was actually alive and cycling through retries, because a dead daemon produces the exact same \u0026ldquo;nothing reopened\u0026rdquo; result while proving nothing.\nWe chose the default\u0026rsquo;s condition deliberately as well: not a \u0026ldquo;run once\u0026rdquo; flag, but \u0026ldquo;only when the ACS address is empty.\u0026rdquo; If discovery ever ran again on a device already talking to an ACS, the next DHCP lease could swap out that device\u0026rsquo;s management server.\nAnd one more boundary, stated precisely: option 43 was measured in the Ethernet WAN installation scenario. A cellular-only installation would need the URL provisioned at the factory.\nThe Measurement From power-on, through receiving the configuration the operator had queued in advance (SSID, Wi-Fi key, disabling the setup wizard), to being in service. We rehearsed it twice; both runs were identical.\nSegment Measured Cold start → first ACS contact (Inform) 100.9 s Cold start → provisioning complete 101.5 s Config received and applied after contact 0.5 s Power to service in under two minutes, and almost all of it is boot time. The provisioning itself takes half a second.\nThe first lines on the ACS console summarize the whole picture:\ninform events=[\u0026#34;0 BOOTSTRAP\u0026#34;, ...] send_rpc SetParameterValues -\u0026gt; status=0 # SSID + Wi-Fi key send_rpc SetParameterValues -\u0026gt; status=0 # disable setup wizard send_rpc GetParameterValues -\u0026gt; Device.WiFi.SSID.1.SSID = CarrierWiFi 0 BOOTSTRAP is the device saying \u0026ldquo;this is the first contact with a management server in my life.\u0026rdquo;\nWe verified over the air, not in the UI. Confirming that a configuration value changed is not enough, so we confirmed the radio actually restarted and was beaconing that SSID, by scanning from a second device sitting next to it. This project has produced several cases of \u0026ldquo;the status light is green but nothing is actually passing.\u0026rdquo;\nRemote Upgrade When the ACS issues a download command, the device writes the image to the inactive slot, reboots, and in the first session on the new firmware sends the success report (TransferComplete, FaultCode 0). About 92 seconds from command to report. A corrupted image is bounced with an error in 3.9 seconds, without touching the flash.\nOne thing we don\u0026rsquo;t hide: images before a certain version never sent the completion report at all. The report record was written to volatile storage, and the reboot that the upgrade itself triggers wiped it. The upgrade succeeded; the ACS just never found out. It\u0026rsquo;s fixed now, and when we demo on an older unit, we say so.\nCan the Office Call the Device? To reach a device at the moment a customer calls in, the ACS has to be able to call the device. We measured both paths.\nOver HTTP, a firewall pinhole is generated automatically, open only to the ACS address. Call to established session: 0.58 s. The interesting verification here isn\u0026rsquo;t the success, it\u0026rsquo;s the refusals. A call from any other address is rejected, a wrong password gets 401, and if no ACS address is configured, the rule doesn\u0026rsquo;t exist at all.\nOver XMPP (TR-069 Annex K), the device holds one outbound session, so zero inbound ports are open. Call to session: 0.65 s. That number, though, is from a test server. Against a production ACS (GenieACS) we have confirmed the session stays up across the internet with certificate verification passing; the final step, an inbound call pushed from that side, is still pending. On CGNAT (most 5G lines) this is the path that matters, so we keep that distinction exact rather than blurring it.\nThis path surfaced a defect of its own: the XMPP client crashed on TLS handshake failure. A null-dereference bug in the library, fixed in our fork of the package.\nOne line we drew on purpose: the admin password cannot be set through the ACS. By design it is not writable remotely. Whoever compromises the management channel does not get the admin account thrown in. The initial credentials on the shipping label are generated per unit, and that is all we will say about them.\nThe Blacklist That Silenced Telemetry Forever To prevent \u0026ldquo;can\u0026rsquo;t diagnose, so roll a truck,\u0026rdquo; the NOC needs RSRP/RSRQ/SINR, operator, band, and attach state. We exposed all of it through the TR-069 data model, with six items carried in the periodic report.\nAt some point, though, the modem fields started coming back empty. The cause was a permanent blacklist in a library underneath the data model. Ten consecutive cycles of slow modem responses, and it kills that data source forever; after that it quietly answers \u0026ldquo;no modem\u0026rdquo; defaults, permanently. A service restart doesn\u0026rsquo;t clear it. And it poisoned not just query responses but the periodic reports: 5 of 43 test sessions went out with a blank IMEI.\nIn other words, one slow 50-second window could silence a device\u0026rsquo;s cellular telemetry for the rest of its life. Behind CGNAT, where the periodic report is effectively the only monitoring path, that is quiet blindness.\nThe fix replaces the permanent ban with a 30-second grace period and retry. Worst case, a 5-second delay every 30 seconds, in exchange for no permanent loss. We drilled the whole cycle on real hardware (reproduce it, fix it, watch it recover) and verified it after a factory-clean flash: the stronger check, proving the fix is in the image, not just in the source tree.\nThe Numbers All measured over Ethernet WAN. The cellular path remains unmeasured.\nItem Value Zero-touch: cold start → in service 101.5 s (first contact 100.9 s, provisioning 0.5 s) ACS remote upgrade ~92 s, completion report received Corrupt image rejection 3.9 s, flash untouched ACS call → session (HTTP, open only to ACS address) 0.58 s ACS call → session (XMPP, zero inbound ports) 0.65 s (test server) Periodic report pollution (during the bug) 5 of 43 sessions with blank IMEI → 0 after the fix What We Keep Most of what this project taught us is about verification. A silent fallback disguises an unverified feature as a working one; if flipping the switch does nothing behind the scenes, that fact has to show up in a log. When you enable a convenience feature by default, design its exposure window with it. The security decision isn\u0026rsquo;t on versus off, it\u0026rsquo;s how long the window stays open, and you only get to claim it\u0026rsquo;s latched after watching it stay latched for real time (394 seconds, in our case).\nVerify against the final effect, not the setting: the SSID actually in the air rather than the string in the UI, the image after a factory-clean flash rather than the source tree. Defensive logic that remembers failure forever eventually becomes the failure; grace and retry is almost always cheaper. And measurement conditions are part of the number: \u0026ldquo;measured on Ethernet\u0026rdquo; and \u0026ldquo;test-server figure\u0026rdquo; belong next to the values they qualify, every time those values are quoted.\n","permalink":"https://pdh0085.github.io/posts/zero-touch-in-101-seconds/","summary":"A factory-fresh router found the carrier\u0026rsquo;s management server on its own, pulled its configuration, and was in service in 101.5 seconds, 100.9 of which were boot time. On the way to that number, we discovered a feature that our docs said we supported but that had never once executed.","title":"From Sealed Box to In Service in 101 Seconds"},{"content":" The Symptom: A 502 That Only Sometimes Reproduces The report from the field went like this: the web UI\u0026rsquo;s \u0026ldquo;Upload \u0026amp; Verify\u0026rdquo; firmware upload dies with HTTP 502. But not always. On a freshly booted board it succeeds. That \u0026ldquo;sometimes it works\u0026rdquo; turned out to be the biggest hint. Of everything in this project, this is the problem where the distance between symptom and cause was the longest.\nReproducing It LuCI\u0026rsquo;s upload streams the 19 MB image into /tmp. /tmp is tmpfs, which is RAM. And at this point in the project, the root filesystem itself was an initramfs unpacked into tmpfs, which meant about 70 MB of /rom was pinned and unreclaimable. tmpfs pages can\u0026rsquo;t be dropped the way page cache can.\nUpload on a board whose free RAM has shrunk, and the OOM killer takes out cgi-io; uhttpd returns 502.\nCondition MemAvailable Result Freshly booted board ~81 MB 200 Simulated low memory ~21 MB 502 An exact match for what customers were seeing.\nThe Most Plausible Quick Fix: zram (It Failed) The first thing I tried was zram-swap. Even with compressed swap enabled and 44 MB swapped out, all four hardware tests returned 502. On a single 400 MHz Lakemont core, the kernel\u0026rsquo;s reclaim-and-compress path simply cannot keep up with the rate of an upload burst.\nThe lesson was blunt: instead of squeezing memory harder, we should never have been holding it in the first place.\nThe Real Fix, in Outline Put the root filesystem on the FAT partition as a squashfs file, loop-mount it, and stack an overlayfs on top, the upperdir being a 64 MB ext4 image file on the same FAT, also loop-mounted. Unlike tmpfs, squashfs pages are file-backed page cache: under memory pressure the kernel can drop them and read them back later. They become reclaimable.\nStep 1: Prove the squashfs Is Actually a Bootable Root Before touching the boot path, I copied the built squashfs onto a running board, loop-mounted it, and chrooted in. Two traps surfaced immediately.\nFirst, the file must be padded to a 256 KB boundary. Truncate it to its exact size and the loop device rounds the capacity down, and the mount dies like this:\nSQUASHFS error: Failed to read block ...: -5 Second, the compression has to be gzip. With XZ, reading the full tree takes over 90 seconds on this CPU. After switching to gzip, individual file access is under a second, and a full-tree read settles at about 81 seconds. The remaining time is I/O bound (squashfs over loop over vfat), not decompression, which also means switching further to lz4 would buy nothing.\nStep 2, Attempt 1: Failure, and a Hung Board The first attempt was to loop-mount in a preinit hook and exec switch_root. busybox refused:\nBusyBox switch_root ... Usage: ... PID must be 1. NEW_ROOT must be a mountpoint. A preinit hook is a subshell forked by procd, so it is not PID 1. (The reason OpenWrt\u0026rsquo;s stock overlay transition works fine is that it uses pivot_root, which has no PID 1 requirement.) Worse: when an exec fails like this, your process has already been replaced, so the fallback code written further down the script is never reached.\nThe board hung. What saved it was a one-shot flag planted in advance: power-cycle, and it booted the old path. This was the moment that safety pattern actually paid for itself; the full story belongs to the next post in this series.\nStep 2, Attempt 2: Rewrite PID 1 Itself The process that is PID 1 is the kernel initramfs\u0026rsquo;s own /init. That script is already the thing that copies the rootfs into tmpfs and calls switch_root, so the answer is to rewrite it to try the squashfs path first. Things I learned doing that:\nAt /init time, /dev is empty (no devtmpfs). The nodes you need (mmcblk0p1, loop0, loop-control) have to be created with mknod by hand. OpenWrt\u0026rsquo;s modprobe is kmodloader. In a loader, the reliable move is full-path insmod in dependency order. (Eventually I built FAT and NLS into the kernel and eliminated the modules altogether.) The squashfs loop pins its backing file on the FAT, so even after switch_root drops the FAT mount point, reads keep flowing through the loop device\u0026rsquo;s fd. loop0: detected capacity change from 0 to 40960 This time it went through.\nHow Much Better It Got, and Where Honesty Is Required Here are the numbers.\nMetric Before After Loader kernel size 19,804,672 bytes (~19.8 MB) 5,034,496 bytes (~5.0 MB) Freeing unused kernel image (initmem) 67456K 1564K Peak boot RAM ~133 MB ~2 MB Steady-state MemAvailable ~116–134 MB unchanged Two things need to be said plainly.\nFirst, the 5 MB kernel is not this post\u0026rsquo;s work. It comes from the minimal-loader initramfs conversion that followed a day later, which is the next post\u0026rsquo;s story. The two changes are a day apart and easy to conflate; this post\u0026rsquo;s share ends at \u0026ldquo;the root is no longer tmpfs, and its pages are reclaimable.\u0026rdquo;\nSecond, an old internal document credited this work with \u0026ldquo;about 147 MB freed.\u0026rdquo; That number was never true, and it was later corrected. Steady-state MemAvailable is essentially unchanged, because those 67 MB were being returned by free_initmem() at the end of boot anyway. The metrics that actually moved are peak boot RAM and the reclaimability of /rom during an upload burst, and it\u0026rsquo;s the latter, the move to squashfs and not the loader shrink, that killed the OOM. The most common lie in optimization write-ups is picking the metric that looks like it improved. One more caveat: the ~81 MB in the reproduction table and the ~116–134 MB above were measured on different images, so they don\u0026rsquo;t compare directly.\nVerification, and the Next Wall The upload OOM was gone. During a 40 MB upload, MemAvailable held at about 117 MB with zero OOM kills.\nA different limit appeared instead. cgi-io computes both md5 and sha256 over the whole upload, and on this CPU that is CPU bound. A 19 MB image takes about 51 seconds, which fits under uhttpd\u0026rsquo;s default script_timeout=60, so it returns 200. A 40 MB upload blows past 60 seconds and returns 502, but this time it is not OOM. Raise script_timeout to 300 and it completes in about 108 seconds with a 200.\nSame status code, completely different cause. Both 502s in this post are the reason not to infer the cause from the symptom code.\nLessons What you put in tmpfs cannot be dropped under memory pressure. Before parking anything large in RAM, ask whether it is reclaimable. And compressed swap only works when the CPU can keep up; sometimes the answer is not squeezing harder but restructuring so the memory is never held. No fallback code can live after a point of no return like exec. Plant the fallback outside that boundary, in advance. In an optimization report, name the metric that actually moved. Credit a metric that didn\u0026rsquo;t move and the document eventually disproves itself. Related: the same error code does not mean the same cause. Both 502s here had different reasons. ","permalink":"https://pdh0085.github.io/posts/getting-the-rootfs-out-of-ram/","summary":"Firmware uploads through the web UI were dying with HTTP 502. The web server was innocent. The root filesystem was sitting in RAM, with about 70 MB of /rom pinned and unreclaimable, and zram didn\u0026rsquo;t help. The fix was moving the root onto a loop-mounted squashfs, and along the way admitting that an old claim of \u0026lsquo;~147 MB freed\u0026rsquo; had never been true.","title":"Getting the Root Filesystem Out of RAM"},{"content":"A Two-Minute Window Our 5G CPE lives in a customer\u0026rsquo;s home or office, somewhere we cannot reach.\nWhen you push a firmware update to a device like that, exactly one stretch of the process is frightening. Download the new image, verify it, erase storage, write it back. If power fails in the few minutes between the erase and the end of the write, the device has no rootfs to boot. It\u0026rsquo;s a brick.\nAnd a brick requires a human to go there in person. Every other automatic recovery feature we\u0026rsquo;ve built stands on one assumption: the device boots. If it doesn\u0026rsquo;t boot, all of it is void.\nThe textbook answer is A/B partitioning: keep two copies of the system, write to one while you can still boot the other. If the write dies, you simply boot the old slot, and the brick window never exists in the first place. This blog has covered rollback drills on a product that has A/B slots; this product couldn\u0026rsquo;t afford that luxury. There is no room. A second slot would need 226MB, storage is exactly 1024MB, and none of it is spare. Every partition we might have raided had a job. Changing the partition table is only an option for future production runs, which means units already sold would never benefit anyway. And the window we wanted to close was precisely on those units.\nThe Thing That Was Already There So we changed the question. If we can\u0026rsquo;t create a second system, is there a second system that already exists?\nThere was: the recovery partition. Flashed at the factory, untouched during normal boots, a complete Linux with its own kernel and filesystem. And the bootloader already contained, compiled in, a branch that boots recovery instead of the main system when it reads a particular value.\nPut together, the change looks like this:\n[before] the running system erases and rewrites itself └ from the first erase to the last write = the brick window [after] stage the image on a separate volume → set a cookie → reboot boot into recovery → recovery erases and writes the main system → clear the cookie → reboot └ if power fails anywhere in between, the cookie is still there, so the unit boots back into recovery The whole thing rests on one piece of ordering:\nThe cookie is cleared last.\nOnly a finished flash clears the cookie. So if power dies mid-flash, the cookie is still there on the next boot, the unit lands in recovery again, and it finishes the job it started. The staged image lives on a separate volume the flash never touches, so it survives intact.\nWhen to Give Up, When to Hold On One more judgment call goes into the design. Things can fail inside recovery too, and you have to decide when to abort and when to dig in.\nSituation Action Why Failure before erasing (image verification fails, etc.) Abort cleanly. Clear the cookie, return to the original system The main system is still intact. Going back to an intact system is always right Failure after erasing Retry 5 times; if it still fails, anchor in recovery. Keep the cookie, do not reboot There is no system to go back to. Rebooting here turns the box into something that power-cycles itself The second row matters. A box that keeps power-cycling itself is worse than a box that sits still. A box that sits still can be rescued over a serial console; a box that reboots every three seconds can\u0026rsquo;t even be caught.\nBut Recovery Collapsed First With all of this built, we ran the first power-cut test. The unit fell into an infinite reboot loop. We counted 24 iterations before cutting it off over the serial console.\nOur updater never ran. Not once.\nThe cause was in the very early stage of the recovery boot. An interrupted flash leaves the main system partition in an unmountable state. And a vendor script that runs at recovery startup was written to trigger a reboot when its attempt to mount that partition failed. Power back on, the partition is in the same state, the mount fails again, it reboots again. Our updater ran much later in that sequence, so its turn never came.\nYou have to laugh at the shape of this: recovery was rebooting itself in exactly the situation that is its reason to exist. Whoever wrote that script presumably thought \u0026ldquo;if we wait, it\u0026rsquo;ll attach eventually.\u0026rdquo; Usually a fine assumption. But it was a design that never contemplated a partition that can permanently fail to attach.\nThe Fix All we did was take the two lines in that script consisting solely of /sbin/reboot and replace each with a single kernel-log line. The mount attempts themselves stayed exactly as they were.\nThere was a reason we couldn\u0026rsquo;t skip the attempts. Inside that function the partition numbers increase in order, and one of the volumes attached later holds the marker file that decides whether our updater is selected at all. Skip the mounting wholesale and the marker can\u0026rsquo;t be read, and the boot branches into the vendor\u0026rsquo;s default path instead of our updater. The only thing that needed fixing was the reboot on failure. Nothing else.\nThis is modifying someone else\u0026rsquo;s code, and the first file that runs in the fallback system at that, so we layered safeguards:\nThe regex is a full-line match: only a line that is exactly /sbin/reboot gets replaced. A reboot with arguments, or in any other context, is untouched. We verify the replacement count matches expectations and that zero reboot calls remain. The modified file is syntax-checked again, and if anything is off we automatically roll back to the vendor original. A syntax error in this file means losing the fallback system itself. The vendor original is always preserved separately. If this guard is not in place, the flash does not start at all. And Then We Actually Pulled the Plug The machinery was complete, but machinery is preparation, not verification. The real question was singular:\nWith the guard in place, if we pull the plug mid-flash, does the box come back on its own and finish?\nSo we pulled it, for real, on the exact line where the erase begins. After that no human hand touched the unit; plugging it back in was the only intervention.\n--- first boot after the power cut --- attempt to attach the system partition → fails \u0026#34;... not yet created, rebooting\u0026#34; ← the vendor\u0026#39;s log text remains as-is \u0026#34;system volume did not attach -- continuing instead of rebooting\u0026#34; ← this, instead of a reboot cache partition attaches ← the marker is readable --- the marker selects our updater --- recovery updater starting (cookie=...) reboot-loop guard: present attempt 2 (committed=1) ← the interrupted flash is recognized checksums verified erasing and writing ... -- the point of no return rootfs written / boot image written finished: OK (flashed from recovery on attempt 2) Power cut → healthy boot about 2 min 30 s, hands off Vendor reboot loops 0 (24 consecutive in the previous test) State after return cookie cleared · staging auto-deleted · 0% WAN packet loss Automated acceptance checks 53 passed / 0 failed The brick window is closed. Without A/B partitions, and on units already sold.\nA note on reading these logs: the vendor\u0026rsquo;s ... rebooting message remains verbatim. What we changed is the actual reboot call beneath it. Whether a reboot really happened must be judged from the next line. Miss this, and you will read a successful log as a failure.\nThe Trap Only Real Hardware Could Catch There is one thing we learned only after burning an entire upgrade run.\nAttach a UBI volume on Linux and a device node like /dev/ubi7_0 appears. Or so we believed. In reality the kernel only creates the kernel object; the node under /dev is created by a userspace hotplug daemon.\nBut by the time our code runs on the upgrade path, every service has already been shut down. There is no daemon left to create the node. It never appears.\nThe symptom was vicious. The kernel log prints, clear as day:\nubi7: attached mtd28 (name \u0026#34;recoveryfs\u0026#34;) And on the very next line, our code dies:\ncould not attach recoveryfs (mtd28) Attached, says the kernel; could not attach, says our code as it exits. No amount of staring at the code reveals it, and no amount of ordinary Linux reasoning derives it. We ended up reading the major:minor numbers straight out of sysfs and creating the node ourselves.\nWhere to hook in had the same flavor. We naturally attached our logic to platform_do_upgrade (the function that performs the actual upgrade), but by then the system has already pivoted to a ramdisk holding only a fixed list of binaries. Our script wasn\u0026rsquo;t there, and neither were cmp or df. It only worked after moving one stage earlier, to platform_pre_upgrade.\nLimitations The feature is finished, but it is not a cure-all. These belong in the post.\nThe first upgrade of old units already in the field is still dangerous. Those images don\u0026rsquo;t contain this updater, so they flash the old way. Only after that upgrade succeeds are they protected. This is structural; there is no way around it. A clean flash that doubles as factory reset does not take this path yet. Clean flashing signals config wipe through a separate flag, and we have not yet measured whether that flag survives the detour through recovery. \u0026ldquo;Clean install that silently keeps old settings\u0026rdquo; is a worse failure than a slow one. Until it\u0026rsquo;s measured, clean flashes take the old path. We modify the recovery partition. The vendor original is backed up, but the partition now differs from the factory image, a matter that needs to be worked out with the production process. On failure, we fall back to the old method. In fact, the very first live run was rejected because of the hotplug trap above, and the fallback worked, completing the upgrade without damage. We ended up field-proving the fallback path by accident. Lessons A/B partitioning is the answer, but it isn\u0026rsquo;t the only answer; it\u0026rsquo;s worth looking first for a second system already on the board, which in our case had been there since the factory. The atomicity here is made entirely out of ordering. Clearing the cookie last is the single decision the whole design stands on. Recovery logic also has to decide when to give up, because retrying a doomed operation forever isn\u0026rsquo;t recovery, it\u0026rsquo;s a new failure mode. And two things about process: before you modify a fallback system, build the rollback first (we added syntax checking and automatic rollback because that file is the last safety net, not out of timidity), and at the end you have to actually pull the plug. Building all the machinery is not verification. Until we pulled it, we did not know whether any of this worked.\n","permalink":"https://pdh0085.github.io/posts/closing-the-brick-window/","summary":"If power fails mid-flash, the device is a brick. We had no room for A/B partitions: a second slot needs 226MB and the 1024MB of storage had none to spare. So we closed the window with the recovery partition that ships from the factory anyway, and then we actually pulled the plug to prove it. Back to a healthy boot in about 2 minutes 30 seconds, no human hands.","title":"We Pulled the Plug Mid-Flash"},{"content":" We Made It to Userspace In an earlier part of this series we built the x86/quark subtarget and its toolchain. Time to hook the kernel into the GRUB menu and boot. The short version: the kernel came up. It reached kmodloader: done loading kernel modules, so userspace was alive.\nBut the early boot output was garbage characters, the console went completely silent partway through, eMMC and USB failed to probe, and the ethernet interfaces didn\u0026rsquo;t exist at all, so the PC on the LAN never got an IP. Being x86 does not mean a board just boots, and none of this is unusual for embedded x86. It\u0026rsquo;s the normal shape of it. There were four walls to climb, and in hindsight they all had the same shape: the kernel wasn\u0026rsquo;t receiving something it needed from the firmware.\nWall 1: Garbled earlycon Output # wrong earlycon (garbled output) earlycon=uart8250,mmio32,$ADDR,115200n8 # correct form — omit the baud earlycon=uart8250,mmio32,$ADDR If you specify a baud rate, the kernel reprograms the divisor assuming the standard 1.8432 MHz UART clock. The Quark\u0026rsquo;s UART clock is much higher than that, so every character comes out mangled. Omit the baud and the kernel inherits the setup GRUB already programmed. One tip: add keep_bootcon and earlycon keeps printing the whole way through, so you can watch everything while you fix the real console.\nWall 2: There Is No Real Console After legacy console [ttyS1] enabled, silence. The answer was already sitting in the log:\nserial 0000:00:14.1: ignoring port, enable SERIAL_8250_LPSS to handle The Quark\u0026rsquo;s UARTs are PCI devices (8086:0936), and nothing claims them unless CONFIG_SERIAL_8250_LPSS=y. With it enabled, 00:14.1 became ttyS0 and 00:14.5 became ttyS1, reporting base_baud = 2764800, which is 44.2368 MHz / 16. That\u0026rsquo;s the numeric confirmation of why specifying a baud in wall 1 was wrong.\nWall 3: eMMC, USB, and Ethernet All Dead The symptoms ran in three directions: sdhci failed to probe with -16 (genirq: Flags mismatch irq 0 ... (mmc0) vs. ... (timer)), USB threw IRQ warnings, and the ethernet driver never probed at all. I chased them separately for a while, until one log line pulled everything together:\nAPIC: ACPI MADT or MP tables are not detected There was one cause behind all three: CONFIG_ACPI was off. OpenWrt\u0026rsquo;s shared x86 kernel config disables ACPI and every x86 subtarget re-enables it individually, a detail I missed when creating the new subtarget. The causal chain:\nCONFIG_ACPI=n → no MADT/_PRT → IOAPIC never configured → PCI IRQ routing wiped out → sdhci (eMMC), USB, ethernet all fail When several symptoms appear at once, it pays to suspect the shared foundation underneath them, something as low-level as IRQ routing, before chasing each symptom on its own.\nWall 3.5: Enabling ACPI Isn\u0026rsquo;t Enough With ACPI on, the next message was ACPI BIOS Error (bug): A valid RSDP was not found. The Quark\u0026rsquo;s UEFI hands the RSDP over via the EFI path, but the custom handoff in this board\u0026rsquo;s GRUB fork doesn\u0026rsquo;t pass it through to a mainline kernel. So I forced the address with a kernel parameter: acpi_rsdp=0x0f00e014.\nWhere did that address come from? From dmesg | grep RSDP on the known-good Yocto boot. This is the first appearance of a technique that recurs throughout the series: when a working system is sitting next to you, it is a more accurate reference implementation than any document. One caveat: that address is specific to this firmware build. If the firmware changes, it changes, so read it again. And for the record, pci=biosirq does not work here; this is a UEFI-only board with no legacy PCI BIOS.\nWall 4: Still No Ethernet IRQs were alive, and eth0 still didn\u0026rsquo;t exist. The Quark GbE is PCI 8086:0937, and stmmac_pci.c (the driver you\u0026rsquo;d expect) only carries the generic Synopsys IDs and doesn\u0026rsquo;t know this device. The driver that actually claims it is dwmac-intel.c, i.e. CONFIG_DWMAC_INTEL. With it enabled, intel-eth-pci bound 00:14.6 as eth0 and 00:14.7 as eth1, and link came up.\nThe final kernel command line, in summary:\nconsole=ttyS1,115200n8 earlycon=uart8250,mmio32,$ADDR acpi_rsdp=0x... reboot=p net.ifnames=0 biosdevname=0 Bonus: The Board Cannot Reboot The reboot=p in that command line is the fifth story. Running reboot hung right after reboot: machine restart. This kernel is built with CONFIG_EFI=n, so the EFI reboot step is an empty stub, and control falls through to machine_real_restart(MRR_BIOS), a far jump to the legacy reset vector at 0xFFFF0, where there is no BIOS. Worse, that function is __noreturn, so the CF9 and triple-fault fallbacks that come after it in the code are never reached at all. The fix is reboot=p: a CF9 hard reset.\nThere\u0026rsquo;s an epilogue. Because of this bug, the reboot -f at the end of sysupgrade took the same path. The image had been written correctly, but the board hung, so it looked exactly like a failed update. Boards already in the field can be rescued with echo pci \u0026gt; /sys/kernel/reboot/type before rebooting.\nLessons A kernel config trimmed by a vendor (or a distro) reflects what they needed, not what this hardware needs, so every disabled option in an inherited config is a suspect. When several seemingly unrelated symptoms show up together, check the shared foundation first. Here it was IRQ routing. A working firmware next to you beats any document as a reference implementation. If a system can be asked for the right answer, ask it. ","permalink":"https://pdh0085.github.io/posts/four-walls-to-first-boot/","summary":"The kernel came up fine. There was just no console, no disk, and no ethernet. Four walls stood between our Quark X1000 board and a working OpenWrt first boot, and three of the symptoms turned out to converge on a single disabled kernel option: CONFIG_ACPI.","title":"Four Walls on the Way to First Boot"},{"content":"The Requirement, in One Line The requirement on our 5G CPE fit in a single sentence.\nPlug in the USB-C cable and the PC sees a network device. No driver installation. Windows, macOS, and Linux.\nOne sentence, but all of its weight sits in the last line.\nA Linux USB gadget can present itself to a host as a network device in several different ways, and the problem is that none of the obvious ones satisfies all three operating systems.\nFunction Windows macOS Linux ECM (what we had been shipping) ✗ ✓ ✓ RNDIS ✓ ✗ ✗ NCM ✓ ✓ ✓ Looking at the table, the answer seems obvious. And in the end it really was NCM. What this post is about is the time it took to get there.\n\u0026ldquo;Just Put In Both\u0026rdquo; The first idea anyone has is to expose both ECM and RNDIS and let each host pick the one it understands.\nWe tried. The USB controller refused.\nOut of memory It wasn\u0026rsquo;t memory that ran out, it was endpoints. A USB device has a hardware-fixed budget of communication channels, and this module was already spending most of its budget on several serial ports and a diagnostic channel. There was no room for a second network function.\nTo make room, we would have had to give up a serial port. In fact, looking at the other configuration combinations the module vendor offers, every one that carries multiple network functions sacrifices serial to do it. We were using those serial ports for diagnostics and control, so they were not negotiable.\nSo we had to pick exactly one, and the only one that works on all three operating systems was NCM.\nThe Thing You Must Not Change: the PID There is a trap here.\nA USB device identifies itself by its VID (vendor ID) and PID (product ID), and host-side drivers are bound to that combination. The Linux serial drivers, the Windows driver installer the vendor distributes, all of them.\nWhich means: change the PID and every serial port on the host dies. You would be trading your diagnostic path for the network fix.\nSo what we actually did was keep the PID and swap only the network class. Fortunately NCM needs the same number of endpoints as the ECM it replaced, so we could slot it into that exact position without disturbing the rest of the configuration.\nThen Every Module Came In Different At this point real hardware threw us a problem we hadn\u0026rsquo;t planned for.\nThese were modem modules of the same model, yet each incoming unit arrived with a different USB configuration value. Any of four values could be inside, and the four differed in exactly one thing: the network function.\nValue Network function Result A no Ethernet class at all never enumerates as a network device B MBIM macOS ✗ C RNDIS macOS ✗ D NCM all three ✓ Our fix targeted D and only D. So a unit that arrived as A, B, or C never boots into the configuration we fixed, no matter how correct the code is.\nTwo roads from here:\nFix all four configurations to NCM. Converge every unit onto one configuration at first boot. We chose the second, because four PIDs means four of everything on the host side: four driver bindings, four sets of documentation, four support procedures. Converge to one, and every unit in the world looks identical to every host. That is the direction that shrinks support cost.\nSo first boot got a normalization step for the configuration value. The hardware verification was unambiguous. We deliberately put a unit into state A, flashed the new firmware, and on its first boot it corrected itself to D and restored the MAC pinning as well.\nNames Will Fool You This work added four automated checks: the configuration value, the actually-bound function, bridge membership, and MAC pinning.\nWhy the second one exists is the point of this section.\nMBIM also creates a network device named usb0. So a check that only asks \u0026ldquo;does usb0 exist?\u0026rdquo; will pass a unit that is unusable on macOS.\nWe didn\u0026rsquo;t figure this out by reasoning. We deliberately injected an MBIM configuration and watched the check pass. So the check was changed from \u0026ldquo;the name\u0026rdquo; to \u0026ldquo;the function actually bound,\u0026rdquo; and verified in both directions: a healthy unit passes, an injected fault fails. An interface name is not an implementation, and a check that looks only at the name will pass a wrong implementation that happens to share it.\nMAC pinning is a similar story. The generic NCM driver does not read the permanent MAC the module vendor programmed in, so the address changed on every boot. From the host\u0026rsquo;s point of view, a brand-new device appeared at every plug-in, and network profiles piled up. We fixed it by explicitly pinning the vendor MAC during configuration, and confirmed it survives a reboot.\nWe Measured 900 Mbit/s. It Was a Lie. With the function working, we measured throughput. The first result was in the 900 Mbit/s range.\nWe almost celebrated. Then arithmetic intervened: USB 2.0\u0026rsquo;s theoretical maximum is 480 Mbit/s, and this number was above it. When a measurement is physically impossible, the measurement is wrong.\nHere is what had happened. The test PC was attached to the same subnet twice, once over Ethernet and once over USB. In that state, telling the benchmark tool \u0026ldquo;use this IP as the source\u0026rdquo; makes it change the source address, not the interface. A large share of the traffic flowed over Ethernet, and that is what produced the 900.\nWe re-measured with the interface bound explicitly, and cross-checked against the USB interface\u0026rsquo;s own byte counters.\nDirection Measured PC → router 315 Mbit/s Router → PC 365 Mbit/s That also matched what users had actually been seeing on Windows (~300 Mbit/s).\nWhere the Bottleneck Was Mattered Once those numbers came in, the natural question surfaced inside the team: NCM doesn\u0026rsquo;t ride the hardware-accelerated path, so is that why it\u0026rsquo;s slow? And if so, should the configuration choice be reconsidered?\nWe checked, and the link was negotiating at High Speed (480 Mbit/s). Accounting for protocol overhead, 315/365 is the practical ceiling of USB 2.0.\nSo the bottleneck was neither NCM nor the CPU. It was the physical link, which means there is no performance-based case for revisiting the configuration choice. Any of the other functions would have hit the same wall.\nPinning this down mattered, because an unanswered question like this comes back every six months. A question left open keeps demanding re-review.\nAnd It Almost Didn\u0026rsquo;t Ship Finally, the scariest part of this whole job.\nWe flashed the first image, and the USB configuration change wasn\u0026rsquo;t in it.\nWhen the build system decided which packages to recompile, the path holding our modified file was not in its change-mapping. So the change went undetected, and a stale, previously-built artifact went into the image. With no error whatsoever.\nThere was exactly one way it got caught: opening the built image\u0026rsquo;s filesystem and looking. A successful build does not mean your change is in the image, and if you skip the pre-release image inspection, this class of omission gets discovered in the field.\nSince this incident, the build script\u0026rsquo;s change-detection scope has been widened, and inspecting image contents right before release is now a fixed step.\nLessons \u0026ldquo;Support all three\u0026rdquo; is not a feature request, it\u0026rsquo;s a constraint that narrows the options down to one. And what actually decided the choice wasn\u0026rsquo;t software design but a hardware resource, the endpoint budget. \u0026ldquo;Just put in both\u0026rdquo; usually doesn\u0026rsquo;t survive contact with it. Change an identifier and you change the host\u0026rsquo;s whole world. Keeping the PID and swapping the contents is almost always the better trade. Never assume incoming parts are uniform. Absorbing the variance with first-boot normalization is cheaper than absorbing it with inspection. Check the implementation, not the name, and the only way to trust that check is to inject a fault against it. When an impossible number appears, suspect the measurement. The question isn\u0026rsquo;t closed until you know where the bottleneck actually is. Build success doesn\u0026rsquo;t mean your change made it in. You know only after opening the image. ","permalink":"https://pdh0085.github.io/posts/one-usb-c-three-operating-systems/","summary":"Our 5G CPE had to enumerate as a network device on Windows, macOS, and Linux, driver-free. ECM covered Mac and Linux, RNDIS covered Windows, and putting both in made the hardware refuse. This is the story of finding the one answer that satisfies all three, and of distrusting our own first benchmark: 900 Mbit/s that turned out to be a lie. The real numbers were 315/365 Mbit/s, the practical ceiling of USB 2.0.","title":"One USB-C Port, Three Operating Systems"},{"content":" The Target The core inside the Quark X1000 is Lakemont: i586, no MMX, no SSE, no SMP, and it does have an x87 FPU. Those four facts dictate every toolchain decision in this post.\nI created a new x86/quark subtarget in OpenWrt with the CPU type set to lakemont. The flags started out like this:\n-march=lakemont -mtune=lakemont -Wa,-momit-lock-prefix=yes -momit-lock-prefix is there because on a uniprocessor core the lock prefix does nothing useful. A reasonable-looking starting point.\nThe First Build Failure The toolchain build stopped while compiling musl:\nsrc/math/i386/fabs.c: error: impossible constraint in \u0026#39;asm\u0026#39; fabs(). Absolute value, about the simplest math function libc has, and the compiler is saying it cannot satisfy an inline-asm constraint there. Why? A missing instruction? No.\nThe Cause GCC\u0026rsquo;s -march=lakemont defaults to -msoft-float. The compiler assumes this CPU has no FPU at all and refuses to touch the x87 registers. But musl\u0026rsquo;s i386 port implements its math functions as x87 inline asm, and it has no soft-float i386 variant. Feed asm with x87 register constraints to a compiler that has x87 disabled and you get impossible constraint.\nMeanwhile, the hardware really does have an x87. The old Yocto image had been running an i586 x87 userspace all along, and its kernel had MATH_EMULATION turned off. The compiler\u0026rsquo;s assumption simply disagreed with the hardware.\nWhen you target an old ISA, the trouble doesn\u0026rsquo;t come from \u0026ldquo;the instruction isn\u0026rsquo;t there.\u0026rdquo; It comes from the toolchain\u0026rsquo;s defaults assuming a different machine than yours.\nThe Fix Add -mhard-float. The final flags:\n# include/target.mk — i386 block CPU_CFLAGS_lakemont = -march=lakemont -mtune=lakemont -mhard-float -Wa,-momit-lock-prefix=yes To make sure flipping one flag didn\u0026rsquo;t drag anything else along with it, I checked gcc -Q --help=target: x87 on, MMX and SSE still off. Which is what it showed.\nOne more thing. Going from soft-float to hard-float is a floating-point ABI change. Objects built under the old assumption must not mix with the new ones, so I deleted build_dir/{toolchain,target}-i386_lakemont* and staging, and rebuilt from scratch.\nVerification The flag was fixed and the build went through. That is not the place to stop, because \u0026ldquo;I passed the flag, so it must be fine\u0026rdquo; is not verification.\nI scanned the 285 ELF binaries and kernel modules in the build output:\nCheck Result MMX/SSE instructions 0 lock prefixes 0 x87 instructions in libc present (hard-float confirmed) In a cross toolchain, any package is free to override -march or ignore your CFLAGS, and the build will still succeed silently. The failure shows up later, on the board, only when that exact code path runs. So you count the artifacts.\nLessons On an old target, the fight is against wrong defaults, not missing instructions. You don\u0026rsquo;t find out that -march=lakemont implies soft-float until you turn it on. A compiler\u0026rsquo;s assumption can be disproven with hardware evidence. The previously shipping firmware, an x87 userspace with MATH_EMULATION=n, was that evidence. Floating-point flags are ABI. If you change them, you rebuild everything. Cross-build verification is done against the artifacts, not the flags. The time it takes to scan 285 files is far cheaper than chasing a SIGILL on the board. What this stage bought was not a boot. It was a correct floor: proof that every binary uses only what this CPU actually has, and nothing it doesn\u0026rsquo;t. The next post in this series is about the kernel refusing to come up on top of that floor.\n","permalink":"https://pdh0085.github.io/posts/i586-toolchain-in-2026/","summary":"The Quark X1000 is an i586 with no MMX, no SSE, and an x87 FPU. The first OpenWrt toolchain build for it broke not in the compiler but in libc\u0026rsquo;s fabs(). The problem wasn\u0026rsquo;t a missing instruction; it was a wrong default. Verification meant scanning 285 build artifacts.","title":"Building an i586 Toolchain in 2026"},{"content":"The Worst Case of a Remote Update Our 5G FWA routers, the LS500X and NM500G (Qualcomm IPQ8072, based on OpenWrt 25.12), sit in homes and small offices, and the carrier\u0026rsquo;s management server (ACS) pushes firmware to them remotely. In that picture there is exactly one worst case: the update finishes and the box doesn\u0026rsquo;t come back. That means a technician in a truck, and in the FWA business one truck roll can cost more than the device itself.\nSo the flash is split into two slots, A and B. An upgrade always writes to the slot not currently in use, and if the new slot fails to boot, the bootloader falls back to the previous one.\nThe implementation has one constraint worth knowing: this A/B is built without modifying a single line of bootloader source. It lives entirely in the vendor U-Boot\u0026rsquo;s environment scripts, because not touching the production bootloader is itself risk management. But this U-Boot has no setexpr, which means no arithmetic. The boot counter is incremented by a ladder of if test comparisons, and because of that structure, the retry limit maxes out at 3.\nThe cycle: U-Boot bumps the counter on every boot and switches slots when it hits the limit; once userspace comes up, a service resets the counter to zero. In other words, \u0026ldquo;the counter went back to zero\u0026rdquo; is the definition of \u0026ldquo;the boot succeeded.\u0026rdquo;\nNobody Had Ever Broken It Everything around the rollback was measured. A corrupted image gets rejected in 3.9 seconds without touching the flash. We had watched the slots swap from A to B and back. We had watched an ACS-initiated upgrade go from download command to success report in about 92 seconds.\nThe rollback itself had never fired, not once. Our internal docs graded that line \u0026ldquo;verified by design,\u0026rdquo; which on a second reading means nobody has ever tried it.\nSo we induced it. Two different ways.\nDrill A: the pushed image can\u0026rsquo;t be read at all. We overwrote the inactive slot\u0026rsquo;s kernel volume with 1 MiB of random data; the FDT magic went from d00dfeed to 4a46f528. Then we staged the board to look exactly like a unit that had just finished an upgrade (counter at zero, active slot pointing at the broken one) and powered it on.\nDrill B: the kernel boots, but the system never comes alive. The nastier one. We didn\u0026rsquo;t touch a single byte of flash; we just appended init=/bin/false to that slot\u0026rsquo;s kernel arguments. The kernel boots and userspace dies instantly.\nWhat the console showed:\nDrill A Drill B [13.08] [A/B] slot=1 bootcount=1 [13.13] [A/B] slot=1 bootcount=1 [13.51] Wrong Image Format for bootm [15.34] Kernel command line: ... init=/bin/false [13.52] resetting ... [23.57] U-Boot 2016.01 \u0026lt;- died, reset [22.90] [A/B] slot=1 bootcount=3 [40.16] [A/B] slot=1 bootcount=3 [23.39] [A/B] failover to slot 0 [40.66] [A/B] failover to slot 0 [36.49] Please press Enter to activate [53.57] Please press Enter to activate Results:\nDrill A (corrupt image) Drill B (boots, then dies) Cost per failed attempt 4.9 s 13.5 s First reset → usable device 26.5 s 43.5 s In both cases the board booted the previous slot and the counter went back to zero, so the recovered boot was recorded as a success. No truck, no human, under a minute.\nThat would already be a happy ending. But the real payoff of the drills was something else.\nFinding 1: \u0026ldquo;Rolls Back After 3 Failures\u0026rdquo; Was Wrong. It\u0026rsquo;s 2. The limit is 3, so the bad slot gets three attempts. That\u0026rsquo;s what three separate documents said. The logs say otherwise. U-Boot increments the counter first and then checks it, and the check switches slots when the counter equals the limit. So the third U-Boot execution bumps the counter to 3 and switches slots within that same run, booting the good slot. The bad slot only ever gets two actual boot attempts.\nThe behavior is better than documented, since recovery is one cycle faster. The problem is that the documentation was wrong, and the more important question is why nobody caught it. An off-by-one in a recovery mechanism is invisible until someone induces a failure. That line was read, re-read, and copied verbatim into three documents. Reading is not verification.\nFinding 2: If the Kernel Hangs, Rollback Never Fires At All The boot counter only increments when the board resets. And the shipping kernel command line had no panic=. On a kernel panic, the board doesn\u0026rsquo;t reset; it just sits there. No reset, no counter, no A/B.\nWhich means the 43.5 seconds above was actually measured with panic=5 added by hand for the test. We recorded it as a floor value rather than a field number, and opened a new gap item.\nThe follow-up: we shipped panic=5 in the board\u0026rsquo;s kernel arguments via the DTS and verified it on 3.1.33. Force a panic and the board resets and is back in service in about 75 seconds, with the counter reset to zero and the panic dump preserved and readable on the next boot.\nWhile doing that, we also had to shrink our own earlier claim. \u0026ldquo;A panic always hangs the board\u0026rdquo; was too broad. OpenWrt applies kernel parameters after boot completes, so a fully booted unit had always rebooted on panic. The real hole was only the window before userspace applies that setting, which is exactly the situation Drill B creates. When you find a defect, you also write down its boundaries; otherwise the next reader of your doc gets fooled in the other direction.\nThe Instruments Lied Three Times The biggest time sink in these drills wasn\u0026rsquo;t the board. It was the measurement setup.\ngrep printed nothing. Serial captures contain control characters, and this environment\u0026rsquo;s grep silently returns empty results on such files. On screen, that is indistinguishable from \u0026ldquo;the rollback never happened.\u0026rdquo; We only noticed after extracting the same lines a different way. The most dangerous instrument is the one that gives you a plausible answer instead of a wrong one. Two console readers shared one port. The capture came out as interleaved garbage, while the board, it turned out, had performed the rollback flawlessly. A corrupted capture is not a failed test. Writing an empty value to a U-Boot environment variable deletes the variable, and returns success. We had backed up a boot-critical variable to a temp directory that a reboot then wiped, and the restore command deleted the variable and returned 0. If we hadn\u0026rsquo;t read it back to verify, we\u0026rsquo;d have genuinely disabled the board mid-test. We also built a tool out of this: a serial capture mode that writes zero bytes to the port. That\u0026rsquo;s not a stylistic preference. One stray newline during U-Boot\u0026rsquo;s 2-second autoboot countdown parks the board at a prompt forever, and during a rollback drill that is indistinguishable from the hang you\u0026rsquo;re trying to measure.\nWhat A/B Cannot Save You From We once killed a build mid-package-install. The resulting image passed validation, booted, and reached a shell, but had no networking. A/B rollback can\u0026rsquo;t catch this, because the kernel is fine. Worse, upgrading to a good image while keeping settings carried the corrupted config layer forward and contaminated the new image too. Only a factory-clean flash broke the loop.\nThe lesson is unglamorous: don\u0026rsquo;t kill builds halfway, and if you do, delete that image. And never say \u0026ldquo;our safety net catches everything.\u0026rdquo; A/B protects against boot failure, and that\u0026rsquo;s the extent of it.\nThe Numbers All measured on real hardware.\nItem Value Corrupt image rejection 3.9 s, flash untouched Rollback (corrupt image) 4.9 s per failure · usable in 26.5 s from first reset Rollback (boots, then dies) 13.5 s per failure · 43.5 s Kernel panic → automatic recovery (3.1.33) ~75 s, panic dump preserved Full ACS remote upgrade ~92 s (download command → success report) What We Keep \u0026ldquo;Verified by design\u0026rdquo; turned out to be a polite way of writing \u0026ldquo;nobody has ever tried it\u0026rdquo;; a recovery path isn\u0026rsquo;t verified until you\u0026rsquo;ve broken things on purpose. Documentation hardens with every read, too. One wrong line got copied into three documents, and the only thing that broke the copy chain was re-measuring against real hardware. Distrust your instruments first: all three lies in these drills came from the measurement side, not the board. And when you describe a safety net, write down what it cannot catch as well. The \u0026ldquo;boot failure only\u0026rdquo; limit above is part of the result, not a footnote.\n","permalink":"https://pdh0085.github.io/posts/ab-rollback-drills/","summary":"The A/B rollback on our 5G FWA router had never actually fired in three years, and the docs graded it \u0026lsquo;verified by design.\u0026rsquo; So we broke the router two different ways on purpose. It came back on its own in 26.5 and 43.5 seconds, and along the way we found two places where our documentation was wrong.","title":"We Stopped Trusting 'Verified by Design'"},{"content":" The Starting Point An industrial LTE router, the LTE572W. The CPU is an Intel Quark X1000 (Lakemont): i586, single core at 400 MHz, no SMP, no MMX or SSE, though it does have an x87 FPU. 256 MB of RAM (the kernel sees 253 MB), 3.6 GB of eMMC.\nThe shipping firmware was a Yocto image based on Intel\u0026rsquo;s X1000 reference design, which we at Lightspeed had been modifying and shipping. Cellular, GNSS, serial, the web UI, all of it lived on that stack. And it worked. This was a released product, running in the field.\nEven so, at the end of June 2026, we decided to replace all of it with OpenWrt 25.12.\nWhy Three reasons.\nFirst, we needed a maintainable base. The kernel, userspace, and daemons were all specific to the reference stack, and the cellular side was tied to Qualcomm\u0026rsquo;s proprietary API. When the modem module changed, the code had to change with it.\nSecond, mainline gives you a lot for free. ModemManager, mwan3, FRR, LuCI, sysupgrade, overlayfs, the package feeds. Most of what we had been building and maintaining ourselves already exists in OpenWrt.\nThird, old hardware is not an excuse. The Quark X1000 is right there in the mainline kernel (CONFIG_X86_INTEL_QUARK). The difficulty doesn\u0026rsquo;t come from missing support. It comes from the fact that nobody had ever booted this particular combination before. That sentence sets the tone for the whole series.\nConstraint 1: The eMMC Cannot Be Repartitioned The boot chain looks like this: EDKII and a GRUB Legacy 0.97 fork live in SPI flash, and GRUB reads grub.conf and the kernel from a FAT partition on the eMMC.\nSPI: EDKII → GRUB Legacy 0.97 │ (grub.conf and kernels are read from the eMMC FAT) ▼ eMMC mmcblk0p1 (FAT, vendor files untouched) ├─ original kernel / initramfs / rootimage ← left alone (rollback path) ├─ openwrt-bzImage ← file we added ├─ openwrt-root.squashfs ← file we added └─ openwrt-overlay.img ← file we added Damage the partition table or the FAT and GRUB can\u0026rsquo;t read its own menu, at which point you can\u0026rsquo;t even reach the recovery entry in SPI. The only way back is physically reflashing the board. So the rule was set on day one:\nEvery change must be additive and reversible. No repartitioning. Never run any grub tooling. The original files and the original boot entry stay.\nOpenWrt exists on that FAT as three files (a kernel image, a squashfs root, and an ext4 overlay image) and touches nothing else.\nConstraint 2: 400 MHz and 256 MB Is a Design Constraint, Not \u0026ldquo;Slowness\u0026rdquo; On this hardware, slowness isn\u0026rsquo;t a user-experience complaint. It\u0026rsquo;s a force that changes designs. Later posts cover these one by one, but here\u0026rsquo;s a preview of decisions this constraint actually reversed:\nsquashfs compression had to be gzip, not XZ (XZ decompression is far too slow here) cellular must attach over QMI, because the AT+PPP fallback is userspace HDLC, which is a disaster on this CPU forking a single mmcli process during boot costs 6–9 seconds, and it was happening 23 times and if your root filesystem lives in RAM, large file uploads die from OOM. That one was reported from the field, and the entire middle of this series starts from it. Constraint 3: Coexistence There is a separate Windows migration tool that moves existing units to the new firmware, and that tool owns grub.conf (it stamps per-board values into it). So the firmware never overwrites that file. We crossed that ownership boundary exactly once and then backed out; that story belongs to the boot-fallback post.\nThe Working Setup The board was always physically on the bench, and the decisive tool of this project was the serial console. With it, you can watch the entire boot even when networking is dead, and the boot scripts log each step to /dev/kmsg. The difference between \u0026ldquo;reboot blind and guess\u0026rdquo; and \u0026ldquo;watch and iterate fast\u0026rdquo; is enormous.\nOne small field detail: scp doesn\u0026rsquo;t work on this board (dropbear ships without an sftp-server). Every file copy went over an ssh pipe:\ncat file | ssh root@192.168.10.1 \u0026#39;cat \u0026gt; /dest\u0026#39; How It Ended From the subtarget skeleton at the end of June to the 3.0.0 production release on July 15. In summary:\nArea Before (Yocto) After (OpenWrt 25.12) OS base X1000-reference Yocto new x86/quark subtarget Cellular / GNSS proprietary stack (Qualcomm API) ModemManager (mainline) Boot A/B partition switch squashfs on eMMC + boot fallback ladder TR-069 none icwmp (new) Web UI legacy UI LuCI-based app + custom theme There were known limitations at release, too: boot takes about three minutes, a SIM is required, and some carriers need the APN set manually. Writing those down instead of hiding them is also one of this series\u0026rsquo; rules.\nWhat This Series Is About Not a feature tour. Most of the posts ahead are stories like these: a factory reset that reported success while doing nothing, a config file that had never once been read, a modem that said \u0026ldquo;connected\u0026rdquo; while passing zero packets, and inherited assumptions I finally disproved with experiments. The common thread is things that were failing silently, and what it took to notice them.\nNext up is the first gate: building a toolchain in 2026 for an i586 CPU with no MMX and no SSE. The first build broke not in the compiler, but in libc\u0026rsquo;s fabs().\n","permalink":"https://pdh0085.github.io/posts/why-we-left-yocto/","summary":"The LTE572W runs on an Intel Quark X1000: a single 400 MHz core and 256 MB of RAM. Its shipping firmware was a Yocto image that worked fine. We replaced all of it with OpenWrt 25.12. This is why, and these are the three constraints that would go on to shape everything that followed.","title":"We Threw Away Firmware That Worked"},{"content":"Zero Satellites The report from the field was short: GPS doesn\u0026rsquo;t work. Zero satellites.\nThe same model on our bench was fine. Same application firmware, same modem firmware version, same antenna configuration. So we did the diligent, textbook thing: we built a comparison table, healthy board and failed board side by side, and went looking for the difference.\nHealthy board Failed board Application firmware same same Modem firmware version same same Antenna port configuration same same GNSS status files same same Positioning session normal, updating every second session error Result 19 satellites 0 satellites Every software value we could read was identical, and only the outcome differed. So the case was closed the way that evidence seemed to demand: hardware fault. All that remained was to determine whether it was the antenna or the module, so the plan was to swap antennas between the two units. That\u0026rsquo;s what the report said.\nThat conclusion was wrong.\nThe Row the Table Didn\u0026rsquo;t Have A few days later we started interrogating the failed board\u0026rsquo;s modem with AT commands, one by one. Not because of some clever plan; it was closer to \u0026ldquo;let\u0026rsquo;s exhaust everything we can do before tearing the antennas off.\u0026rdquo;\nThen one line came back different.\nHealthy board: AT$GPSLOCK? → 0 Failed board: AT$GPSLOCK? → 3 $GPSLOCK is the modem\u0026rsquo;s GNSS lock setting, and 3 means fully locked. The board didn\u0026rsquo;t have zero satellites. It had an engine it was forbidden to start.\nAT$GPSLOCK=0 One command, and a little while later the \u0026ldquo;broken\u0026rdquo; board was tracking 22–25 satellites with HDOP 1.99 and horizontal accuracy ±9.9 m, the same quality as the healthy bench unit. After a reboot it acquired a fix again entirely on its own. The first five minutes of 4 satellites and HDOP 52 were just a cold start.\nWhy That Row Was Missing The more interesting question is why our table never had that row in the first place.\n$GPSLOCK lives in the modem\u0026rsquo;s internal NV memory. It does not appear in anything we had compared: not the config files, not the antenna port settings, not the status files, not the firmware versions. No amount of diligent diffing on the Linux side would ever have shown it.\nOur comparison table could say \u0026ldquo;everything is the same\u0026rdquo; only because that table didn\u0026rsquo;t have that row. The moment you believe the table is complete, whatever lies outside it stops existing.\nAnd Our Own Docs Threw Away the Clue The painful part is that the decisive clue had been in our hands from the beginning.\nOn the failed board, AT$GPSP=1 (GNSS on) returned ERROR. And our internal technical documentation said: \u0026ldquo;this command is rejected on healthy units too.\u0026rdquo;\nSo that observation was classified as normal and discarded.\nWhen we later checked on an actual healthy bench unit, the doc was wrong. On an unlocked board, AT$GPSP=1 is accepted with OK. That ERROR had been the lock symptom itself all along.\nOne wrong line of documentation disguised the most decisive piece of evidence as known-normal behavior. As a result, we had judged a perfectly good board defective and were planning to start pulling antennas.\nFixing One Line Would Have Been Whack-a-Mole We could have stopped there: write AT$GPSLOCK=0 into the service procedure, apply it whenever a report comes in, done.\nThe problem is who set the lock in the first place.\nIt wasn\u0026rsquo;t our code, that much was certain. There isn\u0026rsquo;t a single line in our source tree that sets a GNSS lock. Which means the modem did it to itself, and indeed this modem has a separate setting ($GNSSDISACFG) that disables GNSS when certain host events occur. And that setting\u0026rsquo;s factory default allows the lock.\nWhich means the lock can come back at any time, and since it\u0026rsquo;s the factory default, every unit in the field is exposed to the same condition.\nFixing one unit and preventing recurrence are different jobs. We adopted $GNSSDISACFG=0 (no host event may disable GNSS) as the shipping default. The cost is power consumption, and our positioning daemon already holds a continuous session anyway, so most of that power saving had been forfeited long ago.\nThen We Made It Fix Itself Writing it into a service procedure isn\u0026rsquo;t enough. A procedure runs when a report comes in, and a report comes in only after a customer notices their GPS is dead.\nSo we built a self-healing check into the firmware. It does something simple:\nCheck once at boot; after that, check periodically only while there is no fix. If the lock is set, clear it, and normalize the lock-permission setting at the same time. Record what was fixed and when, in storage that survives reflashing. We verified it by fault injection: deliberately set $GPSLOCK=3 again, hands off. The unit cleared it by itself in 23 seconds.\nTwo Traps That Only Measurement Caught Both are about how you decide \u0026ldquo;is GNSS healthy,\u0026rdquo; and neither would ever have been caught by reasoning alone.\n① The positioning daemon keeps serving the last fix forever, even after GNSS dies. We set the lock and watched for four minutes: fix=true, 11 satellites, unchanged. The only thing frozen was the timestamp. So a health check that looks at the fix flag will never fire precisely when you need it. Liveness must be judged by the age of the fix.\n② The fix timestamp always runs about one second ahead of the system clock, so computing the age gives you a negative number. Our first rule was \u0026ldquo;negative = clock broken = untrusted,\u0026rdquo; and suddenly every healthy unit read as sick. When a clock is actually wrong, it\u0026rsquo;s off by years, not seconds. A tolerance of about 60 seconds settled it.\nNeither trap is visible in the code, no matter how long you stare. You see them by sitting in front of a deliberately locked board for four minutes.\nWhat\u0026rsquo;s Still Open Our side of the story changed conclusions, but one question remains unanswered: we still don\u0026rsquo;t know which host event set the lock in the first place. Today\u0026rsquo;s mitigation is \u0026ldquo;clear it when it happens,\u0026rdquo; not \u0026ldquo;make it never happen.\u0026rdquo; A follow-up inquiry is filed with the vendor; if an answer comes, the polling check can become event-driven.\nWhat We Took Away Mostly habits, not conclusions. \u0026ldquo;Everything is the same\u0026rdquo; is only true if the comparison table is complete; a row the table doesn\u0026rsquo;t have can\u0026rsquo;t even show up as different. Internal documentation can manufacture evidence, too. One wrong line becomes \u0026ldquo;it\u0026rsquo;s always been like that\u0026rdquo; and reclassifies the decisive clue as normal, which is why judgment criteria written in docs need to be re-measured against real hardware once in a while. Fixing one unit and preventing recurrence are separate problems; once you find root cause, the next question is always why it was set and whether it can be set again. And a self-healing feature\u0026rsquo;s health criteria have to be measured on real hardware, because whether a value keeps updating or freezes is written nowhere in the code.\nAnd one last thing. Our original plan was to swap the antennas. Had we done that first, the result would have been \u0026ldquo;still broken,\u0026rdquo; so we\u0026rsquo;d have replaced the module next. Also \u0026ldquo;still broken.\u0026rdquo;\nReplacing hardware never turns a software problem into a fixed one. Fortunately, we typed one more command before pulling the antennas off.\n","permalink":"https://pdh0085.github.io/posts/it-was-never-the-hardware/","summary":"A 5G CPE in the field reported zero GPS satellites. Every value we could read matched a healthy unit, so the case was closed as a hardware fault. The problem was the values we couldn\u0026rsquo;t read: one AT command later, the \u0026lsquo;dead\u0026rsquo; board was tracking 22 satellites.","title":"It Was Never the Hardware"},{"content":"This one is from a while back, so the exact logs are long gone; the commands and numbers below are reconstructed. The debugging sequence and the wrong turns, however, I remember vividly. You tend to remember the ones that make you feel stupid for a week.\nThe Setup A customer was deploying our LTE router (the LTE572W, one of our 4G CPE products) as a relay for IP cameras: camera on the router\u0026rsquo;s LAN (192.168.10.0/24), LTE uplink to the carrier, and port forwards so their operations team could reach each camera\u0026rsquo;s web UI from the office.\nSimple. The kind of setup you configure in five minutes and never think about again.\nThe Symptom The complaint came in as: \u0026ldquo;port forwarding is broken, we can\u0026rsquo;t reach the camera\u0026rsquo;s web UI from outside.\u0026rdquo;\nAnd it looked plausible, because of one detail that sent me down the wrong road for a while: the router\u0026rsquo;s own web UI was perfectly reachable from outside. WAN was up, the LTE link was fine, remote access worked. The box itself was clearly healthy, so the finger naturally pointed at the forwarding rules.\nI added another rule to test with something simpler than HTTP: external port 8022 forwarded to the camera\u0026rsquo;s SSH on 22. Same story. The SSH client just sat there and died. Meanwhile, from the LAN side, everything about the camera was fine, web UI and SSH both. Camera healthy, router healthy, rules apparently correct, external access dead.\nFirst Suspects (All Wrong) The usual checklist: stared at the firewall and DNAT rules until my eyes hurt, double-checked the camera\u0026rsquo;s default gateway, re-created the forwards, rebooted things that didn\u0026rsquo;t need rebooting. Everything was exactly as it should be. That\u0026rsquo;s the worst kind of bug. Nothing is misconfigured, and it still doesn\u0026rsquo;t work.\nThe First Real Clue The turning point was low-tech. My \u0026ldquo;external client\u0026rdquo; was a company PC in our Taiwan office, which I drove over remote desktop from my desk in Korea, so I could hammer the router\u0026rsquo;s public address and watch the interface packet counters on the camera-facing port at the same time. One person, two vantage points, two countries apart.\nEvery connection attempt from outside, the TX counter toward the camera kept climbing while RX stayed flat.\nThat one observation flipped the whole picture. The port forwarding was working; the router had been translating and delivering packets to the camera the entire time. The camera was receiving something and refusing to answer. My working theory became: whatever the camera is receiving, it\u0026rsquo;s arriving in a state the camera\u0026rsquo;s TCP stack won\u0026rsquo;t accept, so it silently drops it.\nWhat tcpdump Showed I installed tcpdump on the router and captured the forwarded traffic. Small packets (the TCP handshake and friends) looked clean. But the large segments carrying the actual data were wrong: the TCP payload was damaged, cut short partway through, like something along the LTE path had taken a bite out of them.\nThat also explained the silence perfectly. A router doing NAT doesn\u0026rsquo;t validate TCP checksums; it rewrites what it needs and forwards the rest as is. So the damaged segments sailed right through to the camera, the camera\u0026rsquo;s TCP stack dropped them as corrupt, no ACK ever went back, and the sender just kept retransmitting into the void. TX climbs, RX flat.\nIn hindsight, the red herring explains itself too. The router\u0026rsquo;s own web UI survived because its exchanges happened to stay small enough to slip under the damage threshold. A reachable box tells you the path passes small packets. It tells you nothing about full-size ones.\nThe Immediate Fix If large packets die and small ones live, you cap the packet size. I forced the WAN MTU on the modem interface from 1500 down to 1400 and re-tested.\nEverything worked, instantly. Web UI, SSH, video.\nI won\u0026rsquo;t pretend I can reconstruct the exact mechanism from memory (MSS following the interface MTU down for forwarded connections would be the usual suspect), but the observable result was unambiguous: cap the WAN at 1400 and nothing on the link gets bitten.\nThese days, my first probe for this class of problem is a DF-bit ping sweep to find the real path ceiling before touching anything:\n# Reconstructed - what I\u0026#39;d run today, from a host behind the router ping -M do -s 1372 \u0026lt;target\u0026gt; # 1372 + 28 = 1400 bytes: passes ping -M do -s 1472 \u0026lt;target\u0026gt; # 1500 bytes: dies silently, no ICMP back Root Cause: Officially, I Still Don\u0026rsquo;t Know This is the part that never makes it into tidy postmortems: I never got a definitive answer on what was damaging those packets.\nThe evidence says the LTE path could not deliver ~1500-byte packets intact, and nothing on the path signaled it. No ICMP, no error, just quiet damage. Whether that lived in the modem firmware or somewhere in the carrier\u0026rsquo;s network, I can\u0026rsquo;t prove.\nWhat I can tell you is that I\u0026rsquo;d seen this movie before. Back in the early 3G days we hit a very similar large-packet problem, and that one was eventually confirmed as a modem firmware bug. That modem came from a small vendor, so we worked the issue together: we characterized it, they fixed the firmware, done. This time the modem came from a tier-1 vendor, and realistically a single field case from one CPE maker was not going to open a firmware investigation there.\nThe Real Fix: Stop Trusting the Modem\u0026rsquo;s MTU The lasting fix wasn\u0026rsquo;t the number 1400. It was a product change. Our firmware used to take the MTU the modem reported and run with it. After this case, we added a manual MTU override, so if the field says the path can\u0026rsquo;t carry what the modem claims, an operator can pin the WAN MTU themselves, per deployment, without waiting for anyone\u0026rsquo;s firmware.\nOne field incident bought us a permanent knob, and that knob has paid for itself since.\nTakeaways \u0026ldquo;Small packets work, large packets die\u0026rdquo; is the MTU smell. Partial connectivity (a reachable UI, hanging transfers, SSH that connects and then stalls) should make you think packet size before configuration. Interface counters are a free diagnostic. TX climbing while RX stayed flat told me more in five minutes than hours of rule-staring did. A reachable device is not a healthy path. The router\u0026rsquo;s own UI working from outside was the most misleading fact in the whole case. On cellular, don\u0026rsquo;t assume the path delivers 1500 bytes, and don\u0026rsquo;t assume anything will tell you when it doesn\u0026rsquo;t. Design as if silent large-packet loss is a thing, because it is. You won\u0026rsquo;t always get root cause, and you should ship the mitigation anyway. Between a tier-1 vendor\u0026rsquo;s queue and a customer\u0026rsquo;s deadline, a well-designed override in your own firmware wins. Make the fix a product feature, not a war story. ","permalink":"https://pdh0085.github.io/posts/lte-port-forwarding-silent-mtu-failure/","summary":"External access to an IP camera behind our LTE router kept dying while the router\u0026rsquo;s own web UI worked fine from outside. The port forwarding rules were innocent: large TCP segments were coming off the LTE link damaged, and forcing the WAN MTU down to 1400 made the whole thing work.","title":"The Port Forwarding Bug That Wasn't: A Silent MTU Failure on an LTE Link"},{"content":"I\u0026rsquo;m a firmware engineer building cellular CPE products (5G/4G routers) on OpenWrt and Yocto. This blog is where I write down real problems I hit in the field and how I solved them.\nThings I work on:\nOpenWrt / Yocto based router firmware (Qualcomm IPQ807x and others) Cellular modem integration: Quectel, Telit Cinterion, Sierra Wireless, u-blox and more — AT commands, QMI / MBIM, and USB networking modes (RNDIS / ECM / NCM) TR-069 / TR-369 remote management, GenieACS deployment Mass production test systems (Windows tooling, automated DUT control) Reliability architecture: watchdog ladders, A/B failsafe boot Working with me I take on a limited number of consulting and contract projects alongside my day job. Typical engagements are fixed-scope rather than hourly, so you know the deliverable and the cost up front:\nRemote debugging engagement — you bring a misbehaving device or link (modem won\u0026rsquo;t attach, throughput collapses, random reboots, \u0026ldquo;it works on the bench but not in the field\u0026rdquo;). We run 2–3 remote sessions on your hardware, and you get a written root-cause report with the fix or a concrete workaround. The kind of problems in these posts are exactly what this covers. TR-069 / ACS deployment — a working GenieACS-based remote management stack for your device fleet: provisioning flow, firmware upgrade path, and the operational runbook your team needs to keep it running. Reliability / recovery architecture review — a design review of your boot chain, watchdog strategy, and upgrade path, with a prioritized list of the failure modes that will actually generate support calls, and how to close them. If your problem doesn\u0026rsquo;t fit any of these boxes, write anyway — worst case I tell you it\u0026rsquo;s not a good fit and point you somewhere useful.\nContact Email: pdh0085@gmail.com GitHub: pdh0085 A short description of the symptom and your hardware (SoC, modem model, OpenWrt/Yocto version) is the fastest way to get a useful first reply.\n","permalink":"https://pdh0085.github.io/about/","summary":"\u003cp\u003eI\u0026rsquo;m a firmware engineer building cellular CPE products (5G/4G routers) on\nOpenWrt and Yocto. This blog is where I write down real problems I hit in\nthe field and how I solved them.\u003c/p\u003e\n\u003cp\u003eThings I work on:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eOpenWrt / Yocto based router firmware (Qualcomm IPQ807x and others)\u003c/li\u003e\n\u003cli\u003eCellular modem integration: Quectel, Telit Cinterion, Sierra Wireless, u-blox\nand more — AT commands, QMI / MBIM, and USB networking modes (RNDIS / ECM / NCM)\u003c/li\u003e\n\u003cli\u003eTR-069 / TR-369 remote management, GenieACS deployment\u003c/li\u003e\n\u003cli\u003eMass production test systems (Windows tooling, automated DUT control)\u003c/li\u003e\n\u003cli\u003eReliability architecture: watchdog ladders, A/B failsafe boot\u003c/li\u003e\n\u003c/ul\u003e\n\u003ch2 id=\"working-with-me\"\u003eWorking with me\u003c/h2\u003e\n\u003cp\u003eI take on a limited number of consulting and contract projects alongside my\nday job. Typical engagements are fixed-scope rather than hourly, so you know\nthe deliverable and the cost up front:\u003c/p\u003e","title":"About"}]