Commit graph

60363 commits

Author SHA1 Message Date
anjiahao
6beaf1258f mqueue:fix msgq memleak
if first call unlink after call nxmq_file_close
cause i_crefs not 0 will leak msqg, inode will
free in unlink, but forget free msgq

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-20 11:18:25 +08:00
anjiahao
2969857ff2 libc/libelf:fix bug for libelf_symname
readlen maybe not equal CONFIG_LIBELF_BUFFERINCR

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-20 11:17:55 +08:00
dirksavage88
c792601963 imxrt/serial: Fix uart registration order when no console defined.
* Explicit registration of ttys0 when no console defined
* Fixes overwriting registration of lpuart1 on ttys1 when no console on ttys0
* Change regstration logic to check for console assignment
* See issue 17116

Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
2025-12-20 11:12:04 +08:00
Justin Erenkrantz
18a1d159a7 risc-v/litex: For vexriscv_smp, match default FDT address in upstream opensbi.
The default opensbi fw_jump.bin expects to see the FDT in 0x40EF0000 per FW_JUMP_FDT_ADDR.

Definitions:

https://github.com/litex-hub/opensbi/blob/0.8-linux-on-litex-vexriscv/platform/litex/vexriscv/config.mk
https://github.com/litex-hub/opensbi/blob/1.3.1-linux-on-litex-vexriscv/platform/litex/vexriscv/objects.mk

Signed-off-by: Justin Erenkrantz <justin@erenkrantz.com>
2025-12-20 11:09:38 +08:00
zhanghongyu
5c61672185 net/tcp/tcp_connect.c: move txnotify after setup_callback
otherwise, when tx is modified to direct mode, wait will not be awakened

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08:00
zhanghongyu
9ce35caf4e net/tcp: fix the problem of nested tx in the rxcb process
since the current txnotify is executed synchronously at the location of
the current call without switching threads, resources such as d_iob need
to be cached first.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08:00
zhanghongyu
2ebb08e78f netdev_upperhalf: avoid recursion during transmission
to avoid uncontrollable stack overhead, we actively
avoid scenarios where recursion occurs.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08:00
zhanghongyu
16947ddacd netdev_upperhalf: modify txavail to be sent directly in the current thread
avoid packet processing delays caused by task switching,
to support those applications that are extremely time-sensitive.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-20 10:58:16 +08: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
buxiasen
4028132910 libc/localtime: rename offsetp to poffset
Fix spell check error
lib_localtime.c:1291: offsetp ==> offset

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-19 13:46:21 -05:00
buxiasen
bda9ab9287 libc/localtime: tz_lock/unlock should not touch tcb except FLAT
Causing kernel build report undefined reference 'g_nx_initstate'
Also protect build, as user elf have no access of kernel objects.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2025-12-19 13:46:21 -05: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
raiden00pl
cb7fb72fae boards/nucleo-f446re: disable OSTEST in some configs
Disable OSTEST in configurations whose purpose is to test peripherals.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-19 08:39:41 -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
7003a2c14d rtc_time:set zero rtc_time struct
timegm set struct tm, not set nsec, so rtc_time->nsec will be a random
value, so set it zero.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-19 01:58:44 +01:00
simbit18
946bd2b36e boards/risc-v/esp32c3: add Waveshare ESP32-C3-Zero
- Add initial support for Waveshare ESP32-C3-Zero.

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-12-19 07:14:22 +08:00
raiden00pl
96af0ceedf boards/nucleo-g431rb/qenco: reduce FLASH
disable ostest from qenco configuration to reduce FLASH.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-18 17:25:23 +01:00
raiden00pl
1b358af82f Documentation: add notes about TAP configuration for qemu
add notes how to configure QEMU network with TAP.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-18 11:39:54 -03:00
raiden00pl
67e3266275 boards/qemu-intel64/jumbo: enable more network tools
enable more network tools for qemu-intel64/jumbo so we can easly test net with qemu

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-12-18 11:39:54 -03:00
anjiahao
fb8da4b89d mps3-an547:support protect mode
add mps3-an547:knsh configs

./tools/configure.sh mps3-an547:knsh
make -j20
qemu-system-arm -M mps3-an547 -m 2G -device loader,file=nuttx.hex -device loader,file=nuttx_user.hex -gdb tcp::1129 -nographic

