Commit graph

7230 commits

Author SHA1 Message Date
yintao
f671ec648e drivers/rpmsg: add signals router for rpmsg router
Now the rpmsg router transport also support get the signals, and
this signals value is modified by other physical rpmsg transport
(port, virtio) other routed by the rpmsg router.

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-15 16:13:24 -03:00
yintao
492abaa052 drivers/rpmsg: unitfy the rpmsg signals from transport to struct rpmsg_s
Now all the rpmsg transport use the signals in struct rpmsg_s instead
add element in its own private struct.

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-15 16:13:24 -03:00
shichunma
476b7684b7 drivers/mmcsd: fix typo, it should be "Byte" by spec
As subject, it's confusing if with "b".

Signed-off-by: Jerry Ma <masc2008@gmail.com>
2026-01-16 01:38:29 +08:00
wangjinjing1
d7ea114fb8 drivers/can: repair compiler error
Add function definition of "container_of" to fix compiler error.

Signed-off-by: wangjinjing1 <wangjinjing1@xiaomi.com>
2026-01-16 01:37:50 +08:00
Xiang Xiao
acb9a1a296 drivers/timers: check CONFIG_BOARD_LOOPSPERMSEC != 0 at runtime
this config is optional for arch timer/alarm
since it is used only in very early boot stage

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-15 22:57:19 +08:00
lipengfei28
4dec7c2766 drivers/pci:x86_64 calculate bar size
X86_64:nit bar in bios, so in nuttx, the bar is setuped
kvm_set_user_memory_region: KVM_SET_USER_MEMORY_REGION failed

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-15 02:19:57 +08:00
jingfei
36e5752205 ftl:optimize ftl's MTD_ERASE return value check
the MTD ERASE interface has inconsistent return values.
Some implementations return the number of erased sectors,
while others return OK (0). It is currently recommended
to uniformly treat ERASE success as OK. Therefore, the
logic for judging the return value of MTD_ERASE in the
FTL erase interface should be changed to check if it is
greater than 0.

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-14 09:56:04 +08:00
jingfei
3559e97659 mtd/parition:MTD partiton check whether the erase interface exist
Since there is a storage device like RRAM that doesn't
require erasing, the MTD erase function may not exist.
Here, we should first check whether the erase interface
exists before performing the erasing operation.

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-14 09:56:04 +08:00
jingfei
e8fbc997fa ftl:adjust ftl for RRAM/MRAM
Accessing RRAM/MRAM from the FTL interface can
cause errors because RRAM lacks an erase interface.
To make RRAM/MRAM compatible with FTL, the FTL layer
erase interface needs to be modified.

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-14 09:56:04 +08:00
jingfei
152ea6c4bd ftl:remove erase buffer for mtd device without erase interface
When there's no erase function for mtd, we decide if we
need erase_buffer based on this:

1. If we've got bad block marking, we still need the erase buffer.
   If a write fails, it's used to read back the entire bad block's
   contents before writing to a new block.
2. If we don't have bad block marking, the erase buffer isn't
   needed and can be skipped.

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-14 09:56:04 +08:00
liqinhui
3843f7b4fe wifi: Support the wifi operations based on the bss file.
Add support for BSS file-based WiFi simulation.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:54 +08:00
liqinhui
58110f3d1a drivers/net: Fix crash in wifi_sim disconnect.
Add WLAN_STA_STATE_DISCONNECTED state to prevent race conditions or invalid state handling during disconnect.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:40 +08:00
Matteo Golin
a35dcd82e3 drivers/sensors/fakesensor: Remove GNSS dependency
This commit removes the dependency of the fakesensor API on
`SENSORS_GNSS`. All of the logic for handling fake GNSS sensors is
conditionally compiled only if GNSS features are enabled. Other fake
sensors can be used without GNSS logic being included in the build.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-01-14 09:21:35 +08:00
liqinhui
2740e40ee7 drivers/virtio: Use arc4random_buf to generate MAC address.
Use arc4random_buf instead of rand() to improve randomness quality and avoid using weak PRNG for MAC generation.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-13 13:53:03 -08:00
liucheng5
bbda415412 drivers/sensors: add a new sensor type ENG
Add a new sensor type for ENG sensor.

