set_errno() should not modify the interrupted task's errno.
Add a check using up_interrupt_context() and skip the assignment
when called from an interrupt handler.
Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
BREAKING: In an effort to simplify NuttX initialization, NSH_ARCHINIT is
removed. board_app_initialize is also removed. BOARD_LATE_INITIALIZE now
performs all board initialization logic, and is by default enabled. All
references to these symbols are removed. BOARDIOC_INIT remains, but will
result in -ENOTTY when called. It is to be removed in a later commit.
Quick fix: Boards relying on NSH_ARCHINIT should now enable
CONFIG_BOARD_LATE_INITIALIZE instead. If the application needs
fine-grained control over board initialization from userspace, the logic
performed by BOARDIOC_INIT may be copied to the board_finalinitialize
function and used instead via BOARDIOC_FINALINIT. All
board_app_initialize logic provided by NuttX is now moved to
board_late_initialize, and the same should be done for out-of-tree
boards.
Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
DShot is a packet based serial protocol, used for controlling motor controllers
(ESCs), typically for drones.
This adds an upper-half driver for dshot protocol, along with common
configuration options and definitions definitions.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
When CONFIG_FS_BACKTRACE is enabled, collecting a stack trace for every
new file descriptor adds overhead to fast path operations like open(),
dup(), and socket().
This patch adds a new configuration option CONFIG_FS_BACKTRACE_DEFAULT.
When enabled (default behavior), the GROUP_FLAG_FD_BACKTRACE flag is
automatically set during group allocation, causing backtrace to be
captured for all tasks globally, preserving the original diagnostic
capability.
When disabled, backtrace capture is zero-cost by default and must be
explicitly enabled per task group using GROUP_FLAG_FD_BACKTRACE.
Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
This driver adds support to MPR121 Capacitive Keypad usually found
at Aliexpress. The MPR121 is a touch sensor chip from Freescale/NXP
that supports up to 12 sensor electrodes and 1 proximity electrode.
Signed-off-by: Alan C. Assis <acassis@gmail.com>
Enabling CONFIG_NX_HWCURSORIMAGE or CONFIG_NX_SWCURSOR causes a compile error due to a missing semicolon after a structure variable.
Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
enabling CONFIG_FB_HWCURSOR and CONFIG_FB_HWCURSORIMAGE causes a compile error: missing semicolon after a structure variable.
Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.
A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Replace the ESP-specific rmtchar upper-half with arch-local esp_lirc
adapters for Xtensa and RISC-V.
This moves the RMT upper-half out of drivers/rmt, registers LIRC
devices from the ESP board bring-up paths, and removes the old common
rmtchar driver and headers.
Also update the ESP Kconfig and build wiring to build esp_lirc when
ESP_RMT and DRIVERS_RC are enabled.
Fixes discovered during hardware validation:
- register TX as /dev/lirc1 so RX and TX do not collide
- parse the RX worker thread argument from the correct argv slot
- keep RX devices from advertising TX capability
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add ES7210 audio ADC driver for NuttX implementing the audio
lower-half interface. Supports 4-channel recording via I2S with
configurable sample rate, bit depth, and mic gain.
- drivers/audio/es7210.c: Codec driver using LPWORK for async buffer
management, I2C register access, and NuttX audio buffer management
- drivers/audio/es7210.h: Internal register definitions and macros
- include/nuttx/audio/es7210.h: Public header with platform config
structure and es7210_initialize() API
- drivers/audio/Kconfig, Make.defs, CMakeLists.txt: Build system
integration for CONFIG_AUDIO_ES7210
Key implementation details:
- ES7210_SDP_NORMAL (normal I2S) instead of TDM, matching NuttX
I2S standard Philips mode
- ES7210_ADC_PGA_POWER_ON bit in gain registers REG43-46, required
for analog front-end amplifier power-on
- 50ms startup delay in es7210_start for codec clock stabilization
- I2S_IOCTL(AUDIOIOC_STOP) in es7210_stop to notify I2S layer,
preventing DMA from running without buffers after stop
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
This adds support for PBKDF2 (SHA1 and SHA256) while leveraging
the existing infrastructure for HMAC.
Signed-off-by: Vlad Pruteanu <pruteanuvlad1611@yahoo.com>
include/cxx contains NuttX's mini C++ ABI shims and must only be added
to the include path when CONFIG_LIBMINIABI is selected. tools/Config.mk
was adding it unconditionally for every non-LIBCXX/non-UCLIBCXX build,
and the platform.cmake files for arm, arm64, risc-v, x86_64 and tricore
were adding it inside the CONFIG_LIBCXXTOOLCHAIN block.
With an unpatched downloaded ARM GNU Toolchain, <cstdlib> uses
newlib's stdlib.h, defining div_t as an anonymous struct. A later
inclusion of NuttX's stdlib.h via <cstdio>->stdio.h->kmalloc.h then
redefines div_t with struct tag div_s, causing a conflicting declaration
error.
Guard the div_t/ldiv_t/lldiv_t definitions in stdlib.h with
redefinitions when a toolchain stdlib.h was already processed.
Also fix lldiv_s members typed as long instead of long long.
Signed-off-by: trns1997 <trns1997@gmail.com>
Add USB Video Class 1.1 gadget driver supporting Bulk transport
with uncompressed YUY2 video streaming. Resolution and frame
interval are negotiated dynamically via PROBE/COMMIT control.
- uvc.h: protocol constants, streaming control struct, public API
- uvc.c: class driver with PROBE/COMMIT, bulk EP, /dev/uvc0 chardev
- Kconfig/Make.defs: USBUVC config and build rules
- boardctl.c: BOARDIOC_USBDEV_UVC standalone init path
Hardened against host disconnect:
- Removed nxmutex_lock from USB interrupt context paths
- Added 30s semaphore timeout in uvc_write with EP_CANCEL fallback
- Drain stale wrsem counts in VS_COMMIT before new stream
- Guard uvc_streaming_stop() against double EP_CANCEL race
- Handle EP_SUBMIT returning -ESHUTDOWN gracefully
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Correct duplicate "is is" word found in 181 files throughout the
codebase.
In most cases "is is" was changed to "is", but in contexts like
"MCU is is sleep mode" it was corrected to "MCU in sleep mode".
Also fixes a "the the" typo in net/inet/inet_sockif.c.
This is a pure style/documentation fix that improves code readability.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Fix 269 occurrences of duplicate "the" word typo found in 209 files
across source code, header files, and configuration.
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit adds the possibility to check for expander errors when
reading the data. This is optional if glerr_check or interr_check
fields in configuration are not zero.
If not zero, read operation also reads ISO1I813T_GLERR and
ISO1I813T_INTERR register and returns error if there is some error.
The user can control which errors he wants to check with
glerr_check and interr_check masks.
Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This update adds comprehensive documentation regarding the 136-bit response format for SDIO, including the structure of the response, CRC handling, and necessary byte-shifting for alignment. This information is crucial for developers implementing or maintaining SDIO drivers.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
Add support for the GalaxyCore GC0308 VGA CMOS image sensor.
The driver implements the NuttX imgsensor interface and supports
VGA (640x480), QVGA (320x240), and QQVGA (160x120) resolutions
via Kconfig selection. Output format is RGB565X (big-endian).
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add big-endian RGB565 (RGB565X) pixel format throughout the V4L2
video pipeline:
- IMGDATA_PIX_FMT_RGB565X in imgdata.h
- IMGSENSOR_PIX_FMT_RGB565X in imgsensor.h
- Format conversion and buffer size handling in v4l2_cap.c
This is needed by 8-bit DVP camera sensors that output RGB565 in
big-endian byte order (high byte first on the data bus).
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.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>
Previously, the ST7796 driver required the board to pass a struct
st7796_config_s at initialization time, carrying display resolution,
color depth, orientation (MADCTL), BGR flag, SPI frequency, and
initial rotation.
All of these are chip-level properties, not board wiring details.
This created an awkward split: board code computed MADCTL values,
selected BPP, and derived effective resolution depending on orientation
(knowledge that belongs exclusively in the generic driver).
This commit removes that split entirely, following the same pattern used
by the ST7789 driver in drivers/lcd/Kconfig. It also implements the
getpower/setpower interface for standard framebuffer power management.
What was changed (per file):
drivers/lcd/Kconfig:
- Added a full 'if LCD_ST7796' ... 'endif # LCD_ST7796' block containing
all chip-level configuration.
- Includes LCD_ST7796_XRES/YRES, LCD_ST7796_BPP, LCD_ST7796_FREQUENCY,
LCD_ST7796_SPIMODE, LCD_ST7796_BGR, LCD_ST7796_INVCOLOR,
and orientation/rotation choices.
drivers/lcd/st7796.c:
- Removed struct st7796_config_s from struct st7796_dev_s.
- Moved struct st7796_cmd_s from public header to Private Types.
- Added compile-time macros derived from Kconfig:
ST7796_XRES/YRES (swapped for landscape),
ST7796_MADCTL_BASE,
ST7796_SPIMODE,
ST7796_BYTESPP,
ST7796_COLORFMT.
- Implemented st7796_getpower() and st7796_setpower() using the
st7796_board_power() board callback.
- Registered power functions in st7796_fbinitialize() vtable.
- Updated st7796_init_display() to make INVON/INVOFF conditional on
CONFIG_LCD_ST7796_INVCOLOR.
- Simplified st7796_fbinitialize() signature to only take
'struct spi_dev_s *spi'.
include/nuttx/lcd/st7796.h:
- Removed legacy macros (ST7796_XRES_RAW, etc.) and configuration
structures.
- Updated st7796_fbinitialize() prototype.
- Added st7796_board_power() callback prototype.
- Removed private implementation details from the public header.
boards/arm/stm32h7/nucleo-h753zi/Kconfig:
- Removed chip-level menus (settings, orientation) now handled by the
generic driver.
- Retained only board-specific wiring concerns (pins and SPI bus).
boards/.../stm32_st7796.c:
- Removed g_st7796_config and associated board-side macros.
- Updated st7796_fbinitialize() call to the new signature.
- stm32_st7796_flush_fb() now queries effective resolution
via g_fb_vtable->getvideoinfo().
Verified on nucleo-h753zi:
Orientation: Landscape (480x320),
Rotation: 180 deg,
BGR: enabled,
INVCOLOR: disabled,
BPP: RGB565,
Frequency: 40 MHz.
Making INVCOLOR a Kconfig option (default n) fixes cases where panels
previously showed inverted colors due to hardcoded INVON.
Signed-off-by: vrmay23 <vmay.sweden@gmail.com>
- Introduced Kconfig options for stdbit.h, allowing architecture-specific and generic implementations.
- Added new documentation for stdbit.h, detailing its usage and configuration.
- Updated CMake and Makefile to handle the inclusion of stdbit.h based on configuration settings.
This enhances the NuttX library with optional C23 bit manipulation utilities, improving functionality for architectures that support it.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This PR adds complete driver support for the Xilinx UART Peripheral System (XUARTPS)
in the NuttX serial driver framework. The implementation includes the core driver code
(uart_xlnx_ps.c), configuration files (Kconfig-xlnxps), header definitions (uart_xlnx_ps.h),
and integration with the existing NuttX build system (CMakeLists.txt, Make.defs, Kconfig).
The driver supports UART0 configuration with customizable parameters (base address,
clock frequency, IRQ number, baud rate, parity, data bits, stop bits), RX/TX buffer sizing,
hardware flow control (RTS/CTS), interrupt-driven data transfer, and console mapping for XUARTPS UART0.
It also provides standard serial driver operations (setup, shutdown, attach/detach, ioctl, send/receive)
and early serial initialization for boot-time console access.
Signed-off-by: chao an <anchao.archer@bytedance.com>
When CONFIG_LIBM_TOOLCHAIN is enabled, include_next the toolchain\n<c\+\+>/cmath wrapper instead of importing symbols from the NuttX\ncmath shim. This avoids include-order recursion and lets libstdc\+\+\nresolve std::abs/std::acos/... against the matching toolchain C\nmath.h declarations.\n\nKeep the existing NuttX cmath namespace path unchanged for non-\ntoolchain libm configurations.
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
Mainline Linux doesn't use data encapsuation or flow control in its
tty_rpmsg driver. Create a NuttX counterpart which matches this
implementation.
This driver uses the static "rpmsg-tty" name to connect with the
remote service.
Signed-off-by: Maarten Zanders <maarten@zanders.be>
Add support for ST7796 TFT LCD controller (320x480). The driver
implements the NuttX framebuffer interface for SPI-connected displays.
Features:
- SPI interface with CONFIG_SPI_CMDDATA for D/C pin control;
- RGB565 (16-bit) and RGB666 (18-bit) color formats;
- Runtime rotation support (0, 90, 180, 270 degrees) via MADCTL;
- Board-provided configuration via st7796_config_s structure;
- Partial screen update via updatearea for efficient rendering;
- Persistent swap buffer to avoid per-frame allocations;
- Proper ST7796S initialization sequence with documented timing;
The driver uses a board-provided configuration structure allowing
flexible setup of resolution, SPI frequency, color depth, and
initial MADCTL value without requiring Kconfig options in the
generic driver.
Architecture changes in this revision as per request:
- Moved internal register commands to .c file (private)
- Moved MADCTL bit definitions to .c file (private)
- Moved struct st7796_cmd_s to .c file (private)
- Converted MADCTL orientation macros to absolute values
- Moved CONFIG_SPI_CMDDATA error check to beginning of file
- Removed duplicated CONFIG_SPI_CMDDATA guards
- Public header contains only board configuration API
- Changed the Kconfig auto-select FB from 'select' to 'depends on'
Tested with LVGL graphics library on STM32H753ZI board (my own port).
Signed-off-by: Vinicius May <vmay.sweden@gmail.com>
Add packed attribute to lzf header structs to prevent the compiler
from optimizing lzf_magic array initialization into wider store
instructions (e.g. st.h), which can cause misaligned access
exceptions on architectures that do not support unaligned memory access.
Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
Mark memset and memcpy as used_code to fix issues with GCC LTO and CMake
which throws many "undefined reference to memset" errors.
used_code force the compiler to emit the memset symbol under LTO.
Signed-off-by: raiden00pl <raiden00@railab.me>
Add a generic kmatrix lower-half with polling/debounce, STM32 board adapters, Kconfig options, a public API header, and a test example/documentation.
Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
decouple kbd / keypad.
Fix some comments
add documentation
fix rule issues
Update CMakeLists.txt
update documentation.
improve documentation
Fix incorrect flag handling and string escaping in the `make host_info`
diagnostic target.
Previously, CFLAGS, CXXFLAGS, and LDFLAGS were passed in a form that caused
improper splitting and quoting, which resulted in malformed output and
incorrectly escaped configuration values such as CONFIG_APPS_DIR.
This change ensures that:
- Compilation flags are passed as proper shell strings
- Flags are split correctly using shlex
- Configuration values are escaped exactly once when generating sysinfo.h
- Parsed output matches the contents of the .config file
This change affects diagnostic output only and does not modify the NuttX
build process or generated binaries.
Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
When the VIRTIO_RPMSG_F_CPUNAME feature is not negotiated, the driver
previously would crash due to DEBUGASSERT. This commit adds support
for a fallback mechanism:
1. Add rpmsg_virtio_probe_cpuname() API that accepts an optional cpuname
parameter to be used when VIRTIO_RPMSG_F_CPUNAME is not available.
2. Modify rptun driver to pass the cpuname from rptun device config
to rpmsg_virtio_probe_cpuname().
3. Refactor rptun device register/unregister to prioritize RPMSG device
handling before other virtio device types.
This ensures the system works correctly in scenarios where the remote
side does not support the VIRTIO_RPMSG_F_CPUNAME feature.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Move common virtio inline functions (virtqueue_kick_lock, virtio_malloc_buf,
virtio_zalloc_buf, etc.) from CONFIG_DRIVERS_VIRTIO guard to CONFIG_OPENAMP
guard. This allows vhost drivers to reuse these helper functions without
requiring the full virtio driver framework.
The virtio_driver structure and driver registration APIs remain under
CONFIG_DRIVERS_VIRTIO as they are specific to virtio device drivers.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add vhost_get_vq_buffers() API to retrieve all chained buffers from a
virtqueue in one call. This simplifies handling of scatter-gather I/O
where data spans multiple descriptors.
The function populates an array of virtqueue_buf structures with buffer
pointers and lengths, returning the descriptor head index on success.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
Add vhost wrapper macros that map to the corresponding virtio helper
functions:
- vhost_has_feature: check if a feature is supported
- vhost_read_config_member: read a config structure member
- vhost_write_config_member: write a config structure member
Also include virtio-config.h header to support these macros.
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Guard float_t, double_t, and standard math functions with FLT_EVAL_METHOD checks. This ensures compilation when external toolchain's math.h lacks C99/C++11 definitions.
Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
Fix violations of MISRA C:2012 Rule 10.4 (operand of unsigned and signed)
in cancellation point handling code.
Changed all CANCEL_FLAG_* macro definitions and their usage to use unsigned
literals (1u instead of 1) to ensure consistent unsigned arithmetic when
performing bitwise operations. This eliminates mixed signed/unsigned operand
violations in:
- CANCEL_FLAG_NONCANCELABLE
- CANCEL_FLAG_CANCEL_ASYNC
- CANCEL_FLAG_CANCEL_PENDING
The changes affect cancellation point entry/exit logic, cancellation state
management, and cancellation type handling across both kernel and libc
implementations.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>