nsh>ostest

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 22:19:44 +08:00
guohao15
635d81a76b cmake:add missing cflag "-D_FILE_OFFSET_BITS=64" of sim
The -D_FILE_OFFSET_BITS=64 parameter is missing
during the CMake compilation of the sim (simulator) build,
which causes incorrect version invocations of interfaces
such as hostfs_stat.

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2025-12-18 22:18:49 +08:00
yangao1
011fd50bcd libc/arch_libc.c:fix bug for macro LIBC_ARCH_STRCHRNUL
config ARM64_STRCHRNUL
	bool "Enable optimized strchrnul() for ARM64"
	default n
	select LIBC_ARCH_STRCHRNUL
	depends on ARCH_TOOLCHAIN_GNU
	---help---
		Enable optimized ARM64 specific strchrnul() library function

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-12-18 22:05:12 +08:00
yangao1
184f1ef225 libs/risc-v:add cfi for optimized compilation func
(gdb) bt
    at /home/mi/ssd/dev-system/nuttx/include/string.h:321
    ppcmd=<synthetic pointer>, vtbl=0x80069498) at nsh_parse.c:1909
    param=0x800692b8) at nsh_parse.c:2593
    cmdline=cmdline@entry=0x80069750 "hello") at nsh_parse.c:3028
    argc=argc@entry=1, argv=argv@entry=0x80068870) at nsh_session.c:246
    at nsh_consolemain.c:75
    at nsh_main.c:74
...

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-12-18 22:05:12 +08:00
yangao1
15eb317be2 libc/arm64: add cfi for optimized func
(gdb) bt
    #0  arch_strlen () at machine/arm64/gnu/arch_strlen.S:119
    #1  0x000000004043a2c0 in strchr (s=s@entry=0x408e5e40 "HELLO WORLD", c=c@entry=87) at machine/arch_libc.c:252
    #2  0x0000000040504c6c in strchr (c=87, s=0x408e5e40 "HELLO WORLD") at /home/mi/ssd/dev-system/nuttx/include/string.h:306
    #3  test_strchr () at hello_main.c:79
    #4  hello_main (argc=argc@entry=1, argv=argv@entry=0x40b5c090) at hello_main.c:132
    #5  0x000000004043d958 in nxtask_startup (entrypt=0x40504ba0 <hello_main>, argc=argc@entry=1, argv=argv@entry=0x40b5c090) at sched/task_startup.c:72
    #6  0x00000000403f1ab4 in nxtask_start () at task/task_start.c:104
    #7  0x0000000000000000 in ?? ()

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-12-18 22:05:12 +08:00
yangao1
34aef9cbec armv7a:add cfi instrcutions to debug
(gdb) bt
    #0  memset () at machine/arm/armv7-a/gnu/arch_memset.S:45
    #1  0x0407222e in memset (n=4, c=65, s=0x40269d94) at /home/mi/ssd/dev-system/nuttx/include/string.h:203
    #2  test_memset () at hello_main.c:57
    #3  hello_main (argc=<optimized out>, argv=<optimized out>) at hello_main.c:66
    #4  0x0403f1de in nxtask_startup (entrypt=0x40721b1 <hello_main>, argc=1, argv=0x40269628) at sched/task_startup.c:72
    #5  0x0400c66a in nxtask_start () at task/task_start.c:104
    #6  0x00000000 in ?? ()

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-12-18 22:05:12 +08:00
ligd
5e785b14bc memset: add none NEON version support for armv7-a/r
Add memset implementation for ARMv7-A/R targets without NEON support,
ensuring proper operation on CPUs lacking NEON instructions.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2025-12-18 22:05:12 +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
ligd
8a02ca5913 memcpy: fix link failed when open kasan
riscv-none-elf-ld: /home/ligd/platform/dev-system/nuttx/staging/libc.a(arch_libc.o): in function `memcpy':
/home/ligd/platform/dev-system/nuttx/libs/libc/machine/arch_libc.c:131:(.text.memcpy+0x4e): undefined reference to `arch_memcpy'