Signed-off-by: liucheng5 <liucheng5@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-13 11:46:07 -03:00
ouyangxiangzhen
4514a11237 sched/sched: Update the comments and docs.
This commit updated the comments and docs after removing the
nxsched_tick_expiration.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-13 21:41:35 +08:00
zhanghongyu
3bb8749672 drivers/net/igc.c: fix build error
otherwise, enable CONFIG_NETDEV_STATISTICS will result in a compile error

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-13 02:17:15 +08:00
wangchengdong
51bcec53c4 nuttx/sched: rename nxsched_timer_expiration
rename nxsched_timer_expiration to nxsched_tick_expiration
    to align with nxsched_process_tick()

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-12 16:20:42 +08:00
wangchengdong
813ab962f5 nuttx/drivers: merge tickless and tick process
merge nxsched_timer_expiration() into nxsched_process_timer()
    to improve code efficient

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-12 16:20:42 +08:00
wangchengdong
9f44bff3cc sched/sched:merge tickless and tick process together
Merge tickless and tick process into  nxsched_process_timer
    to improve code level efficient

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-12 16:20:42 +08:00
chenzihan1
664d2d7213 drivers/sensors: add get_info interface for gnss_uorb
Implement gnss_get_info callback function to support device information query for GNSS sensor devices through the sensor framework.

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-01-10 17:30:33 +08:00
xucheng5
f989860c4a timer: add timer operation support
Add basic timer operations to the kernel, including registration,
start/stop, and callback handling. This provides a consistent timer
interface for use by kernel components and drivers.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2026-01-09 17:10:43 +08:00
Bowen Wang
2a8acac159 rpmsg/rpmsg_port_uart: drop all the packets when reconnect to peer
1. move drop packets function from port spi to port;
2. add drop packets logic when reconnect to peer;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-09 09:48:18 +08:00
Bowen Wang
3d764939c8 rpmsg/rpmsg_port_uart: set the signals based on the suspend/reusme state
Now peer's state can be get by the rpmsg_get_signals() api

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-09 09:48:18 +08:00
Bowen Wang
b8ad562fcb rpmsg/rpmsg_port_uart: add poweroff support
Peer can send poweroff command and local will shutdown the uart
device and wait for the next connect

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-09 09:48:18 +08:00
Bowen Wang
8ba084329d rpmsg/rpmsg_port_uart: add wakeup feauture for rpmsg_port_uart
Wakeup peer when peer is in low power mode

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-09 09:48:18 +08:00
mazhuang
45f6d86f37 drivers/rpmsg: add rpmsg_test to test rpmsg hold/release rx buffer
rpmsg_test is a rpmsg api test service inside the kernel, and user
can use ioctl to start this test.

Signed-off-by: mazhuang <mazhuang@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
2026-01-08 22:44:35 +08:00
Zhe Weng
1d6068f6fb drivers/virtio-gpu: Use macro to indicate blocking cmd
Improving readability, because using bit without name makes people confused.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2026-01-08 22:01:09 +08:00
Zhe Weng
f4bfde4d47 drivers/virtio-gpu: Avoid calling free in IRQ
Calling `virtio_free_buf` or `kmm_free` inside IRQ may lead to dead lock
inside `mm_free`, so we use a free list to store the buffer and reuse it
next time.  Fortunately, NuttX only uses one async buffer at same time,
so we don't need to consider how to free the buffer because we won't
have too many in the free list.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2026-01-08 22:01:09 +08:00
zhanghongyu
02645974cb drivers/net/igc.c: add device id 0x15f3 support
add the network card models whose functions have been confirmed to the
id table.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-08 09:49:07 -03:00
zhanghongyu
446aecdd61 drivers/net/e1000.c: add PIDVID of e1000 NIC
add the network card models whose functions have been confirmed to the
id table.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-08 09:49:07 -03:00
xucheng5
380bcabba8 sja1000: replace enter_critical_section with spinlock
Replace enter_critical_section() with spinlock-based protection to
avoid sleeping in atomic or interrupt contexts.

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2026-01-08 09:15:04 -03:00
wangshaoxin
43d26e2890 drivers/rptun: solve the poweroff stuck problem
The rpmsg_ioctl() function will first obtain the read lock before
traversing g_rpmsg, then the rpmsg_dev_destory function will try
to obtain the write lock.

