Skip to content

fix(lr2021): live LF↔HF reconfigure via full begin() - #11279

Open
Ethan-chen1234-zy wants to merge 3 commits into
meshtastic:developfrom
Ethan-chen1234-zy:fix/lr2021-lf-hf-band-hop
Open

fix(lr2021): live LF↔HF reconfigure via full begin()#11279
Ethan-chen1234-zy wants to merge 3 commits into
meshtastic:developfrom
Ethan-chen1234-zy:fix/lr2021-lf-hf-band-hop

Conversation

@Ethan-chen1234-zy

@Ethan-chen1234-zy Ethan-chen1234-zy commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • On develop, LoRa region changes apply live via reconfigure() (no reboot).
  • LR2021 incremental setOutputPower across Sub-GHz ↔ 2.4 GHz can return RadioLib -706; the old assert HardFaulted before config save.
  • Detect LF↔HF hops (carrier crosses 1500 MHz) and call lora.begin(...); same-band changes stay on the incremental path. Power failures are logged + CRITICALERROR instead of asserting.

Scope

  • src/mesh/LR20x0Interface.cpp only (USE_LR2021).
  • No board variants / PA tables.
  • Does not affect cold boot (init()begin()), non-LR2021 radios, or same-band live reconfigure.

Test plan

  • Sub-GHz → live set lora.region=LORA_24: log LF/HF band hop ... full begin(), no -706 / reset; region persists.
  • Live switch back to a Sub-GHz region: same checks.
  • Same-band region/power change still works.
  • Cold boot already in LORA_24 still OK.
  • Verified on internal LR2021 dual-band HW; please spot-check other USE_LR2021 boards if available.

Summary by CodeRabbit

  • Bug Fixes
    • Improved radio reconfiguration when moving between low- and high-frequency bands.
    • Applies the correct initialization steps, including clock/RF switching, CRC, and RX gain settings, on band hops.
    • Streamlined reconfiguration for same-band updates with enhanced failure handling.
    • Radio RX now reliably restarts after successful frequency changes.
    • More consistently retains and reuses the active carrier frequency across initialization and subsequent reconfigurations.

…06 / assert when live-switching Sub-GHz ↔ LORA_24.
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Flash this PR in the Web Flasher

firmware commit boards expires

Warning

This is an automated, unreviewed CI test build. Back up your device configuration
before flashing, and only flash devices you are able to recover.

Supported boards built by this PR (31)
Device Board Platform
Crowpanel Adv 3.5 TFT elecrow-adv-35-tft esp32-s3
Heltec HT62 heltec-ht62-esp32c3-sx1262 esp32-c3
Heltec Mesh Node 096 heltec-mesh-node-t096 nrf52840
Heltec Mesh Node T1 heltec-mesh-node-t1 nrf52840
Heltec Mesh Node T114 heltec-mesh-node-t114 nrf52840
Heltec V3 heltec-v3 esp32-s3
Heltec V4 heltec-v4 esp32-s3
Meshnology W10 meshnology_w10 esp32-s3
Meshnology W12 meshnology_w12 esp32-s3
Raspberry Pi Pico pico rp2040
Raspberry Pi Pico W picow rp2040
RAK WisMesh Pocket V3 rak_wismesh_pocket nrf52840
RAK WisMesh Pod rak_wismesh_pod nrf52840
RAK WisMesh Repeater Mini V2 rak_wismesh_repeater_mini nrf52840
RAK WisMesh Tag rak_wismeshtag nrf52840
RAK WisBlock 11200 rak11200 esp32
RAK WisBlock 11310 rak11310 rp2040
RAK3312 rak3312 esp32-s3
RAK WisBlock 4631 rak4631 nrf52840
Seeed SenseCAP Mesh-Tracker-X1 seeed_mesh_tracker_X1 nrf52840
Seeed Wio Tracker L1 seeed_wio_tracker_L1 nrf52840
Seeed Xiao NRF52840 Kit seeed_xiao_nrf52840_kit nrf52840
Seeed Xiao ESP32-S3 seeed-xiao-s3 esp32-s3
Station G2 station-g2 esp32-s3
Station G3 station-g3 esp32-s3
LILYGO T-Deck t-deck-tft esp32-s3
LILYGO T-Echo t-echo nrf52840
LILYGO T-Echo Plus t-echo-plus nrf52840
LILYGO T-Impulse Plus t-impulse-plus nrf52840
LilyGo T3-C6 tlora-c6 esp32-c6
Seeed SenseCAP T1000-E tracker-t1000-e nrf52840

Build artifacts expire on 2026-08-29. Updated for 1f431a0.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d0e93a4a-8ea1-4323-bf29-9ab27875ba5e

📥 Commits

Reviewing files that changed from the base of the PR and between 3d0317e and 1f431a0.

