Skip to content

Commit 2bf5020

Browse files
josephnefclaude
andauthored
RTL8814AU: post-fwdl chip-state parity (MAC addr, RRSR, RA-table) (#27)
## Summary Three independent chip-init parity bugs found via live pyusb register readback (kernel-driver vs devourer state) + usbmon trace diff. Each brings devourer's post-init chip state closer to what the working kernel-driver leaves in the chip. 1. **`REG_TXPKTBUF_BCNQ1_BDNY_8814A` address: `0x0426` → `0x0456`** (per `hal/rtl8814a_spec.h:262`). The previous "spec calls it +2" comment was wrong; BCNQ1 lives at `0x0456`, not BCNQ+2. The bad write scribbled some queue/protocol register instead. 2. **`REG_MACID` (`0x0610..0x0615`) now programmed.** Kernel-driver writes 6 individual bytes carrying the chip's MAC address; devourer never wrote `REG_MACID` at all, leaving it `00:00:00:00:00:00`. Hardcoded locally-administered address (`02:0d:b0:c7:e4:b3`) for now — proper EFUSE-read is a follow-up. 3. **Trace-derived post-fwdl init batch** — writes the kernel driver makes that devourer skipped: - `REG_RRSR (0x0440) = 0xff0f0000` — Response Rate Set - `REG_QUEUE_CTRL (0x04c6) = 0x04` - `REG_TX_PTCL_CTRL (0x0520) = 0x0f2f0000` - `REG_RD_CTRL (0x0524) = 0x0f4fff00` - `0x0670 = 0x000000c0` — NAV-related - RA-table init at `0x0990-0x09a4` ## What this does NOT fix End-to-end 8814 TX. Bulk OUT EP `0x02` still times out post-init. Usbmon diff shows kernel does **~4464 post-fwdl vendor writes**; this PR adds ~12 of them. Most of the remaining ~4400 are BB/PHY programming in the `0x800-0x1FFF` register range (table-driven, deterministic) that devourer doesn't yet replicate. That's the next layer of work. ## Test plan - [x] Build green on macOS (`cmake --build build`) - [x] Build green on Arch Linux 6.18 (trainer-arch) - [x] 8814 RX regression on CF-938AC (`0bda:8813`), channel 6: 10+ packets received in demo window - [x] Live pyusb readback confirms these registers now hold the kernel-driver values 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent adea8b7 commit 2bf5020

1 file changed

Lines changed: 42 additions & 1 deletion

File tree

src/HalModule.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ constexpr uint16_t REG_FIFOPAGE_INFO_5_8814A = 0x0240;
2121
constexpr uint16_t REG_RQPN_CTRL_2_8814A = 0x022C;
2222
constexpr uint16_t REG_FIFOPAGE_CTRL_2_8814A = 0x0204;
2323
constexpr uint16_t REG_TXPKTBUF_BCNQ_BDNY_8814A = 0x0424;
24-
constexpr uint16_t REG_TXPKTBUF_BCNQ1_BDNY_8814A = 0x0426; /* spec calls it +2 */
24+
constexpr uint16_t REG_TXPKTBUF_BCNQ1_BDNY_8814A = 0x0456; /* per rtl8814a_spec.h:262 */
2525
constexpr uint16_t REG_MGQ_PGBNDY_8814A = 0x047A;
2626
constexpr uint16_t REG_RXFF_PTR_8814A = 0x011C;
2727

@@ -400,6 +400,47 @@ bool HalModule::rtl8812au_hal_init() {
400400
"REG_RXFLTMAP2=0xFFFF",
401401
cr_observed, cr_final);
402402

403+
if (is_8814a) {
404+
/* Program MAC address to REG_MACID (0x0610). usbmon-trace diff vs
405+
* kernel-driver shows kernel writes 6 individual bytes at 0x610..0x615
406+
* during init; devourer never writes REG_MACID at all. Many Realtek
407+
* MAC TX paths refuse to schedule a frame if the chip's MAC address
408+
* isn't programmed. Using a hardcoded locally-administered address
409+
* for now — proper EFUSE-read of the per-chip MAC is a follow-up. */
410+
static const uint8_t kHardcodedMac[6] = {0x02, 0x0d, 0xb0, 0xc7, 0xe4, 0xb3};
411+
for (uint16_t i = 0; i < 6; ++i) {
412+
_device.rtw_write8(0x0610 + i, kHardcodedMac[i]);
413+
}
414+
415+
/* Trace-derived 8814 post-fwdl init writes. usbmon diff vs
416+
* kernel-driver (cold-init → monitor → inject) revealed these are
417+
* present in the kernel path and absent from devourer. Applied as a
418+
* batch to bring devourer's chip state into MAC-TX-ready shape.
419+
*
420+
* REG_RRSR (0x0440) = 0xff0f0000 Response Rate Set
421+
* 0x04bc = 0x00 TX queue gate
422+
* REG_QUEUE_CTRL (0x04c6) = 0x04 Queue control
423+
* REG_TX_PTCL_CTRL (0x520) = 0x0f2f0000 TX protocol control
424+
* REG_RD_CTRL (0x0524) = 0x0f4fff00 RD control
425+
* 0x0670 = 0x000000c0 NAV-related
426+
* RA-table init at 0x0990-0x09a4
427+
*/
428+
_device.rtw_write32(0x0440, 0xff0f0000u); /* REG_RRSR */
429+
_device.rtw_write8(0x04bc, 0x00);
430+
_device.rtw_write8(0x04c6, 0x04); /* REG_QUEUE_CTRL */
431+
_device.rtw_write32(0x0520, 0x0f2f0000u); /* REG_TX_PTCL_CTRL */
432+
_device.rtw_write32(0x0524, 0x0f4fff00u); /* REG_RD_CTRL */
433+
_device.rtw_write32(0x0670, 0x000000c0u);
434+
/* Rate-adaptation table init (final values from trace). */
435+
_device.rtw_write32(0x0990, 0xffff1027u);
436+
_device.rtw_write32(0x0994, 0x0001484cu);
437+
_device.rtw_write32(0x0998, 0x24282c30u);
438+
_device.rtw_write32(0x099c, 0x34383c40u);
439+
_device.rtw_write32(0x09a0, 0x44000000u);
440+
_device.rtw_write32(0x09a4, 0x80000800u);
441+
_logger->info("8814A: REG_MACID + trace-derived post-fwdl writes applied");
442+
}
443+
403444
if (is_8814a) {
404445
/* TX-validation diagnostic. Read back the registers that gate USB→TX
405446
* dataflow to confirm what state the chip is actually in at the end of

0 commit comments

Comments
 (0)