Repository navigation
jaguar2: a band change re-applies the coex antenna switch and RF18's 5G band bits - #612
Conversation
…5G band bits set_channel_bw (the pure tune SetMonitorChannel uses) left two per-band writes to the bring-up: coex_wlan_only's antenna switch (8822B 0xcbc[9:8], 8821C 0xcb4[29:28]) stayed on the bring-up band, and the 8822B's RF18 5G band bits (16, 8) were only kept from the read, which a 2.4G write had cleared. A retune across bands then received through the other band's path. One 8812BU (T4U, USB 3, IGI 0x30, CCA off, 20 MHz, LA capture), floor by open band 13 / 116, measured on 13 / 116: before 69.4 / 62.8 vs 62.9 / 45.1; after 69.3-69.7 / 45.1-45.2 vs 69.6-69.7 / 45.1-45.2. coex_switch_antenna() is the switch half of coex_wlan_only (8821C: coex_switch_antenna_8821c, the same code moved), remembering the band it set; set_channel_bw re-applies it on a band change, only once the bring-up granted the antenna (skip_coex: never). RF18 on 5G now writes RF18_BAND_5G as rtw88 and the 8821C path do. Not covered (src/jaguar2/CLAUDE.md): IQK/LCK still from the bring-up band, the 8821C half and the firmware cross-band hop are unmeasured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
PR Summary by Qodojaguar2: re-apply coex antenna switch and RF18 5G bits on band change
AI Description
Merge Risk
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt |
…o; band_change_rxcheck The firmware's SINGLE_CHANNELSWITCH_V2 (FastRetune, fastretune_fw=2) retunes across bands but leaves the coex antenna switch (0xcbc[9:8]) on the old band, as set_channel_bw did. fast_retune re-applies it after the H2C on a band change. One 8812BU: 36 -> 1 read the ch-1 AP's beacons at RSSI 61.8 against 75.3 after a ch-1 bring-up; with the write 75.1-75.3. tests/band_change_rxcheck.cpp brings up on one 20 MHz channel, switches (SetMonitorChannel, or FastRetune), and reports frames/s, the switch and RF18 read back, and the beacon RSSI/SNR/EVM/CFO of the two most-heard APs. With it on master, 1 -> 36 via SetMonitorChannel decoded nothing (0 frames in 8 s, 2 of 2). It also measured what the first commit left: after a band change the IQK is the bring-up band's. Strong-AP beacon EVM on 36 after a ch-1 bring-up -54.9..-56.0 against -58.2..-58.6 native, while same-band retunes read -58.3..-58.9. Re-running IQK on the band change recovers it but left RX deaf in 4 of 7 changes into 2.4 GHz, so it is recorded in src/jaguar2/CLAUDE.md and not done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
The 8812CU's bring-up outlasts the 2 s settle. With 6 s, the RTL8822C (Jaguar3, a separate HAL this PR leaves alone) shows no band-change fault: 36 -> 1 and 1 -> 36, SetMonitorChannel and the firmware hop, match a bring-up on the target (ch-1 AP RSSI 62.5 against 62.4-62.6; on 36 the strong AP's SNR A 56.0-56.7 against 56.7-56.9, EVM -56.0.. -59.4 against -56.9..-57.4), 2 runs each. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
…s at debug - A re-Init on the same object in another band kept _coex_ant_5g from the last session, so the bring-up's set_channel_bw wrote the switch before the coex grant and IQK. bring_up now starts with it at -1 (coex_forget). - coex_switch_antenna_8821c runs on every band change: its log lines are debug; coex_wlan_only_8821c logs the grant once at info, as the 8822B path does. - band_change_rxcheck switches only after the first frame (bring-up done) and says its register readouts are the 8822B's. - Comments: IGI 0x45 (not "10 dB"); after a 2.4G bring-up RF18 lacks bit 8 (and on some reads bit 16); CLAUDE.md's 13->116 range is 44.9-45.2. Rechecked on the 8812BU: 36->1 cbc[9:8]=2, ch-1 AP RSSI 74.2 against 74.1 for a native ch-1 open; 1->36 cbc[9:8]=1, RF18 0x10d24; 36->1 FastRetune (sw path) 74.3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
…f0284 - bandswitch and bbdump retune at 20 MHz: they now refuse another --bw instead of comparing a 40 MHz open with 20 MHz retunes. - bandswitch's comment: the pinned devourer already re-applies the switch, so the command is an A/B of it. On the 8812BU with 80f0284, 13 -> 116 at IGI 0x30: retuned 26.2, +ant 26.2, ant_back 26.3 (dB): with RF18's band bits right, putting the 2.4G switch back no longer moved the 5G floor (FINDINGS' 39.0 for it was without the RF18 fix). - devourer 80f0284 (OpenIPC/devourer#612 review fixes): bring-up forgets the switch's band; 8821C switch logs at debug; test and comment fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL
josephnef
left a comment
There was a problem hiding this comment.
Reproduced on a second 8812BU and checked against the vendor source. Approving; the comments are non-blocking.
Against the vendor driver (reference/rtl88x2bu):
- The RF18 write is
config_phydm_switch_band_8822b's: clear bits 16, 9, 8, then set 16 and 8 on 5G. - The antenna switch on a band change is
ex_hal8822b_wifi_only_switchbandnotify, which calls the samehal8822b_wifi_only_switch_antennaas the bring-up.
On hardware: TP-Link Archer T3U (RTL8812BU, 2357:012d, USB high speed), band_change_rxcheck built from this branch against master bb801c3 and against this head, 20 MHz, ambient APs, two rounds per cell.
| master | this PR | bring-up on the target | |
|---|---|---|---|
1 -> 36, SetMonitorChannel |
0 frames, RF18 0x00c24, cbc=2 (2 of 2) |
200-640 frames/s, RF18 0x10d24, cbc=1, RSSI 78.7-79.6 / 76.2-76.8 |
RSSI 77.8-79.5 / 76.3-76.7 |
36 -> 1, SetMonitorChannel |
ch-1 AP RSSI 33.8-34.7, cbc=1 |
46.5-47.3, cbc=2 |
45.1-46.6 |
| 1 -> 36, firmware hop | RSSI 76.9-78.2 / 73.0-73.5, cbc=2 |
79.1-79.7 / 76.2-76.8, cbc=1 |
as above |
| 36 -> 1, firmware hop | 33.4-34.7, cbc=1 |
46.4-46.6, cbc=2 |
as above |
| 44 -> 36 (same band) | RSSI as bring-up | RSSI as bring-up |
- The calibration gap shows here too, smaller than on your unit: after 1 -> 36, SNR A 56.2-58.9 against 61.6-63.2 for a ch-36 bring-up, and EVM A -46.7..-47.6 against -47.5..-47.8.
- One thing I did not chase: on master after 36 -> 1 a second, weak ch-1 AP was heard in 62-67 of ~80 beacon slots with mean RSSI readings of 174-195, against 0-57 slots at RSSI 25-28 with this PR and after a ch-1 bring-up.
Limits: one unit, 20 MHz, beacons only, no SDR. I did not measure the 8821C half, the noise floor, or TX after a band change.
…owband tune; RF18 comment credits the vendor (#615) ## What this is This PR addresses the two non-blocking comments from the review of #612. 1. **CCK after a 5G narrowband tune** (the comment at `HalJaguar2.cpp:979`). On the 8822B, `set_channel_bw` writes the CCK trio (`0x808[28]`, `0x454[7]`, `0xa80[18]`) and the CCA mask (`0x814[15:10]`) in its 5/10 MHz branch only. A 5G 5/10 MHz tune turns CCK off, and a later 20 MHz change to 2.4G kept it off. CCK frames and CCK beacons were then lost. It reproduces as predicted. 2. **RF18 provenance** (the comment at `HalJaguar2.cpp:1155`). The band-bit comment now cites `config_phydm_switch_band_8822b` in `reference/rtl88x2bu/hal/phydm/rtl8822b/phydm_hal_api8822b.c`, not rtw88. The paragraph on keeping the 5G bits from the read, which described the behaviour before #612, is gone. ## What changed - **`set_channel_bw`, 8822B, 2.4G at 20/40/80:** writes `0x808[28]` = 1, `0x454[7]` = 0, `0x814[15:10]` = 15. These are the values a 2.4G bring-up leaves (read back on this unit after `1 1`), so outside this state the writes change nothing. 5G at 20/40/80 keeps the bring-up's CCK block, as before. - **The 2.4G narrowband branch** also resets `0x814` to 15, as the vendor routine does. After a 5G narrowband tune it had been left at 34. - **`tests/band_change_rxcheck.cpp`:** - accepts `CH/5` and `CH/10` channels, and stops between `from` and `to` (e.g. `36 36/5 1`); - prints the CRC-good CCK frames (`data_rate` 0-3) and the CCK block registers after the switch. - The existing `from to [fast]` form is unchanged. - **`src/jaguar2/CLAUDE.md`:** the fact, with its counterparts. **Cost:** three BB writes per 2.4G `set_channel_bw` at 20/40/80, and one more in the 2.4G narrowband branch. ## Verification One RTL8812BU (T4U), USB 3. On ch 1 there are two CCK-beaconing APs. `band_change_rxcheck`, 2 runs per cell. Base: master `c7e96fe`. | cell | master | this PR | |---|---|---| | `1 1` (bring-up on ch 1) | 127 / 133 CCK frames, both APs, RSSI 74.5-74.7 | 140 / 138, RSSI 74.5-74.6 | | `36 1` | 172 / 199, RSSI 74.8-74.9 | 184 / 158, RSSI 74.8 | | `36 36/5 1` (5 MHz tune on 36, then ch 1) | **0 / 0 CCK frames, no beacons**; `808[28]`=0 `454[7]`=1 `814`=34 | 177 / 177, both APs, RSSI 74.7-74.8; `808[28]`=1 `454[7]`=0 `814`=15 | | `36/5 1` (bring-up at 5 MHz on 36) | **0 / 0, no beacons** | 153 / 170, RSSI 74.8-74.9 | | `36 36/10 1` | not run | 164 / 156, RSSI 74.9 | | `1 36` | not run | ch-36 AP RSSI 60.9-61.0 / 64.6-64.8, `cbc`=1, RF18 0x10d24, as #612 | **2.4G narrowband, with a 5 MHz transmitter.** An RTL8812CU ran `txdemo` with `DEVOURER_NB_BW=5` on ch 1, at 100 frames/s: | cell | master | this PR | |---|---|---| | `1/5 1/5` (bring-up) | 88-96 frames/s, `814`=15 | 91-97 frames/s, `814`=15 | | `36 36/5 1/5` | 90-97 frames/s, `814`=34 | 88-98 frames/s, `814`=15 | The CCA mask change made no difference to reception here. `ctest`: 99 of 99 pass (`build`, Linux, GCC 15). ## Against it / not verified - **`0xa80[18]` (BB CCK check) is left alone.** A 2.4G bring-up leaves it at 1, where `config_phydm_switch_band_8822b` writes 0, and CCK receives with it at 1 in every cell above. Writing 0 would change the normal 2.4G state, so this PR doesn't. - **Not measured:** - 40 MHz on 2.4G; - reaching this state through `FastRetune` or `fast_bw`; - TX after it; - more than one unit. - **8821C:** not affected. `set_channel_bw_8821c` writes its CCK block at every width. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
What this is
On the 8822B (RTL8812BU), the receive path followed the band the adapter was brought up in, not the band
SetMonitorChanneltuned it to:The firmware cross-band hop (
FastRetunewithfastretune_fw=2) has the same antenna-switch fault.set_channel_bw, the pure tune thatSetMonitorChanneluses, left two per-band writes to the bring-up:coex_wlan_onlywrites0xcbc[9:8](1 = 5G, 2 = 2.4G) once, for the bring-up band;Found in wifi-sdr and wsdr-studio, where a session started on 2.4 GHz showed a 5 GHz floor 12 dB high with a ~10 MHz hump around the centre.
What changed
coex_switch_antenna(is_5g): the switch half ofcoex_wlan_only. It records the band it set (_coex_ant_5g);coex_wlan_onlycalls it.coex_wlan_only_8821cmoved unchanged intocoex_switch_antenna_8821c(0xcb4[29:28], RFE-dependent).set_channel_bw: re-applies the switch when the central channel's band differs from the recorded one. It does this only once the bring-up granted the antenna: withskip_coexthe recorded band stays -1 and nothing is written.RF18_BAND_5G(bits 16 and 8 set, bit 9 clear), as rtw88 and this HAL's 8821C path do. 2.4G is unchanged (& 0x00060cff).fast_retune, firmware path: after the H2C on a band change, re-applies the switch the same way (8822B: after the existing 1 ms 0x838 wait).tests/band_change_rxcheck.cpp: a one-adapter repro built by hand likewidth_relatch_rxcheck(BAND_CHANGE_SETTLE_Sfor Jaguar3's longer bring-up).SetMonitorChannel(orFastRetunewithfast), and listens 8 s.0xcbc[9:8]and RF18 A/B read back, and the beacon RSSI/SNR/EVM/CFO of the two most-heard APs.src/jaguar2/CLAUDE.md: the facts, with the caveats below.Cost: a same-band
set_channel_bwor firmware hop writes nothing new; a band change adds one BB write on the 8822B (three on the 8821C). The softwarefast_retunerefuses band changes, so it is untouched.Verification
Frames and beacons (
band_change_rxcheck)One RTL8812BU (T4U), USB 3, 20 MHz; ambient APs on ch 1 (CCK beacons: RSSI only) and ch 36. Two to four runs per cell; master =
bb801c3. Frame counts swing with the APs' traffic, so compare RSSI.SetMonitorChannelcbc=2cbc=1, strong AP RSSI 57.4-60.1 / 61.3-63.1SetMonitorChannelcbc=1cbc=2cbc=1cbc=2cbc=2cbc=1On the firmware hop, master's RF18 already carries the 5G band bits; only the switch is wrong.
Noise floor (raw IQ)
Same adapter, fixed IGI 0x30, CCA off, 20 MHz, path A raw IQ via LA capture (wifi-sdr), 2 s per point. Floor = median over bins of the 10th-percentile PSD (DC and edges excluded), dB of 12-bit units. Each point: bring up on one channel,
SetMonitorChannelto the other, settle, record, close.0761c600761c60(2 rounds)bb801c3(2 rounds)Master repeated within 0.1 dB in a second round.
The two halves separately, using wifi-sdr's
wsdr_probe bandswitch(path-A bank power, which includes the DC offset):wsdr_probe bbdump) showed RF18 at 0x10c74 / 0x30c74 (A / B) against a native 0x30d74. With the band bits written, the gap closed (table above).Path, not noise: at IGI 0x45, with an AP on ch 1, a 5 GHz bring-up retuned to ch 1 (master) read bursts 10.7 dB and the floor 12.7 dB under a 2.4 GHz bring-up.
In wsdr-studio with this fix, at 49 dB and 40 MS/s, both antennas:
ctest: 95 tests, 0 failures (2 skipped), on this branch.Calibration after a band change
The IQK is still the bring-up band's, and that costs something on 36 after a ch-1 bring-up. Strong AP (RSSI ~59), beacon EVM in raw phy-status units:
iqk_trigger(new band)+config_trx_mode()inSetMonitorChannelon a band change and took 43-45 ms.Not verified
set_channel_bwre-apply and the firmware-hop write run on it too. Not measured; no 8811CU/8821CU here.band_change_rxcheckwithBAND_CHANGE_SETTLE_S=6, 2 runs each: 36 -> 1 and 1 -> 36, viaSetMonitorChanneland the firmware hop, match a bring-up on the target.🤖 Generated with Claude Code
https://claude.ai/code/session_011dRefzq1jjxHVRwtAWjJqL