You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This progresses the USB-first portion of #233. It does not auto-close that issue because narrowband RF validation and combo-module/coexistence work remain outside this PR.
Why a separate backend
RTL8733B is HALMAC 87xx, not a Jaguar2/3 variant. Its power, firmware, MAC, RX/TX descriptor and PHY paths therefore remain isolated under src/rtl8733b/.
Both reviewed vendor trees describe this device as 1SS 802.11b/g/n with a 20/40 MHz capability mask. The 2024 tree also contains a later Fix VHT flags commit that removes the accidentally enabled VHT flag. This PR consequently does not adopt #233's provisional VHT/80 MHz/2T2R assumptions.
Firmware and tables are pinned to libc0607/rtl8733bu-20230626 commit 9e5f6845b4e3393207720fc1886668bc80b6af1c. The implementation was compared with libc0607/rtl8733bu-20240806 commit 2ec19e154cffbc2abd98d43d59278dffa6e50d49, including its active-path TSSI, SRRC band-edge, GPIO/coexistence, power-saving and C2H/TX-tasklet changes. The already hardware-validated artifacts were not silently replaced.
Hardware tested
Test device: one 0bda:f72b, RTL8733B cut D, USB high speed. Independent witness: RTL8812AU in monitor mode.
Verified through the normal WiFiDriver / IRtlDevice path:
USB discovery/endpoints, repeated power/firmware/MAC/BB/RF bring-up, stable EFUSE reads and permanent MAC extraction.
Ambient monitor RX on channels 6 and 36, descriptor aggregation, PHY status, CRC reporting and clean stop.
A 60-second high-traffic RX run exposed a 20 KiB device-aggregate versus 16 KiB host-URB split. Capping RX aggregation at 12 KiB fixed it; five repeated high-traffic channel-36 runs then had zero malformed descriptors, aggregate mismatches or parser aborts.
Raw TX independently captured on both bands: legacy OFDM and HT MCS0-7 at 20 MHz, plus HT 40 MHz. BCC was forced throughout.
Long-preamble CCK independently captured at 1, 2, 5.5 and 11 Mbps on channel 6. A mixed CCK/OFDM run submitted 650/650 frames; 636 were captured with valid FCS across all requested rates. A 1 Mbps request on channel 36 was rejected before USB TX.
A rapid transition run submitted 1,000/1,000 frames through 118 CCK/OFDM TSSI table changes with zero USB failures. The witness captured 660 canonical frames across both rates, all with valid FCS; the thermal code stayed at 32-33 against EFUSE baseline 32.
Ten bounded warm lifecycle cycles rotating channels 6/36 passed EFUSE, firmware, initialization, RX parsing, thermal, rollback, card-disable and USB-persistence gates.
Concurrent RX/TX, bounded sustained TX, malformed-input rejection, teardown during active work, SIGINT during initialization and explicit failure cleanup passed.
Correctly targeted post-stress adapter doctor: HEALTHY; 4/4 identical EFUSE reads, firmware ready, 91 clean + 34 corrupt ambient frames, 125 frames total with zero malformed/aggregate errors.
Final explicit card-disable readback: RF_CTRL=0x00, CR=0xea.
Checks
Full default build: passed.
Full CTest matrix: 53/53 passed.
RTL8733B-only build (all other chip options disabled): passed.
RTL8733B-only CTest matrix: 49/49 passed.
RTL8733B-only ASan/UBSan build and CTest matrix: 49/49 passed.
bash -n, ShellCheck and failure-cleanup exercise for tests/rtl8733b_lifecycle_soak.sh: passed.
Firmware extractor --check: reproduced both checked-in NIC images byte-for-byte.
Table extractor --check: reproduced all checked-in MAC/BB/AGC/RF/RFK arrays byte-for-byte.
Based on current OpenIPC/devourer:master (da06ccc) for the final local builds and hardware checks.
Explicitly not tested or claimed
No SDR equipment was available. Occupied bandwidth, spectral mask, EVM, absolute output power and SDR duty measurements were not performed.
Experimental 5/10 MHz has register-readback and normal-path RX evidence only. Narrowband TX and independent narrowband-peer decode are deferred; narrowband_ok remains false.
No physical 0bda:b733 combo module was available. Its ID is from the vendor table; Bluetooth/coexistence is not implemented or claimed.
SGI remains disabled: descriptors with the short-GI bit set submitted, but the RTL8812AU witness decoded both broadcast and unicast probes as long GI.
STBC and LDPC are rejected. The vendor reports TX-LDPC but not RX-LDPC; this raw-injection path has only been validated with global BCC forced, and the known injection defect makes enabling LDPC here unjustified.
CCK short preamble, CCK outside 2.4 GHz/20 MHz, VHT, 80 MHz, ACK/BlockAck, A-MPDU, fast retune and throughput are not claimed.
The hub cannot switch VBUS, so automated repeated true-cold boots were not possible; physical replug and warm reinitialization were tested.
A vendor-kernel-driver cross-test was attempted with the 2024 tree on Linux 6.14. Its build first omitted required include paths, then failed on incompatible MODULE_IMPORT_NS syntax and missing platform_ops.h. No vendor module was loaded, so no vendor-driver parity result is claimed.
An RTL8731BU-labelled f72b passed early identity/EFUSE/firmware checks, but later stopped enumerating and overheated while attached to a custom power supply. It is excluded from all radio-validation claims.
The full tested/deferred matrix and provenance are in docs/rtl8733b.md.
Halmac8733bMac::configure_monitor_rx enables the MAC using a 16-bit CR write (0x06ff), but
Halmac8733bMac::stop() clears only the low byte via rtw_write8(kRegCr, 0). This leaves CR[15:8] at
0x06 (not symmetric with enable), so stop() does not fully undo the MAC enable it applied,
undermining safe teardown/re-init sequencing.
The RTL8733B monitor RX path programs CR via a 16-bit write to 0x06ff (commented as “full
DMA/protocol/MAC TX+RX enable”) and validates it with a 16-bit readback, meaning bits outside the
low byte are intentionally set. The stop() implementation only clears the low byte, so the high byte
(0x06) is not cleared. Other chip teardown code (Jaguar3) clears CR with a 16-bit write to 0x0000
before power-off, reinforcing that CR should be cleared at the same width it was enabled with.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`Halmac8733bMac::configure_monitor_rx()` writes `kRegCr` as a 16-bit value (`0x06ff`) to fully enable DMA/protocol/MAC TX+RX, but `Halmac8733bMac::stop()` only clears the low byte with `rtw_write8(kRegCr, 0)`. This can leave the upper CR byte (`0x06`) set after stop.
## Issue Context
- The same file explicitly treats CR as a 16-bit value during monitor RX enable and validates it with `rtw_read16(kRegCr) == 0x06ff`.
- Other generations’ deinit paths clear CR with a 16-bit write before powering off.
## Fix Focus Areas
- src/rtl8733b/Halmac8733bMac.cpp[782-789]
### Suggested change
In `Halmac8733bMac::stop()`, replace the 8-bit CR clear with a 16-bit clear (and keep the existing RCR/TxPause shutdown):
- `rtw_write16(kRegCr, 0x0000)` instead of `rtw_write8(kRegCr, 0)`
If RTL8733B CR is wider than 16 bits on this MAC, consider also explicitly clearing any additional CR bytes that are set during init/monitor config, but at minimum stop() should clear the same width it uses to enable.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
RTL8733B capability reporting currently excludes 5/10 MHz narrowband (and does not advertise
FastRetune), contrary to the narrowband/FastRetune requirement. This prevents the expected
narrowband long-range mode from being enabled/verified through the normal capability surfaces.
+ return g == ChipGeneration::Rtl8733b ? (kBw20 | kBw40)+ : g == ChipGeneration::Jaguar1 ? ac
: g == ChipGeneration::Unknown ? 0
: (ac | kBw5 | kBw10);
Evidence
PR Compliance ID 7 expects RTL8733B narrowband 5/10 MHz support (and FastRetune). The PR sets
RTL8733B bandwidth mask to only 20/40 MHz, and GetTxCaps() explicitly documents that 5/10 MHz is
omitted; no RTL8733B caps path marks FastRetune as supported.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
PR Compliance ID 7 requires RTL8733B narrowband 5/10 MHz support plus FastRetune behavior. Current RTL8733B capability reporting excludes 5/10 MHz and does not surface FastRetune support, so narrowband cannot be enabled/validated via the standard capability path.
## Issue Context
- `bw_mask_for_generation(ChipGeneration::Rtl8733b)` currently returns only 20/40.
- `Rtl8733bDevice::GetTxCaps()` explicitly states 5/10 MHz is omitted.
- `AdapterCaps::fastretune_ok` remains at its default (`false`) for RTL8733B.
## Fix Focus Areas
- src/AdapterCaps.h[77-86]
- src/rtl8733b/Rtl8733bDevice.cpp[529-559]
- src/AdapterCaps.h[213-218]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
RTL8733B GetAdapterCaps() does not set narrowband_ok (or fastretune_ok) and hard-codes chain
counts rather than runtime-detecting them, which violates the RTL8733B adapter capability reporting
requirement. This causes demos/telemetry to misrepresent RTL8733B feature availability.
PR Compliance ID 8 requires RTL8733B capability reporting (including narrowband capability and
correct feature flags). In the added RTL8733B backend, GetAdapterCaps() never assigns
narrowband_ok/fastretune_ok (so they remain false per the struct defaults) and sets chain
counts as fixed constants rather than runtime-derived.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
PR Compliance ID 8 requires RTL8733B `AdapterCaps` to correctly surface identity and feature flags, including narrowband capability, and to avoid misreporting RF chain capabilities.
## Issue Context
- `AdapterCaps::narrowband_ok` and `AdapterCaps::fastretune_ok` default to `false`.
- `Rtl8733bDevice::GetAdapterCaps()` populates identity/bands/`bw_mask`, but does not set `narrowband_ok`/`fastretune_ok` and hard-codes `tx_chains`/`rx_chains`.
## Fix Focus Areas
- src/rtl8733b/Rtl8733bDevice.cpp[539-559]
- src/AdapterCaps.h[118-120]
- src/AdapterCaps.h[213-218]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
4. UB shift in txdesc✓ Resolved🐞 Bug≡ Correctness
Description
rtl8733b::txdesc_set_bits uses (1u << width) which is undefined behavior for width==32, so encoding
a 32-bit field would produce unpredictable masks and corrupt the TX descriptor. Because this helper
is header-only and reusable, a future call site can trigger this silently.
The TX helper computes its mask via 1u << width without guarding width == 32, which is UB. The
nearby RTL8733B RX helper (rx_bits) explicitly special-cases width == 32, demonstrating the
expected safe handling pattern in this repo.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`txdesc_set_bits()` builds its bitmask with `1u << width`; when `width == 32` this is undefined behavior in C/C++ and can generate an incorrect mask/descriptor.
### Issue Context
The RTL8733B TX descriptor encoder is intended to be a generic bitfield writer; the RX-side helper already special-cases `width == 32`, suggesting 32-bit fields are a known boundary in this codebase.
### Fix Focus Areas
- src/rtl8733b/TxDescriptor8733b.h[47-52]
### Suggested fix
- Special-case `width == 32` (and validate `bit == 0`) or compute the mask using a 64-bit intermediate (`1ull << width`) and validate `bit + width <= 32` before shifting.
- Consider explicitly handling `width == 0` as a no-op to avoid accidental full-clear patterns.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Rtl8733bDevice increments malformed on any RX parse failure even when the remainder is all-zero
padding (which emit_rx_parse_abort explicitly treats as benign). This inflates/poisons the RX
summary counters and makes troubleshooting RX parser regressions harder.
+ frame)) {+ ++malformed;+ devourer::emit_rx_parse_abort(+ _logger->events(), data + offset,
Evidence
The RX loop counts every parse failure as malformed. However, emit_rx_parse_abort explicitly
excludes all-zero remainder padding, and parse_rx_8733b returns false when frame_len==0—the
decode result you’d get from a zero-filled padded descriptor region—so benign padding can be counted
as malformed.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
The RX loop increments the `malformed` counter before determining whether the parse failure is a real abort or just benign all-zero aggregate padding.
### Issue Context
`emit_rx_parse_abort()` is explicitly designed to suppress events for all-zero remainder padding. Separately, `parse_rx_8733b()` returns `false` when `frame_len == 0`, which is exactly what an all-zero padded “descriptor” would decode as.
### Fix Focus Areas
- src/rtl8733b/Rtl8733bDevice.cpp[170-189]
- src/rtl8733b/FrameParser8733b.h[96-103]
- src/RxParseAbort.h[19-37]
### Suggested fix
- Before incrementing `malformed`, detect the benign-padding case (all-zero remainder) and break without counting it as malformed.
- Alternatively, restructure as:
- detect `all_zero` remainder locally (even when event sink is disabled),
- only then increment `malformed` + emit `rx.parse_abort` for non-zero remainder.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full
• Adds a dedicated HALMAC 87xx backend for RTL8731BU and RTL8733BU USB Wi-Fi.
• Enables validated monitor RX and bounded raw CCK, OFDM, and HT transmission.
• Pins vendor firmware and PHY tables with extraction tools, tests, diagnostics, and documentation.
Diagram
graph TD
A["WiFiDriver"] --> B["Rtl8733bDevice"] --> C["Bringup and MAC"] --> D["PHY and RF"] --> E["Firmware and Tables"]
B --> F["RX and TX"] --> G["IRtlDevice Clients"]
H["Probe and Tests"] --> B
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Extend a Jaguar backend
➕ Could reuse some existing device plumbing and reduce file count.
➖ RTL8733B has incompatible HALMAC power, firmware, descriptor, and PHY paths; shared code risks unsupported capability leakage.
2. Accept PID-only dispatch
➕ Could create the device when a live chip-ID read is transiently unavailable.
➖ Would weaken identity validation and may misroute a device into an incompatible backend.
Recommendation: Keep the isolated HALMAC 87xx backend and require live chip ID 0x16. This matches the hardware architecture, preserves conservative capability gating, and explicitly prevents unsafe Jaguar fallback; common interfaces are reused only at the correct abstraction boundary.
Files changed (38) +38857 / -81
Enhancement (17) +5044 / -34
main.cppInclude RTL8733B USB IDs in adapter doctor+2/-1
Include RTL8733B USB IDs in adapter doctor
• Adds RTL8731BU/RTL8733BU product IDs to the doctor discovery PID set.
main.cppGeneralize RX thermal telemetry and cleanup+80/-23
Generalize RX thermal telemetry and cleanup
• Moves thermal polling to the common IRtlDevice interface and includes CRC, ICV, and RSSI event fields. Ensures background emitters stop before USB teardown.
main.cppBound TX runs and use time-based thermal polling+26/-9
Bound TX runs and use time-based thermal polling
• Adds an optional finite TX frame limit for reproducible captures. Changes thermal polling to wall-clock scheduling so it remains accurate with custom frame pacing.
• Creates Rtl8733bDevice for live chip ID 0x16 and known RTL8733B USB identities. Refuses the historical Jaguar fallback when a known RTL8733B PID reports an unexpected chip ID.
Halmac8733bMac.cppImplement RTL8733B EFUSE and MAC setup+791/-0
Implement RTL8733B EFUSE and MAC setup
• Implements physical EFUSE decoding, normal USB queue and WMAC setup, monitor RX configuration, and safe 12 KiB RX aggregation. Validates expected MAC state and disables unsafe LDPC configuration.
• Updates supported generations and hardware tables for RTL8731BU/RTL8733BU. Documents conservative 1x1 HT/20–40 MHz capability limits and the diagnostic probe.
CMakeLists.txtBuild and test the RTL8733B backend+55/-1
Build and test the RTL8733B backend
• Adds the DEVOURER_8733B option, backend sources, generated artifacts, probe executable, and RTL8733B self-tests. Allows RTL8733B as the sole enabled chip family.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a dedicated userspace HALMAC 87xx backend for the RTL8731BU/RTL8733BU Wi-Fi function.
0bda:f72band0bda:b733, while requiring live RTL8733B chip ID0x16.rtl8733bprobe, adapter-doctor integration and capability documentation.rx.parse_aborttelemetry added in rx.parse_abort: count the abandoned-aggregate RX loss on every generation #387.This progresses the USB-first portion of #233. It does not auto-close that issue because narrowband RF validation and combo-module/coexistence work remain outside this PR.
Why a separate backend
RTL8733B is HALMAC 87xx, not a Jaguar2/3 variant. Its power, firmware, MAC, RX/TX descriptor and PHY paths therefore remain isolated under
src/rtl8733b/.Both reviewed vendor trees describe this device as 1SS 802.11b/g/n with a 20/40 MHz capability mask. The 2024 tree also contains a later
Fix VHT flagscommit that removes the accidentally enabled VHT flag. This PR consequently does not adopt #233's provisional VHT/80 MHz/2T2R assumptions.Firmware and tables are pinned to libc0607/rtl8733bu-20230626 commit
9e5f6845b4e3393207720fc1886668bc80b6af1c. The implementation was compared with libc0607/rtl8733bu-20240806 commit2ec19e154cffbc2abd98d43d59278dffa6e50d49, including its active-path TSSI, SRRC band-edge, GPIO/coexistence, power-saving and C2H/TX-tasklet changes. The already hardware-validated artifacts were not silently replaced.Hardware tested
Test device: one
0bda:f72b, RTL8733B cut D, USB high speed. Independent witness: RTL8812AU in monitor mode.Verified through the normal
WiFiDriver/IRtlDevicepath:RF_CTRL=0x00,CR=0xea.Checks
bash -n, ShellCheck and failure-cleanup exercise fortests/rtl8733b_lifecycle_soak.sh: passed.--check: reproduced both checked-in NIC images byte-for-byte.--check: reproduced all checked-in MAC/BB/AGC/RF/RFK arrays byte-for-byte.OpenIPC/devourer:master(da06ccc) for the final local builds and hardware checks.Explicitly not tested or claimed
narrowband_okremains false.0bda:b733combo module was available. Its ID is from the vendor table; Bluetooth/coexistence is not implemented or claimed.MODULE_IMPORT_NSsyntax and missingplatform_ops.h. No vendor module was loaded, so no vendor-driver parity result is claimed.f72bpassed early identity/EFUSE/firmware checks, but later stopped enumerating and overheated while attached to a custom power supply. It is excluded from all radio-validation claims.The full tested/deferred matrix and provenance are in
docs/rtl8733b.md.