AuroraRAS opened a new pull request, #18527:
URL: https://github.com/apache/nuttx/pull/18527

   ## Summary
   
   This PR introduces a comprehensive refactoring and stabilization of the 
CC1101 wireless character driver. It aligns the driver's software logic with 
the physical hardware state machine defined in the Texas Instruments 
specifications (DN013/SWRA151A), ensuring safe cross-band operation and robust 
IOCTL memory safety.
   
   **Key Modifications:**
   * **Modulation Support:** Extended `ioctl.h` to include `WLIOC_MSK` and 
`WLIOC_4FSK`. Implemented strict hardware constraint checks in `WLIOC_SETMODU` 
(e.g., rejecting MSK if baud rate <= 26 kBaud, enforcing Manchester coding 
exclusions).
   * **Dynamic PA Ramping:** Deprecated static `rfsettings->PA` logic. 
Introduced a frequency-aware `g_cc1101_pa_calibration` matrix to dynamically 
reconstruct the `PATABLE` via Burst Access. This natively resolves ASK/OOK 
pulse truncation and minimizes FSK adjacent-channel splatter.
   * **Standardized TX Power:** `WLIOC_SETTXPOWER` and `WLIOC_GETTXPOWER` now 
strictly operate on `dBm` units (as defined by `ioctl.h`) using a quantized 
nearest-match algorithm, abandoning the arbitrary 0-8 indexing.
   * **Math & Overflow Safety:** Implemented hard clamping for mantissa 
calculations in `WLIOC_FSK_SETBITRATE` (256-511) and `WLIOC_FSK_SETFDEV` (8-15) 
to prevent silent register wrap-around under extreme input parameters.
   * **Kernel Memory Safety:** Replaced uncompiled `DEBUGASSERT` checks with 
strict `if (ptr == NULL) return -EFAULT;` validations across all IOCTL branches 
to prevent user-space-triggered segmentation faults.
   * **Low-Power Reliability:** Added a mandatory `PATABLE` reconstruction call 
inside `cc1101_powerup()` to fix the known hardware issue where indices 1-7 are 
lost during SLEEP state.
   
   ## Impact
   
   - **Is new feature added?** Yes. MSK and 4-FSK modulation.
   - **Is existing feature changed?** Yes. `WLIOC_SETTXPOWER` now accepts dBm 
instead of raw index values.
   - **Impact on Build:** None.
   - **Impact on Hardware:** Significantly improves RF spectral purity and 
communication stability across diverse frequency bands (315/433/868/915 MHz).
   
   ## Testing
   
   I confirm that changes are verified locally.
   
   * **Build Host:** Fedora 43
   * **Target Architecture:** Xtensa / ESP32 (Hardware setup featuring dual 
CC1101 transceivers and an nRF24L01,  EvilCrowRF-V2 layout).
   
   * **Testing Methods & Results:**
     * **IOCTL Parameter & Clamping Verification:** Successfully validated the 
full suite of standard IOCTLs (`WLIOC_SETRADIOFREQ`, `WLIOC_SETTXPOWER`, 
`WLIOC_SETMODU`, `WLIOC_FSK_SETBITRATE`, `WLIOC_FSK_SETFDEV`) on both 
`/dev/radio0` and `/dev/radio1`. The mathematical saturation and clamping logic 
proved accurate against the hardware limits (e.g., configuring a 250,000 bps 
target bitrate cleanly quantized to an actual 249,938 bps; 47,000 Hz target 
FDEV quantized to 44,433 Hz).
     * **Cross-Band RF Validation:** Executed bidirectional TX/RX payload 
verification and 100-packet throughput stress tests across all four primary ISM 
bands to guarantee the new dynamic PATABLE generator adapts correctly to 
`WLIOC_SETRADIOFREQ` calls:
       * **315 MHz & 433 MHz:** Achieved near-perfect reliability with 98%–100% 
packet delivery rates and throughputs peaking at ~3.95 KB/s (31.5 kbps).
       * **868 MHz & 915 MHz:** Payload verification passed successfully in 
both directions. Stress tests completed with delivery rates ranging from 54% to 
91%, handling the dynamic frequency shifts without state machine lockups.
     * **Driver Coexistence / Regression:**
       Confirmed that the SPI bus and IOCTL interface behavior for other 
wireless drivers on the same hardware (`/dev/nrf24l01`) remain completely 
unaffected by the CC1101 IOCTL architecture changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to