This patch introduces CONFIG_CC1101_SPIFREQ_BURST and
CONFIG_CC1101_SPIFREQ_SINGLE to Kconfig, allowing users to override
the default SPI frequencies for the CC1101 wireless driver.
Previously, these values were hardcoded to 6.5 MHz and 9.0 MHz
respectively. While these are safe defaults for many setups, specific
hardware designs, high routing capacitance, or platforms utilizing
internal GPIO switching matrices (such as the ESP32) can suffer from
signal integrity degradation at these speeds. By exposing these to
Kconfig, users can easily adjust the clock speeds to match their
hardware capabilities without modifying the core driver source.
Impact:
- Build: Adds two new Kconfig options under WL_CC1101.
- Runtime: Retains 6.5 MHz / 9.0 MHz defaults. Behavior only changes
if overridden via menuconfig.
Testing:
- Built with default values and custom Kconfig overrides.
- Hardware Testing: Tested on a sub-optimal platform utilizing an
internal GPIO matrix (ESP32). The CC1101 failed to load at the
default 6.5/9.0 MHz due to signal integrity issues. Downclocking
the frequencies to 4.0 MHz via Kconfig successfully restored
signal integrity and allowed the driver to initialize and operate
normally.
Signed-off-by: Chip L. <chplee@gmail.com>
This commit overhauls the CC1101 RF driver to address physical hardware
constraints, prevent register wrap-around overflows, and support accurate
dBm power scaling via the standard IOCTL interface.
What this change does:
1. Adds WLIOC_MSK and WLIOC_4FSK modulation support in `ioctl.h` and driver.
2. Replaces static PATABLE initialization with a dynamic Ramp-up curve
generator `cc1101_ioctl_apply_power()` based on lab calibration data.
3. Modifies WLIOC_SETTXPOWER and WLIOC_GETTXPOWER to process actual dBm
values with a nearest-match algorithm instead of raw array indices.
4. Removes DEBUGASSERT on user-space IOCTL pointers and replaces them
with strict -EFAULT checks.
5. Implements saturation clamping (e.g., mantissa to 256-511) to prevent
bitrate and frequency deviation calculation overflows.
6. Rebuilds volatile PATABLE memory upon SLEEP mode wake-up.
Why it is necessary & what it fixes:
- Fixes severe OOK modulation distortion and FSK spectral splatter caused
by statically assigned PATABLE indices.
- Fixes potential kernel panic in flat builds when IOCTL receives a NULL
pointer from user space.
- Fixes register wrap-around (silent failures) when users pass
out-of-bounds baud rate or FDEV values.
- Prevents RF silence after SLEEP mode due to PATABLE volatility.
- Resolves inaccurate power output when changing frequencies dynamically.
Impact:
Changes the behavior of CC1101 TX power and modulation IOCTLs to strictly
comply with standard `wlioc` definitions. Improves overall driver stability
and hardware safety.
Signed-off-by: Chip L. <chplee@gmail.com>
This commit refactors the CC1101 driver's read interface to comply with
the standard NuttX wireless character driver API and introduces extended
hardware operation modes.
- Migrate `cc1101_file_read` to accept and populate the standard
`struct wlioc_rx_hdr_s` instead of returning raw byte arrays.
- Implement `cc1101_calc_rssi_dbm_x100` to preserve the hardware's
0.5 dBm RSSI precision when scaling to 1/100 dBm units, eliminating
the integer truncation loss present in the legacy calculation.
- Add `CC1101IOC_SETOPMODE` and `CC1101IOC_GETOPMODE` IOCTLs.
- Introduce four RF operation modes (`enum cc1101_opmode_e`):
1. NORMAL: Standard packet mode with hardware filtering.
2. PROMISCUOUS: Packet mode bypassing address filtering and retaining
packets with CRC errors.
3. SYNC_SERIAL: Bypasses FIFO, routes clock and data to GDO0/GDO2.
4. ASYNC_SERIAL: Bypasses FIFO, routes async data to GDO2.
- Fix the `GS2200M_FIRST` IOCTL block offset in `wireless/ioctl.h` and
allocate a dedicated IOCTL block for CC1101.
Signed-off-by: Chip L. <chplee@gmail.com>
Implement `cc1101_file_ioctl` to map common NuttX wireless IOCTL commands
to CC1101 hardware registers. This allows dynamic configuration of radio
parameters from user-space applications.
* Map `WLIOC_SETRADIOFREQ` and `GETRADIOFREQ` to `FREQ[2:0]`.
* Map `WLIOC_SETADDR` and `GETADDR` to `ADDR`.
* Map `WLIOC_SETTXPOWER` and `GETTXPOWER` to internal PATABLE indexing.
* Map `WLIOC_SETMODU` and `GETMODU` to `MDMCFG2`.
* Map `WLIOC_FSK_SETBITRATE` and `GETBITRATE` to `MDMCFG4` and `MDMCFG3`.
* Map `WLIOC_FSK_SETFDEV` and `GETFDEV` to `DEVIATN`.
* Normalize positive SPI status byte returns from `cc1101_access` to `OK` (0)
to ensure POSIX compliance and prevent silently skipped register writes.
Signed-off-by: Chip L. <chplee@gmail.com>
Many third-party CC1101 modules (such as those populated on the Evil Crow
RF V2) feature clone silicon that hardcodes the VERSION register to 0x00
instead of the official 0x14.
Previously, the cc1101_checkpart() function strictly enforced
VERSION == 0x14, which caused cc1101_register() to return -ENODEV (-19)
and abort initialization on these compatible modules.
This commit introduces the CONFIG_WL_CC1101_IGNORE_VERSION Kconfig option.
- When disabled (default), the driver maintains strict official silicon
validation. This preserves the diagnostic ability to catch hardware
faults, such as a MISO line shorted to GND (which also reads as 0x00).
- When enabled, the driver explicitly permits VERSION == 0x00, allowing
successful initialization and interoperability with clone chips while
printing a warning to the syslog.
Signed-off-by: Chip L. <chplee@gmail.com>
Nuttx currently has 2 types of sleep interfaces:
1. Signal-scheduled sleep: nxsig_sleep() / nxsig_usleep() / nxsig_nanosleep()
Weaknesses:
a. Signal-dependent: The signal-scheduled sleep method is bound to the signal framework, while some driver sleep operations do not depend on signals.
b. Timespec conversion: Signal-scheduled sleep involves timespec conversion, which has a significant impact on performance.
2. Busy sleep: up_mdelay() / up_udelay()
Weaknesses:
a. Does not actively trigger scheduling, occupy the CPU loading.
3. New interfaces: Scheduled sleep: nxsched_sleep() / nxsched_usleep() / nxsched_msleep() / nxsched_ticksleep()
Strengths:
a. Does not depend on the signal framework.
b. Tick-based, without additional computational overhead.
Currently, the Nuttx driver framework extensively uses nxsig_* interfaces. However, the driver does not need to rely on signals or timespec conversion.
Therefore, a new set of APIs is added to reduce dependencies on other modules.
(This PR also aims to make signals optional, further reducing the code size of Nuttx.)
Signed-off-by: chao an <anchao.archer@bytedance.com>
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
since mmap may exist in block_operations, but truncate may not,
moving mmap beforee truncate could make three struct more compatible
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
- Add mmap into file_operations and remove it from ioctl definitions.
- Add mm_map structure definitions to support future unmapping
- Modify all drivers to initialize the operations struct accordingly
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
- Add truncate into file_operations
- Move truncate to be common for mountpt_operations and file_operations
- Modify all drivers to initialize the operations struct accordingly
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
1.Don't check the return value of nxsem_init or nxmutex_init
2.Fix some style issue
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Uros Platise has submitted the ICLA and we can migrate the licenses
to Apache.
David Sidrane has submitted the ICLA and we can migrate the licenses
to Apache.
Bob Feretich has submitted the ICLA and we can migrate the licenses
to Apache.
Gregory Nutt has submitted the SGA and we can migrate the licenses
to Apache.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* Simplify EINTR/ECANCEL error handling
1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx
* Unify the void cast usage
1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
arch/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
sched/ audio/ crypto/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
Documentation/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
fs/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
graphics/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
net/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
drivers/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
include/, syscall/, wireless/: Removed all references to CONFIG_DISABLE_POLL. The standard POSIX poll() can not longer be disabled.
configs/: Remove all references to CONFIG_DISABLE_POLL. Standard POSIX poll can no longer be disabled.
cc1101: Changes from review of last PR.
remove gpio
remove cc1101 frame len
remove FLAGS_RXONLY flags
add cc1101 function
remove some waring
add cc1101 poll function
add cc1101 register
add cc1101 isr read data
add cc1101 spi deviceId
add cc1101 init2
add wait cc1101 chip ready
raw init cc1101
configs/z80sim and xtrs: Serial driver lower halfs ioctl methods should return a negated errno value, not set the errno variable.
drivers/wireless: CC1101 driver not permitted to set errno.
drivers/sensors: LIS331DL driver not permitted to set errno.
drivers/lcd: ILI9341 initialize method not permitted to set errno,
drivers/serial: 16550 UART driver IOCTL method must not set errno; it must return a negated errno value.