Commit graph

8007 commits

Author SHA1 Message Date
ouyangxiangzhen
e5db83d7db sched/sched: Remove nxsched_alarm_expiration
This commit removed nxsched_alarm_expiration to simplify the timer
expiration.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 21:17:13 +08:00
ouyangxiangzhen
3aed2485f8 sched/sched: Remove nxsched_alarm_tick_expiration
This commit removed nxsched_alarm_tick_expiration to simplify the timer
expiration.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 21:17:13 +08:00
yezhonghui
8a91155a0a power/battery: support get battery cycle count
add ioctl cmd

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-22 09:15:56 -03:00
yezhonghui
2b1c108819 power/battery: set interval to reduce report via ioctl
set time interval to control report frequency

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-22 09:15:56 -03:00
yezhonghui
6df4c7c009 power/battery: add charge full event mask
new add a macro for charge full

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-22 09:15:56 -03:00
yezhonghui
db7f292709 power/battery: fake gauge support for rpmsg communication
realize a fake gauge to support powermanger

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-22 09:15:56 -03:00
yezhonghui
443e0cf0db power/battery: gauge upper driver modify b16_t and b8_t to int
upper and lower drivers use int data type

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-22 09:15:56 -03:00
anjiahao
994c9d8929 sched:use tcb inside of pthread_tcb_s, remove all cast
Simplify the code and remove different tcb

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-22 17:55:45 +08:00
anjiahao
0a2b01950c sched:use tcb_s inside of task_tcb_s , remove all cast
Simplify the code and remove different tcb

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-22 17:55:45 +08:00
raiden00pl
cd8ba3377c include/nuttx/atomic.h: fix C++ definition conflicts
when C++ lib has an atomic implementation, we shouldn't include NuttX defined macros to avoid conflicts

Fix errors like:

build/include/libcxx/__atomic/atomic.h:445:1: error: expected identifier before numeric constant
  445 | atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT
      | ^~~~~~~~~~~~~~~~

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-22 15:27:39 +08:00
wangzhi16
31e562b10f Revert "sched/group: move task group into task_tcb_s to improve performance"
This reverts commit 29e50ffa73.

reason:
Placing the main thread and the gourd in the same memory block, and allocating and freeing memory simultaneously, presents the following two problems:

When the main thread creates a child thread and performs a detach operation, there is a possibility that the main thread may have exited, but the main thread's TCB (Transaction Control Block) may not have been released.

This could potentially cause the main thread's TCB to be double-freed. The core contradiction in this problem lies in binding the main thread's TCB (Trust Container Registry) and the group together. When releasing the main thread's TCB, an additional check is needed to ensure the main thread was the last to leave the group. If this check and the free operation are atomically guaranteed, the logic is sound, and double freeing won't occur. However, this atomicity cannot be completely guaranteed. If other free operations cause a block, problems still arise.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-12-21 08:53:46 -03:00
anjiahao
92f26a98dd mm:use Kconfig to control sequence number to save memory
One memory block can save sizeof(size_t) size.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-20 09:47:22 -03:00
anjiahao
7c96537a58 string:use builtin function to optimize libc function
This allows the compiler to automatically identify which string functions
can be compiled into libraries, and the compiler's internal implementation
is faster than libc functions.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-20 10:38:53 +08:00
zhanghongyu
63a036ff6a netlink: add RT_TABLE_LOCAL definition for mqttc5 build
Just add relevant macro definitions

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-19 15:40:48 -03:00
Julian Oes
7e46d282eb drivers/mtd: Add W25N SPI NAND flash driver
Add MTD driver for Winbond W25N series SPI NAND flash.

Currently supports W25N01GV (1Gbit/128MB).

Features:
- Standard SPI interface with configurable frequency (up to 104 MHz)
- Hardware ECC enabled by default
- Block erase with sleep-based wait (releases SPI bus)
- Page read/write with busy-wait for fast operations

Limitations:
- No bad block management (BBM). Factory bad blocks and runtime bad
  blocks are not tracked.
- No bad block table (BBT) scanning at initialization.
- No Quad SPI support (standard SPI only).
- No access to spare area (64 bytes/page) or OTP region.

Tested using:
- Board with STM32H743
- W25N01GV on SPI at 96 MHz with DMA enabled
- Flash mounted using littlefs
- Tested using sdbench:
  - Sequential write speed of 1760 KB/s
  - Sequential read speed of 4900 KB/s

Signed-off-by: Julian Oes <julian@oes.ch>
2025-12-19 10:00:33 +08:00
anjiahao
b623c781c5 arch:use ARCH_64BIT to mark arch is support 64bit
Add ARCH_64BIT macro to indicate architectures with 64-bit support,
improving portability and conditional compilation.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 22:05:12 +08:00
chenzihan1
a9df67e56b drivers/gpio: gpio driver added debounce and interrupt mask functions
Add handling for GPIOC_SETDEBOUNCE to set GPIO pin debounce duration.
Add handling for GPIOC_SETMASK to enable/disable GPIO interrupt mask.

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2025-12-18 14:52:37 +01:00
wangchengdong
edf89ddedd sched/hrtimer: add safe synchronous hrtimer cancel API
Add a safe synchronous hrtimer cancel API, hrtimer_cancel_sync().
If the timer callback is currently executing, this function waits
until the callback has completed and the timer state transitions
to HRTIMER_STATE_INACTIVE.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-18 18:36:28 +08:00
wangchengdong
55b0ea4c55 nuttx/arch.h: Enable up_alarm_start / up_timer_start by default
Enable up_alarm_start and up_timer_start by default so they can be used
by both the tickless scheduler and the high-resolution timer subsystem.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-18 18:36:28 +08:00
wangchengdong
ed1cb6f9b8 sched/hrtimer: Add high-resolution timer support for NuttX
NuttX provides the wdog module to implement timers for the scheduler.
While it is lightweight and efficient, wdog only supports tick-level timers,
typically in milliseconds. Although the tick duration can be configured,
setting it to microsecond or nanosecond resolution is not practical.
Doing so may cause an interrupt storm, where the CPU is constantly
occupied handling tick interrupts.

To address this limitation, a new hrtimer module is introduced.
It coexists with the wdog module, providing both tick-level timers
for wdog and high-resolution timers (nanosecond-level) directly to users.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-18 18:36:28 +08:00
Xiang Xiao
0ba93e5b68 sched/init: Add OSINIT_IS_PANIC to replace 'g_nx_initstate == OSINIT_PANIC'
to simplify the code logic which need handle the panic in special way

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-12-18 18:21:55 +08:00
zhanghongyu
9869181761 tcp.h: add TCP_CORK definition
TCP_CORK and TCP_NODELAY behave almost exactly the opposite,
so first provide simple support for TCP_CORK.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-18 15:38:17 +08:00
Antoine Juckler
d5633f75a8 mtd/at25ee: Use eeprom/spi_xx25xx internally
In order to reduce code duplication, use the eeprom/spi_xx25xx
driver within mtd/at25ee.

The eeprom/xxx.h includes have been merged into eeprom/eeprom.h, to
provide a common include file like mtd/mtd.h.

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
2025-12-17 19:03:54 +01:00
fangpeina
cfbbd06957 input/ff: add control operation to force feedback driver interface
adds a generic control operation to the FF driver interface.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2025-12-17 20:10:09 +08:00
fangpeina
4f3a72ef59 input/ff: extend ioctrl to support get effect duration
support obtain effect duration interface

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2025-12-17 20:10:09 +08:00
ouyangxiangzhen
f14461db2e timers/oneshot: Fix converted tv_nsec > NSEC_PER_SEC.
In rare case, the round-nearest behavior in the clkcnt_best_multshift
may result in converted tv_nsec > NSEC_PER_SEC. This commit fixed the
issue.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-16 17:38:46 -05:00
zhanghongyu
aa8ffea3cf netdev_upperhalf: convert Kconfig to variable
Upperhalf supports multiple working modes at the same time,
which is specified by NIC when register

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-14 10:01:22 +08:00
Jiri Vlasak
f93a1b34e5 eeprom/spi_xx25xx: Add IOCTL to set Block Protect
Add IOCTL to set Block Protect, because we need a way to set Block
Protect of an EEPROM.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2025-12-13 13:33:48 +08:00
rongyichang
0b544d3359 drivers/rpmsg: add slash check for sepical rpmsg dev
rpmsgdev match name too long, so add prefix

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2025-12-12 17:48:43 +08:00
yangsong8
b3758a1df0 compiler: redefine float and double when disable float compiling
Redefine float and double on devices that do not support floating-point.
float  ==> int
double ==> long

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-12 02:33:49 +08:00
Zhe Weng
6fd74f817d net/pkt: Support filtering protocol in AF_PACKET
Ref: https://man7.org/linux/man-pages/man7/packet.7.html