📒 Files selected for processing (1)
  • src/mesh/LR20x0Interface.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/mesh/LR20x0Interface.cpp

📝 Walkthrough

Walkthrough

LR20x0Interface tracks the programmed frequency, performs full initialization when switching LF/HF bands, and uses incremental radio updates for same-band reconfiguration while restarting reception and recording failures.

Changes

Radio reconfiguration

Layer / File(s) Summary
Frequency tracking and initialization
src/mesh/LR20x0Interface.cpp
Adds last-frequency tracking and records the current frequency during initialization.
Band-aware reconfiguration
src/mesh/LR20x0Interface.cpp
Uses full lora.begin() initialization for LF/HF transitions and incremental parameter updates for same-band changes, with RX restart and error recording on failures.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LR20x0Interface
  participant lora
  participant RX
  LR20x0Interface->>LR20x0Interface: Compare requested and previous frequency bands
  LR20x0Interface->>lora: Run full begin() for a band hop
  lora-->>LR20x0Interface: Return initialization result
  LR20x0Interface->>RX: Restart reception
  LR20x0Interface->>lora: Apply incremental settings within the same band
  lora-->>LR20x0Interface: Return parameter results
  LR20x0Interface->>RX: Restart reception
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, scope, and test plan, but it omits the required attestations checklist from the template. Add the attestations section with the required test checkboxes and note whether hardware-specific verification was completed.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the main change: live LF↔HF reconfigure now uses full begin() on band hops.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mesh/LR20x0Interface.cpp`:
- Around line 193-225: Update the band-hop branch around lora.begin() to mirror
init()’s LF/HF reinitialization: apply the appropriate RF-switch GPIO state for
the new frequency, wait for TCXO settling, retry SPI command failures after the
established delay, and retry without TCXO for TCXO_OPTIONAL when applicable.
Replace the ignored setCRC, setRfSwitchTable, and setRxBoostedGainMode results
with the same error checking and logging used by init() and the same-band path,
preserving failure returns and critical-error handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f231aa66-9918-4a01-b6a6-1e31655b23bc

📥 Commits

Reviewing files that changed from the base of the PR and between b4ff1df and 099b22e.

📒 Files selected for processing (1)
  • src/mesh/LR20x0Interface.cpp

Comment thread src/mesh/LR20x0Interface.cpp
@thebentern thebentern added the bugfix Pull request that fixes bugs label Jul 29, 2026
@thebentern
thebentern requested a review from caveman99 July 29, 2026 10:28
…switch GPIOs, SPI/TCXO retries, and log CRC/RX-gain errors.
@thebentern

Copy link
Copy Markdown
Contributor

@Ethan-chen1234-zy please run trunk fmt. Thanks

@Ethan-chen1234-zy

Copy link
Copy Markdown
Contributor Author

Done — ran trunk fmt and pushed. Thanks.

@caveman99 caveman99 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#11234 Addresses the same code area and a very similar problem. I think the underlying issue is the same here. Can you try with this patch so we don't fix the same thing twice?

@Ethan-chen1234-zy

Ethan-chen1234-zy commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@caveman99 Thanks — I tried #11234 alone on LR2021 dual-band HW (live US → LORA_24).

#11234 alone avoids HardFault, but setOutputPower still fails while prefs save region=LORA_24. RF stays broken even after switching back to US (until reboot / cold begin()):

INFO | Set radio: region=LORA_24, name=LongFast, config=0, ch=25, power=10
INFO | frequency: 2420.718750
INFO | Final Tx power: 10 dBm
ERROR | NOTE! Record critical error 7 at src/mesh/LR20x0Interface.cpp:215

This PR (#11279) on the same live hop takes the full begin() path and TX works:

INFO | Set radio: region=LORA_24, name=LongFast, config=0, ch=25, power=10
INFO | frequency: 2420.718750
INFO | Final Tx power: 10 dBm
INFO | LR20x0 LF/HF band hop 906.9 -> 2420.7 MHz, full begin()

So #11234 and #11279 are complementary, not duplicates: #11234 softens asserts / SPI hang; #11279 is still required for correct live LF↔HF reconfigure. Happy to rebase after #11234 lands if needed.

@RCGV1

RCGV1 commented Aug 1, 2026

Copy link
Copy Markdown
Member

I opened a focused companion PR against this branch: Ethan-chen1234-zy#1

It fixes a MHz/Hz mismatch in the external LF/HF RF-switch GPIO selection, propagates rejected reconfiguration steps instead of restarting RX and returning success, and adds LF/HF boundary plus bidirectional transition tests. meshnology_w12 builds successfully.

I do not have LR2021 hardware attached. The remaining useful check is the same live US -> LORA_24 -> US matrix on your dual-band device, verifying actual TX/RX in both directions and no new critical radio error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants