Commit graph

7927 commits

Author SHA1 Message Date
chenzihan1
43b16fdb7c libc/search: add foreach api for hcreate_data
add foreach api for hash table

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2025-12-25 09:39:03 +08:00
jiangtao16
c5814ac910 sched/wdog: compatible with MISRA-C
This commit fixed the MISRA C-2004 violation rule 11.1, 10.4 and more.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-24 16:46:16 +08:00
ouyangxiangzhen
476e02c7e0 sched/wdog: Faster wdog deleting.
This commit reduced 1 write operation for wdog deleting and decoupled
the WDOG_ISACTIVE with the list implementation.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-24 16:46:16 +08:00
guohao15
029a5f5383 node/driver: make SIZEOF_NOTE_START return the right size
The value returned by sizeof(struct note_start_s) is larger
than the actual memory footprint of struct note_start_s.

This causes the length calculated in sched_note_start to be larger
than the actual memory size,which further leads to out-of-bounds reads in note_common.

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2025-12-23 11:26:24 -05:00
zhengyu9
491ce83508 drivers/mtd: add MTDIOC_ISBAD ioctl
add an ioctl item MTDIOC_ISBAD
used for flashtool command to check bad blocks

Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
2025-12-23 09:26:34 -03:00
ouyangxiangzhen
e5f46cb92b seqlock: Fix struct name and constants.
This commit fixed struct name and constant.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
ouyangxiangzhen
5c5872dbac seqlock: Remove atomic_init to fix compilation error.
Since the adafruit-kb2040:smp do not support the `atomic_init`, we have
to remove the function.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
23e985b5ba seqlock: Move the header files to decouple compilation dependencies.
Move the header files to decouple compilation dependencies.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
zhangyu117
c50dd1d952 include/nuttx/seqlock.h: remove warning about less header.h
remove warning about less headers.

Signed-off-by: zhangyu117 <zhangyu117@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
5df2072876 seqlock: Improve seqlock performance on SMP platforms.
The optimization reduces one judgment in read operations, improving write performance by 3% and read performance by 10%.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
ouyangxiangzhen
d576363fc4 seqlock: Improve seqlock performance on non-SMP platforms.
This commit implemented seqlock for non-SMP platforms, which achieves
1.62x performance improvement.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
ouyangxiangzhen
a8724387e7 seqlock: Improve seqlock performance.
This commit improved the seqlock performance on non-SMP and SMP
platforms by 31.7% on average (83Mops -> 106Mops, tested on qemu-intel64/KVM).

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
ouyangxiangzhen
ef1fb35462 seqlock: Better implementation of the seqlock.
This commit provided a better implementation of the seqlock, which
ensure the functional correctness and provide better performance.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
46ad770b60 seqlock: add SMP_WMB to seqlock
This commit added SMP_WMB to seqlock.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
65247f2603 seqlock: change UP_DMB to UP_RMB to improve performance
read_seq Loop 20,000,000 times
before
233333376
after
183333375

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
9e3b852d4b seqlock: add predict_xxx to increase performance
This commit added predict_xxx to increase performance.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
ouyangxiangzhen
dbc6bedff9 seqlock: Remove memory barrier if Non-SMP.
This commit removed unnecessary memory barriers of the seqlock
implementation, since they may block the CPU pipeline and lead to
performance degradation.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
f1ef43c72e nuttx: add seqlock.h
This commit added seqlock.h.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
wangzhi16
0268be1076 sched/arch: fix compile error.
03:17:57  /home/work/ssd1/workspace/Vela-Multi-Boards-dev-system-Build@2/nuttx/include/nuttx/seqlock.h: In function 'read_seqbegin':
03:17:57  /home/work/ssd1/workspace/Vela-Multi-Boards-dev-system-Build@2/nuttx/include/nuttx/seqlock.h:107:3: error: 'asm' undeclared (first use in this function)
03:17:57     SMP_RMB();
03:17:57     ^
03:17:57  /home/work/ssd1/workspace/Vela-Multi-Boards-dev-system-Build@2/nuttx/include/nuttx/seqlock.h:107:3: note: each undeclared identifier is reported only once for each function it appears in
03:17:57  /home/work/ssd1/workspace/Vela-Multi-Boards-dev-system-Build@2/nuttx/include/nuttx/seqlock.h:107:3: error: expected ';' before 'volatile'
03:17:57     SMP_RMB();
03:17:57     ^

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-12-22 10:22:06 -03:00
hujun5
c55954d56c barrier: add UP_RMB UP_WMB
This commit added linux-style UP_RMB() and UP_WMB().

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-12-22 10:22:06 -03:00
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