1. For `socket(AF_PACKET, int socket_type, int protocol)`: When `protocol` is set to `htons(ETH_P_ALL)`, then all protocols are received. If `protocol` is set to zero, no packets are received.
2. For `bind`: `bind` can optionally be called with a nonzero `sll_protocol` to start receiving packets for the protocols specified.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-10 23:44:14 +08:00
daichuan
ba54829239 include: modify for support socat, so need add some macro same as linux
add the necessary definitions to the Header File

Signed-off-by: daichuan<daichuan@xiaomi.com>
2025-12-10 23:44:14 +08:00
gaohedong
81f42cb2cf net/ethernet: add timestamp for socket packet
add timestamp for socket packet

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
2025-12-10 23:44:14 +08:00
wangzhi16
ddad4fa16e drivers/note: Optimize code logic.
Remove duplicate code

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-12-10 14:58:29 +08:00
wangzhi16
9e20b41f19 note/drivers: Get taskname more safely.
When tcb may has been released in caller, the return pointer to tcb->name is dangling pointer. So add a buffer in caller, even if tcb is released, buffer is still valid.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-12-10 14:58:29 +08:00
chenxiaoyi
f107b3f5d5 stdio: disable fortify of snprintf/sprintf for clang
clang does not have builtin function `__builtin_va_arg_pack`

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2025-12-09 08:23:14 -03:00
chenxiaoyi
c07d9dc900 compiler: fix fortify for clang
The clang compiler has also defined `__GNUC__`, which can't be used to
decide the compiler version.

And the version used to decide whether the builtin function
`__builtin_dynamic_object_size` exist is not correct.

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2025-12-09 08:23:14 -03:00
Zhe Weng
8d7799d6c1 net/vlan: Allow setting default priority (PCP)
1. We add default PCP because some of our apps may not want to set PCP
   manually (e.g. Our user may just ping with pre-set PCP)
2. The `vlan_qos` is used as PCP when setting Linux's priority mapping:
   https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L590
   Although `vlan_qos` is not used when creating VLAN on Linux, we can
   use it as PCP on creating VLAN (without changing its meaning), and
   keep compatible with Linux's creating (Exactly the same when
   `vlan_qos` is 0).

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng
2b34bcfcb1 netdev/ioctl: Add support for simple VLAN ioctl
Supporting ADD_VLAN_CMD and DEL_VLAN_CMD of SIOCSIFVLAN
Ref: https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L621

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng
242c253178 net: Add VLAN device support
Inspired by Linux's way, we also create VLAN devices for managing VLAN,
which will become interfaces like `eth0.58`.