At this time, rpmsg_ioctl does not release the read lock, resulting
in a deadlock.

To solve this problem, add a standardalone list for the rptun instance
to avoid hold the rpmsg lock when execute rptun_poweroff()

Backtrace:
Thread 14 nsh_main
0  0x4412b9da in up_switch_context (tcb=0xeac03380, rtcb=0xe7f02480) at sim/sim_switchcontext.c:95
1  0x43fbe5e4 in nxsem_wait_slow (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:170
2  0x43fbeacf in nxsem_wait (sem=0x5179d570 <g_rpmsg_lock+16>) at semaphore/sem_wait.c:272
3  0x44671a26 in down_write (rwsem=0x5179d560 <g_rpmsg_lock>) at semaphore/sem_rw.c:248
4  0x4401e255 in rpmsg_device_destory (rpmsg=0xe7b03280) at rpmsg/rpmsg.c:469
5  0x4402f5fe in rptun_dev_stop (rproc=0xe7b033e4, stop_ns=true) at rptun/rptun.c:973
6  0x4402aa28 in rptun_ioctl (rpmsg=0xe7b03280, cmd=11109, arg=0) at rptun/rptun.c:661
7  0x4401ba1e in rpmsg_dev_ioctl_ (rpmsg=0xe7b03280, cmd=11109, arg=0) at rpmsg/rpmsg.c:137
8  0x4401ee88 in rpmsg_ioctl (cpuname=0x0, cmd=11109, arg=0) at rpmsg/rpmsg.c:562
9  0x44030cb0 in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1183
10 0x43f27be2 in board_power_off (status=0) at sim/sim_head.c:211
11 0x446fd933 in boardctl (cmd=65283, arg=0) at boardctl.c:401
12 0x44313b95 in cmd_poweroff (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_syscmds.c:368
13 0x442d148c in nsh_command (vtbl=0xe7600e80, argc=1, argv=0xe7824350) at nsh_command.c:1275
14 0x442f65f5 in nsh_execute (vtbl=0xe7600e80, argc=1, argv=0xe7824350, param=0xe78242b0) at nsh_parse.c:716
15 0x44304fb4 in nsh_parse_command (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2809
16 0x44305a50 in nsh_parse (vtbl=0xe7600e80, cmdline=0xe7601338 "poweroff") at nsh_parse.c:2919
17 0x442bdc91 in nsh_session (pstate=0xe7600e80, login=1, argc=1, argv=0xe7814870) at nsh_session.c:246
18 0x442bbbe5 in nsh_consolemain (argc=1, argv=0xe7814870) at nsh_consolemain.c:75
19 0x4422b4bb in nsh_main (argc=1, argv=0xe7814870) at nsh_main.c:74
20 0x440ee098 in nxtask_startup (entrypt=0x4422b39a <nsh_main>, argc=1, argv=0xe7814870) at sched/task_startup.c:72
21 0x43fa1d6e in nxtask_start () at task/task_start.c:116
22 0x4412982c in pre_start () at sim/sim_initialstate.c:53
23 0x00000000 in ?? ()

Signed-off-by: wangshaoxin <wangshaoxin@xiaomi.com>
2026-01-08 12:05:46 +08:00
mazhuang
183df1ef9e drivers/rptun: solve rptun_dev_stop crash in sim
When execute 'rptun stop /dev/rptun/proxy' in the nsh,
rpmsg_deinit_vdev(&priv->rvdev) will set rvdev->vdev = NULL,
then the remoteproc_remove_virtio(priv->rvdev.vdev) input is NULL,
which will cause crash, the backtrace as follow, so we save the
rvdev->vdev pointer on vdev to solve this problem.

(gdb) bt
0  _assert (filename=0x4002aecc <nxrmutex_destroy+8> "\005D\220\v", linenum=1038, msg=0x400a26a8 "tx_vq", regs=0x400a2768) at misc/assert.c:827
1  0x4002a1db in __assert (filename=0x400a2204 "open-amp/lib/remoteproc/remoteproc.c", linenum=1038, msg=0x0) at assert/lib_assert.c:38
2  0x4006fd83 in remoteproc_remove_virtio (rproc=0xf3ea1880, vdev=0x0) at open-amp/lib/remoteproc/remoteproc.c:1038
3  0x4001b01d in rptun_dev_stop (rproc=0xf3ea1880, stop_ns=true) at rptun/rptun.c:979
4  0x4001a45e in rptun_ioctl (rpmsg=0xf3ea16d0, cmd=11109, arg=0) at rptun/rptun.c:661
5  0x40017246 in rpmsg_dev_ioctl_ (rpmsg=0xf3ea16d0, cmd=11109, arg=0) at rpmsg/rpmsg.c:138
6  0x4001728e in rpmsg_dev_ioctl (filep=0xf3d70a14, cmd=11109, arg=0) at rpmsg/rpmsg.c:153
7  0x4005ef51 in file_vioctl (filep=0xf3d70a14, req=11109, ap=0xf3d80f2c "\352\r\004@F\023\004@\230\020\330\363\353;\354\363(7\354", <incomplete sequence \363>)
   at vfs/fs_ioctl.c:70
8  0x4005f2ff in ioctl (fd=3, req=11109) at vfs/fs_ioctl.c:294
9  0x40041049 in cmd_rpmsg_once (vtbl=0xf3ec3728, path=0xf3ec3beb "/dev/rptun/proxy", argv=0xf3d81098, rpmsg_cb=0x40041346 <cmd_rptun_cb>) at nsh_syscmds.c:616
10 0x400415c8 in cmd_rptun (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098) at nsh_syscmds.c:766
11 0x40036024 in nsh_command (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098) at nsh_command.c:1275
12 0x4003d044 in nsh_execute (vtbl=0xf3ec3728, argc=3, argv=0xf3d81098, param=0xf3d81078) at nsh_parse.c:716
13 0x4003efcc in nsh_parse_command (vtbl=0xf3ec3728, cmdline=0xf3ec3be0 "rptun") at nsh_parse.c:2809
14 0x4003f129 in nsh_parse (vtbl=0xf3ec3728, cmdline=0xf3ec3be0 "rptun") at nsh_parse.c:2919
15 0x40033ca4 in nsh_session (pstate=0xf3ec3728, login=1, argc=1, argv=0xf3d70ae0) at nsh_session.c:246
16 0x400338ea in nsh_consolemain (argc=1, argv=0xf3d70ae0) at nsh_consolemain.c:75
17 0x40033845 in nsh_main (argc=1, argv=0xf3d70ae0) at nsh_main.c:74
18 0x4002bc9f in nxtask_startup (entrypt=0x400337d0 <nsh_main>, argc=1, argv=0xf3d70ae0) at sched/task_startup.c:72
19 0x400077cc in nxtask_start () at task/task_start.c:116
20 0x40031d2f in pre_start () at sim/sim_initialstate.c:53
21 0x00000000 in ?? ()

Signed-off-by: mazhuang <mazhuang@xiaomi.com>
2026-01-08 12:05:46 +08:00
Bowen Wang
f4cfc9579d drivers/rptun: change the notify wait return type after upgrade OpenAMP
return -EAGAIN will cause rpmsg_virtio_get_tx_payload_buffer() in
OpenAMP break immediately, but should return to the sleep() logic
to wait buffer is return.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-08 12:05:46 +08:00
fangpeina
5a22ad4dbb drivers/timers: use DEBUGASSERT check abnormal values
use DEBUGASSERT to check abnormal values in drivers/timers.c

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:56:18 +08:00
fangpeina
bc35ea17d2 drivers/timers: Remove redundant check for crefs > 0 before decrement
The reference count (upper->crefs) is incremented in timer_open()
only after ensuring it will not overflow, timer_close() is only
called after a successful open. Therefore, crefs should never be
zero when timer_close() is called. The check for crefs > 0 before
decrementing is unnecessary and has been removed to simplify the code.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:56:18 +08:00
fangpeina
e4d4f7e2c3 drivers/math: use small lock to replace enter_critical_section
replace critical_section with spinlock

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:17:17 +08:00
fangpeina
e44690e22a drivers/leds: remove bo_closing as lu_lock can prevent race condition occurs
remove enter_critical_section

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:17:17 +08:00
fangpeina
a8214b0b1e drivers/input/ff: use small lock to replace enter_critical_section
replace critical_section with spinlock

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:17:17 +08:00
fangpeina
017df835ba drivers/motor: use small lock to replace enter_critical_section
replace critical_section with spinlock, and use atomic to
protect state.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-08 11:17:17 +08:00
jianglianfang
0737eb3325 virtio-gpu: support vsync and double fb.
changed from a single buffer to a dual buffer, and adapted the vsync buffer queue.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2026-01-08 02:49:43 +08:00
Yongrong Wang
9d6edc37e7 rpmsg: fix rpmsg dead lock and ns bind race condition problem
If a ns_bind message come at between traverse g_rpmsg_cb and add g_rpmsg_cb list,
the cb->node has not been added to the g_rpmsg_cb list yet.
So rpmsg_ns_bind will not find this callback and not call the cb->ns_bind()
to notify the rpmsg services.

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-07 22:47:09 +08:00
liaoao
f9272fa090 rpmsg_port_spi: fix reconnect failed issue
The reconnect will fail because the state changes to connecting when
shutdown cmd is still in process.

And after the shutdown cmd processed, it will reset the state to
unconnected, even though the connect cmd is in ready list,
it will still not be processed.

This patch solve this issue.

Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
bc58b0d837 rpmsg_port_spi/slave: fix the reconnect issue during shutdown process
If connect cmd is dropped during the shutdown cmd process, it will
not be able to reconnect because current side will not try to send
connect cmd after shutdown cmd processed.

So change state to connecting when received connect cmd during the
shutdown cmd process.

Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
ec06af22b8 rpmsg_port_spi.c: setfreq to 0 to shutdown the spi device
In the stop process, add SPI_SETFREQUENCY(rpspi->spi, 0) to stutdown
the spi device.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
1fba4986c9 rpmsg_port_spi/slave: add suspend/resume notify
Now rpmsg port spi can receive peer's suspend and resume command,
suspend command means peer enter into the lowpower state and
resume command means peer waked up

These two commands can let us know peer's running status, so we
will modify the rpmsg signals to let the rpmsg service can get
peer's running state too.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
a41c2cb741 rpmsg_port_spi: add support for peer's shutting down notify
Shutdown mean peer's want to disconnect the connection untial
peer want connect with local side again.

After receive shutdown command, local will clear the state until
reconnecting and clear the gpio status to avoid the leak current.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
01b022fdd0 rpmsg_port_spi_slave: only drop tx queue used buffer when unconnecting
because rxq may have received peer's reconnection data, so we can
connect with peer again.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-07 22:47:00 +08:00
liaoao
972dae38a2 rpmsg_port_spi: add connecting/disconnecting status for port spi
to make sure the connecting process will not be interrupted

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-07 22:47:00 +08:00