Signed-off-by: ligd <liguiding1@xiaomi.com>
2025-12-18 22:05:12 +08:00
anjiahao
fe7a877c4e sched/env_putenv:putenv is kernel function need use kmm_free
strdup if use __KERNEL__ defined by nx_strdup
so need kmm_free it

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 21:59:31 +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
zhangshuai39
b09d402d06 nettest: Add a guide document for the nettest directory.
Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-18 21:46:43 +08: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
d7ce29774c sched/hrtimer: Add motivation to hrtimer module description
Enhance the hrtimer module description by explaining its purpose
and use cases, making it more readable and understandable for humans.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2025-12-18 18:36:28 +08:00
wangchengdong
a86af7abcd drivers/timers: Implement up_alarm_start() in arch_alarm.c
Add the implementation of up_alarm_start() in arch_alarm.c.

Signed-off-by: Chengdong Wang wangchengdong@lixiang.com
2025-12-18 18:36:28 +08:00
wangchengdong
506c75069d Documentation: add documentation for the hrtimer module
This commit adds documentation for the hrtimer module, including its
design overview and intended use cases.

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
anjiahao
56bdc0a035 virtio-blk:if in assert,don't wait semaphore
we use virtio-blk as coredump backend, so need support write it when
assert

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 18:21:55 +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
anjiahao
6f1e99c9bd sched: assert if call timedwait from interrupt
Nuttx does not allow calling interfaces like TIME_WAIT in interrupts, so we need to directly assert.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 18:19:42 +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
anjiahao
60dc94b909 procfs/heapcheck:fix bug,aviod '\n' to 0
The lines will end with \n to prevent atoi('\n') from always being 0. It is recommended to check the first byte directly.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 15:37:30 +08:00
anjiahao
431cffa5d8 x86_64:fix syscall type mismatch
/home/ajh/work/vela_system/nuttx/include/arch/syscall.h:181: Error: operand type mismatch for `movq'

`rax`: Used in 64-bit mode, suitable for storing 64 bits of data.

`eax`: In 64-bit mode, typically used for operating on 32-bit data. When writing to `eax`, the high 32 bits of `rax` are automatically cleared to zero.

`nbr` is an unsigned int, is 32-bit.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-12-18 06:31:43 +01:00
zhangshuai39
1914dd0820 net/socket: Check on the end of the NIC name when binding device
When using usrsock to pass the network interface name, omitting "\0" will cause the host to parse extra characters. therefore, the tail section should be inspected during device binding.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2025-12-17 23:01:34 -05: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
rongyichang
963b421c39 drivers/virtio: Fix DRIVERS_VIRTIO_INPUT configuration dependencies
Changed the DRIVERS_VIRTIO_INPUT dependencies from 'depends on' to 'select'
for INPUT_TOUCHSCREEN, INPUT_KEYBOARD, and INPUT_MOUSE options. This ensures
that when DRIVERS_VIRTIO_INPUT is enabled, all required input subsystems are
automatically selected, fixing the issue where mouse device nodes were not
being created properly.

Signed-off-by: rongyichang <rongyichang@xiaomi.com>
2025-12-17 20:48:06 +08: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
fangpeina
e55ba8c82c drivers/input: support return effect duration in ff_dummy
add duration return of an uploaded effect in ff_dummy

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2025-12-17 20:10:09 +08:00
Tomasz 'CeDeROM' CEDRO
7069e77370 tools/nxtagspkgsfetch.sh: Fetch tags packages for NuttX and Apps.
This script downloads all NuttX RTOS and Application snapshot packages
from the upstream git repository based on the provided git tags list.
These are NOT official release packages as checkum will differ.

When launched from the local NuttX git repository clone the script will
obtain all available tags to be downloaded, otherwise list of tags needs
to be provided manually (or when just selected tag is required).
This script uses ``wget`` underneath, make sure this tool is installed.
Fetch log file is created with a timestamp in name next to the packages.

Having all tags packaged is important for changes comparison
between specific versions, testing a specific version, compatibility
checks, searching for a feature introduction timeline, etc.

Usage: `./nxtagspkgsfetch.sh [download_path] [tags_list_space_separated]`

You can provide optional download path (default `../../nuttx-packages`)
and tags list to get packages for (default all tags from local git clone).
When providing tags you also need to provide download path.

Documentation update contains new tool description (above).

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2025-12-17 08:12:44 -03:00