How did open-source Linux wireless projects like nouveau (NVIDIA GPUs), ath9k, and b43 (Broadcom SoftMAC Wi-Fi) figure out exact initialization sequences for undocumented silicon without violating clean-room rules by copying vendor C code? They treated the hardware bus itself as an observable protocol. By interposing a transparent Memory-Mapped I/O (MMIO) bus tracer between the reference binary and the PCIe BAR0 register aperture, you record what the silicon actually requires โ and by mutating one volatile NVRAM key at a time, every mysterious magic bitfield reveals its exact physical meaning.
5-Part IoT Router Firmware & Linux Wi-Fi Driver Reverse Engineering Curriculum
- Part 1: Dissecting NETGEAR
.chk, BroadcomTRX&SquashFSContainers by Hand - Part 2: Triage of ARM
ET_RELKernel Modules,.rel.rodataTables & D11 Microcode - Part 3 (You Are Here): Black-Box
BAR0Page-Fault MMIO Traps & Differential NVRAM Fuzzing on ARMv7 - Part 4: Clean-Room Linux 6.12
mac80211, BCMA Windowing &B43DFirmware Loaders - Part 5: 2.6.36-to-6.12
sk_buffABI Interposition vs. Native OpenWrt 25.12 Packaging
BCMA_PCI_BAR0_WIN (0x80) onto D11 core 0x18001000. Center: ARMv7 Data Abort MMIO tracing and RMW folding. Right: Single-variable RAM NVRAM diffing.1. The Classic Broadcom Trap: BCMA_PCI_BAR0_WIN (PCI Config 0x80)
Suppose you write a minimal Linux pci_driver for PCI ID 14e4:43a0 (BCM4360), call pci_iomap(pdev, 0, 0) to map BAR0, and immediately execute ioread16(bar0 + 0x03E0) expecting to read B43_MMIO_PHY_VER (0x0B01 = AC-PHY type 11, rev 1). Instead, you read 0x0000 or an unrelated ChipCommon ID register! Why?
Inside a Broadcom wireless ASIC, there is not just one register block โ there is an entire on-chip AMBA AXI backplane managed by Linux's bcma subsystem, hosting multiple independent IP cores at 4 KiB physical intervals:
| BCMA Core Name | Core ID | AXI Backplane Base | Agent / Wrapper Base | Primary Role on BCM4360 |
|---|---|---|---|---|
ChipCommon |
0x800 |
0x18000000 |
0x18100000 |
Chip ID (0x4360 rev 3), PLL clocks, PMU, SROM OTP |
IEEE 802.11 (D11) |
0x812 |
0x18001000 |
0x18101000 |
D11 rev 42 MAC, 64-bit DMA rings, SHM, indirect AC-PHY & Radio 2069 |
PCIe Gen2 |
0x820 |
0x18002000 |
0x18102000 |
PCIe link state, MSI/legacy IRQ routing, host bridge DMA |
The PCIe BAR0 aperture exposed to the host CPU is a movable window controlled by 32-bit PCI configuration register BCMA_PCI_BAR0_WIN (0x80). At cold reset, 0x80 defaults to 0x18000000 (ChipCommon). Until either drivers/bcma or your probe routine writes 0x18001000 into PCI config 0x80 โ and enables the D11 core clocks via its agent wrapper (BCMA_IOCTL / BCMA_RESET_CTL at 0x18101408 / 0x18101800) โ reading BAR0 + 0x03E0 never touches the wireless core at all!
2. Building a Black-Box MMIO Tracer on ARMv7 Linux
On x86_64 workstations, the Linux kernel includes built-in mmiotrace (CONFIG_MMIOTRACE) inside ftrace, which marks PCIe PTEs non-present, logs every faulting instruction via single-step trap flags, and replays the I/O. Embedded ARMv7 router kernels (especially 2.6.36.4 or 4.4) ship without mmiotrace. How did community researchers capture complete R7000 BCM4360 initialization traces on physical hardware?
They used ARMv7's native Data Abort fault hook (hook_fault_code() in arch/arm/mm/fault.c):
- Shadow Virtual Address Allocation: When the reference driver calls
ioremap_nocache(phys_bar0, size), a tiny interposer kernel module performs the realioremap()privately atreal_va, allocates a separate unmapped virtual rangeshadow_va(viaget_vm_area()without backing PTEs), and returnsshadow_vato the driver. - Catching Translation Faults: Every time the driver executes a 16-bit or 32-bit load/store (
ldrh,strh,ldr,str) inside[shadow_va, shadow_va + size), the Cortex-A9 MMU raises a synchronous Data Abort (section/page translation fault, FSR codes0x05/0x07). - Instruction Decoding & Replay: Inside the fault callback, if the faulting address
farfalls withinshadow_va, the handler computesoffset = far - shadow_va, inspects the ARM/Thumb-2 instruction atregs->ARM_pcto identify the source/destination general-purpose registerRtand access width (8/16/32-bit), performs the realreadw/writew/readl/writelagainstreal_va + offset, writes the result intoregs->uregs[Rt](on reads) + logs(op, core_win, offset, val)to a lockless relay ring buffer, and advancesregs->ARM_pcby 4 bytes (ARM) or 2/4 bytes (Thumb-2) to resume execution seamlessly!
3. Folding Indirect Register Pairs & Posted-Write Flushes
Raw BAR0 MMIO logs contain hundreds of thousands of low-level bus cycles because the thousands of internal 16-bit AC-PHY and Radio 2069 registers do not fit directly inside the 4 KiB D11 core window. Instead, D11 exposes indirect address/data portals:
- AC-PHY Portal: Write 16-bit register address to
B43_MMIO_PHY_CONTROL(0x03FC), then read or write the 16-bit value atB43_MMIO_PHY_DATA(0x03FE). - Radio 2069 Portal: Write radio register address (ORed with read bit on reads) to
B43_MMIO_RADIO24_CONTROL(0x03D8), then read/writeB43_MMIO_RADIO24_DATA(0x03DA). - PCIe Posted-Write Flush Reads: Because PCIe memory writes are posted (asynchronous), hardware drivers frequently perform a dummy read of
B43_MMIO_PHY_VER(RD 0x03E0) immediately after a time-critical PHY write before callingudelay(), forcing the PCIe root complex to drain pending writes to silicon.
To turn noisy bus captures into clean specification notes, a semantic trace folder collapses raw cycles into high-level operations โ especially Read-Modify-Write (PHY.MOD) sequences:
# Raw BAR0 Capture:
WR 0x03fc 0x0810 # Select AC-PHY register 0x0810
RD 0x03fe 0x1000 # Read current value (0x1000)
WR 0x03fc 0x0810 # Re-select AC-PHY register 0x0810
WR 0x03fe 0x100c # Write modified value (0x100c)
RD 0x03e0 0x0b01 # Dummy flush read (discarded)
# Folded Semantic Operation:
PHY.MOD reg=0x0810 old=0x1000 new=0x100c changed_mask=0x000c
4. Differential RAM-Only NVRAM Perturbation (SROM Rev 11)
Look at that folded line above: why did the driver set bits 0x000C in PHY register 0x0810? On a Nighthawk R7000, the factory board_data flash partition populates SROM revision 11 NVRAM variables for both PCIe slots (pci/1/1/... for 2.4 GHz and pci/2/1/... for 5 GHz), including external LNA gains (rxgains2gelnagaina0=3), FEM control indices (femctrl=3), and PA polynomial coefficients (pa2ga0, pa5ga0).
Instead of spending a week reverse engineering NVRAM string-parsing math in assembly, you can run a 60-second controlled single-variable experiment purely in volatile RAM:
- Capture Trace A with stock RAM NVRAM (
pci/1/1/rxgains2gelnagaina0=3): PHY0x0810ends with0x100C(binary...0001100). - Run
nvram set pci/1/1/rxgains2gelnagaina0=6(NEVER runnvram commit!), bounce the interface while tracing, and capture Trace B: PHY0x0810ends with0x1018(binary...0011000), while every other PHY register in the 50,000-line trace remains byte-for-byte identical! - Compare
3 << 2 == 0x0Cvs.6 << 2 == 0x18(0x100C ^ 0x1018 == 0x0014): you have proved empirically that Core 0's 2.4 GHz eLNA gain occupies bits[4:2]of AC-PHY register0x0810!
Even better, negative differential tests save you from writing dead code: unsetting pci/1/1/tssifloor2g in RAM and observing zero register diffs proves that PHY 0x0724 receives a constant 0x03FF sentinel during temperature sensing regardless of NVRAM.
5. Your Turn โ Hands-On Lab 03 Checkpoints (Zero Spoilers)
Open labs/03-mmio-trapping-and-nvram-fuzzing.md, inspect the three trace captures in labs/fixtures/sample_mmio_trace.txt, and implement both functions in labs/starter/lab03_mmio_fold_skeleton.py:
- Implement
fold_phy_ops(raw_lines): Track the active PHY address written to0x03FC, discard posted-write flush reads on0x03E0, emit('PHY.RD', reg, val)on reads of0x03FE, and fold back-to-back read+write pairs targeting the exact same PHY register into('PHY.MOD', reg, old_val, new_val, old_val ^ new_val). - Implement
diff_final_phy_state(ops_a, ops_b): Compute the final written value of every touched PHY register across two folded traces and return only registers whose final hardware state changed. - Verify with the Grader: Execute
python3 labs/verify_labs.py --lab 3โ note that the grader also tests cross-register edge cases (reading register A then writing register B must not falsely collapse intoPHY.MOD!).
Continue to Part 4 of the Series
Once you understand how hardware register specifications and calibration tables are derived cleanly, continue to Part 4: Clean-Room Linux 6.12 mac80211, BCMA Windowing & B43D Firmware Loaders to architect a mainline GPL-2.0 kernel driver and fuzz-test its binary firmware parser in userspace C.