QinQ is also supported, we can create VLAN devices above another VLAN
devices, like `eth0.100.101` (or even `eth0.1.2.3.4`, also supported on
Linux).

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng
750fae4cca netdev/lower: Support share quota between devices
To prepare for VLAN device support, a VLAN device will share quota with
its real device.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Zhe Weng
b2db3a6430 net/netdev: Add netdev_iob_replace_l2 for netdev to avoid misuse
And fix wrong `d_len` for IOBs from `upper->txq` in TX.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-12-09 07:56:20 -03:00
Petro Karashchenko
535b08514d cxx/cstddef: expose 'max_align_t'
expose 'max_align_t'

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2025-12-09 18:03:10 +08:00
Petro Karashchenko
9c38276249 cxx/cmath: expose 'nextafter'
expose 'nextafter'

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2025-12-09 18:03:10 +08:00
zhanghongyu
f7526522a1 icmp/icmpv6: fix the level parameter type
use a more standard definition

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-06 17:55:40 +08:00
donghaokun
839468f52d docs/sched/sched: Add documentation for different sleep interfaces
As pull request apache#17200 & apache#17368 introduced support for scheduling sleep, a documentation is needed for different sleep interfaces.
This patch adds the description for sleep interfaces currently provided in NuttX, including Scheduled sleep(nxsched_sleep()...), Signal-scheduled sleep(nxsig_sleep()...), and Busy sleep(up_udelay()).

Signed-off-by: Haokun Dong <donghaokun@lixiang.com>
2025-12-04 18:59:58 +01:00
Antoine Juckler
4863564d48 drivers/eeprom: Support PE/SE/CE commands
Add support for the page erase (PE), sector erase (SE) and chip erase
(CE) dedicated commands on supported devices.
They can be triggered using the corresponding IOCTL commands
EEPIOC_PAGEERASE, EEPIOC_SECTORERASE and
EEPIOC_CHIPERASE.

On unsupported devices, this is equivalent to writing a full page,
sector, or the entire EEPROM to 0xFF.

Signed-off-by: Antoine Juckler <6445757+ajuckler@users.noreply.github.com>
2025-12-03 22:05:44 +08:00
buxiasen
7588da4f76 inttype.h: add PRIuTM(time_t) to handle TIME64 & TIME32 print compatible
After patch, we will no longer need cast to int64_t again.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-01 10:07:49 +01:00
Huang Qi
3a6865aef5 drivers/sensors: Add QST QMI8658 6-axis IMU sensor support
Add complete driver support for the QST QMI8658 6-axis IMU sensor featuring
3-axis accelerometer and 3-axis gyroscope with I2C interface and uORB
integration.

Key features implemented:
* Full I2C communication with configurable frequency (default 400kHz)
* Multiple accelerometer ranges (±2g, ±4g, ±8g, ±16g) and ODR settings
* Multiple gyroscope ranges (±16 to ±1024 dps) with high ODR support
* Low-pass filter configuration for both sensors
* Temperature sensing with 16-bit resolution
* Self-test capability for both accelerometer and gyroscope
* Calibration-on-demand support with offset registers
* FIFO buffer management (framework ready)
* Interrupt-driven and polling mode support
* Complete uORB integration with sensor_accel and sensor_gyro topics

Driver components added:
* Core driver implementation (qmi8658_uorb.c) with register operations
* Header file with register definitions and scale factors (qmi8658.h)
* Kconfig options for driver configuration and polling mode
* Build system integration (CMakeLists.txt, Make.defs)
* Comprehensive documentation with API reference and usage examples

The driver follows NuttX sensor framework conventions and provides
robust error handling, mutex protection, and comprehensive debugging
support through CONFIG_DEBUG_SENSORS.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-11-30 09:44:43 -03:00
Huang Qi
311f42bbac libc/unistd: Replace pipe() macro with proper function implementation
Replace the pipe() macro definition with a proper function implementation
to improve POSIX compliance and debugging capabilities. The new pipe()
function serves as a wrapper around pipe2() with flags set to 0.

Changes include:
- Convert pipe() from macro to function declaration in unistd.h
- Add lib_pipe.c implementation file with proper function documentation
- Update build system files (CMakeLists.txt and Make.defs) to include
  the new source file when CONFIG_PIPES is enabled
- Add pipe() entry to libc.csv for symbol tracking

This change allows for better debugging, proper symbol resolution,
and follows NuttX coding standards for library function implementations.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-11-26 17:18:13 +08:00