Commit graph

7340 commits

Author SHA1 Message Date
Yongrong Wang
f56ea30479 drivers/rpmsg: refactor internal APIs to private header
Move rpmsg internal APIs from public header include/nuttx/rpmsg/rpmsg.h
to private header drivers/rpmsg/rpmsg.h. These APIs are only used within
the rpmsg driver implementation and should not be exposed to external
modules.

Moved APIs:
- rpmsg_modify_signals()
- rpmsg_ns_bind() / rpmsg_ns_unbind()
- rpmsg_device_created() / rpmsg_device_destory()
- rpmsg_register() / rpmsg_unregister()

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-26 17:23:31 -03:00
yukangzhi
8226e8e8fe driver/noteram: Support poll threshold
The noteram driver supports setting the poll threshold.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 03:18:38 +08:00
yukangzhi
6ccc2fc7c8 driver/ramlog: Implement the rate limiting function for ramlog driver.
Limit the maximum number of log entries allowed within
the specified time interval in seconds.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 03:17:05 +08:00
jklincn
6538477fa5 drivers/sensors/dhtxx: Fix read return values to be POSIX compliant
The dhtxx driver previously returned 0 on success, which violates standard
character device behavior where the number of bytes read should be returned.
It also used non-standard error codes like -1 or -ENOSYS for operational
errors.

This commit fixes the following behavior to comply with POSIX standards:
* Return sizeof(struct dhtxx_sensor_data_s) on success instead of 0.
* Return -EINVAL instead of -ENOSYS/-1 for invalid buffer arguments.
* Return -ETIMEDOUT instead of -1 for sensor timeouts.
* Return -EIO instead of -1 for checksum or parsing errors.

Signed-off-by: jklincn <jklincn@foxmail.com>
2026-01-27 03:11:25 +08:00
liaoao
ae6ad9c193 drivers/rpmsg_port_spi_slave: add getrecvbuf callback for zero-copy receive
Add a new getrecvbuf callback to the SPI slave device operations
that allows the slave device to provide a pre-allocated receive
buffer directly to the controller. This enables zero-copy data
transfer by allowing the controller to receive data directly into
the device's buffer instead of copying.

Changes:
- Add SPIS_DEV_GETRECVBUF macro and getrecvbuf callback to
  spi_slave_devops_s structure in include/nuttx/spi/slave.h
- Implement getrecvbuf in rpmsg_port_spi_slave driver
- Update getdata to return 0 as it's no longer used for this path

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
fd6ab20362 drivers/rpmsg_port_spi: fix SPI exchange length calculation
The cmdhdr->len was uninitialized before being used in SPI exchange
operations. This caused incorrect transfer lengths.

Changes:
- Initialize cmdhdr->len to sizeof(struct rpmsg_port_header_s) during
  initialization for both SPI master and slave drivers
- Use port.txq.len instead of cmdhdr->len for TX exchange length
- Use port.rxq.len instead of cmdhdr->len for RX getdata length

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
ba81948741 drivers/rpmsg_port_spi/slave: update type of pin number to pinset_t
Correct the gpio pin number type

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
9f4708f643 drivers/rpmsg_port_spi: fix build error
CC:  vfs/fs_unlink.c rpmsg/rpmsg_port_spi.c: In function ‘rpmsg_port_spi_complete_handler’:
rpmsg/rpmsg_port_spi.c:415:11: warning: implicit declaration of function ‘rpmsg_port_spi_drop_packets’; did you mean ‘rpmsg_port_drop_packets’? [-Wimplicit-function-declaration]
  415 |           rpmsg_port_spi_drop_packets(rpspi, RPMSG_PORT_SPI_DROP_ALL);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |           rpmsg_port_drop_packets
rpmsg/rpmsg_port_spi.c:415:46: error: ‘RPMSG_PORT_SPI_DROP_ALL’ undeclared (first use in this function); did you mean ‘RPMSG_PORT_DROP_ALL’?
  415 |           rpmsg_port_spi_drop_packets(rpspi, RPMSG_PORT_SPI_DROP_ALL);
      |                                              ^~~~~~~~~~~~~~~~~~~~~~~
      |                                              RPMSG_PORT_DROP_ALL

rpmsg/rpmsg_port_spi_slave.c:292:5: warning: implicit declaration of function ‘container_of’; did you mean ‘list_container_of’? [-Wimplicit-function-declaration]
  292 |     container_of(port, struct rpmsg_port_spi_s, port);
      |     ^~~~~~~~~~~~
      |     list_container_of

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
986a1f38a6 drivers/rpmsg_port_spi/slave: increase rx thread default stack size
The default stack size should be large enough to avoid the stack
overflow:

0x18551ad8      1968      1968   100.0%!    24.2%   rpmsg-spi

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
49d95aa0d1 drivers/rpmsg_port_spi/slave: remove the pm prepare ops
Use pm wakelock is enough to make sure system will not suspend
when there is a transfer in process, and it can actually sleep when
there is buffer to send but peer side not response in 1ms which is
the timeout we set.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
a52dc0e785 drivers/rpmsg_port_spi_slave: unbind spictrl when peer shutdown
Unbind the spictrl to close the spi controller, and bind it again
when peer boots.
This can help to reduce the leak current caused by the spi gpio.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
Xiang Xiao
fa947f95ee drivers/rpmsg_port_spi/slave: add RPMSG_PORT_SPI_ prefix to BYTES2WORDS
Code format optimization

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-26 21:17:27 +08:00
Xiang Xiao
8981810e96 drivers/rpmsg_port_spi: call rpmsg_port_spi_pm_action(false) in inactive path
Only call rpmsg_port_spi_pm_action(false) when no more data to
transfer to avoid unnecessary pm unlock/lock operations.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
6ca67e4061 drivers/rpmsg_port_spi: check crc value only when crc is enabled
Allow one side enables crc check while the other side not enabled.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
de5ec3be6c drivers/rpmsg_port_spi/slave: notify remote core when reboot
Now rpmsg_port_spi/slave support send shutdown command to remote
core to notify then local core will reboot, so remote core can
notify all the rpmsg services to do the unregister.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-26 21:17:27 +08:00
liaoao
abe28e1bcf drivers/rpmsg_port_spi/slave: add pm ops support for rpmsg port spi
Add low power support for the rpmsg port spi/slave transport, now
the rpmsg port spi/slave transport will not allow enter into the
low power state when there are still tx data to sent or rx data
to processed.

Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-26 21:17:27 +08:00
wangzhi16
03ca455066 sched/sched: Modify the critical section interface name.
replace _wo_note to _notrace.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-26 21:13:05 +08:00
Yongrong Wang
aa567d43f6 drivers/rpmsg: fix struct alignment issue by removing zero array member
This commit fixes a memory alignment issue in the rpmsg subsystem.
The previous implementation used a flexible array member (rdev[0])
in struct rpmsg_s, but due to automatic 8-byte padding, rpmsg->rdev
could differ from the transport layer's rdev address (e.g.,
rpmsg_virtio->rvdev.rdev), causing potential memory corruption.

Changes:
- Remove rdev[0] flexible array member from struct rpmsg_s
- Add rpmsg_get_rdev_by_rpmsg() inline helper to calculate rdev
  address as (rpmsg + 1), ensuring correct pointer arithmetic
- Update all rpmsg->rdev references to use the new helper function
- Fix rpmsg_virtio_notify_wait() to use correct container_of macro

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-26 21:12:34 +08:00
yukangzhi
a6e15f6fbd driver/note: Add tag to note_event_s and note_printf_s
Record the tag in note_event_s and note_printf_s for log filtering.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-26 20:56:45 +08:00
dongjiuzhu1
ae85903f71 drivers/sensors: wakeup mode optimization.
set nonwakeup mode as initialize state.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-26 15:04:11 +08:00
dongjiuzhu1
4dd415b6c1 drivers/sensors: sensor wakeup mode change.
change non-wakeup as default mode.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-26 15:04:11 +08:00
dongjiuzhu1
df2709085c drivers/sensors: using worker to broadcast advertisement message
when remote core connect.

using worker instead of rptun thread to broadcast advertisement
message because the rptun thread can't process rx message when it
calls the ns_bound function.

And the advertisement message to remote core will generate many
the advertisement ack message from remote core, these advertisement
ack messages can't be processed at times by rptun thread.

This can cause rptun thread to block when the number of advertisement
message exceeds the number of ipc buffers between local core and
remote core.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-26 15:04:11 +08:00
dongjiuzhu1
8127c48507 drivers/sensors: sensor rpmsg add new features.
support set_nonwakeup ops for sensor driver to save power

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-26 15:04:11 +08:00
zhaoxingyu1
0e1dd46f3b mtd/mtd_config: add mtdconfig_register_by_path/mtdconfig_unregister_by_path api
mtd_config/mtd_config_nvs should all support
mtdconfig_register_by_path/mtdconfig_unregister_by_path api

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-26 10:52:51 +08:00
zhaoxingyu1
e4a73edec8 mtdconfig: lomtdconfig device change to depends on !MTD_CONFIG_NONE
The structure of mtd_config in Kconfig has changed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-26 10:52:51 +08:00
zhaoxingyu1
273222c06e mtdconfig: modify mtdconfig kconfig
change filename  mtd/mtd_config_fs.c to mtd/mtd_config_nvs.c
and optimize the configuration related to mtdconfig

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-26 10:52:51 +08:00
masc
09f09daeab Author: shichunma <masc2008@gmail.com> Date: Thu Jan 15 07:24:08 2026 +0800
drivers/usbdev/rndis: after client send notication, host can't read msg timely

rndis use intr ep to notify host to read RNDIS message from client, it should
read all the messages cached. Need notify host to read again if there is msg left.

Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
2026-01-25 23:59:49 +08:00
yukangzhi
b50c5f6638 note/noteram: add FIONREAD ioctl to report unread buffer size
Add handling for the FIONREAD ioctl in noteram_ioctl to return the
number of unread bytes in the circular note buffer (noteram_unread_length()).
Validate the argument pointer and return -EINVAL if it is NULL.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-24 23:32:57 +08:00
yinshengkai
d3460aa111 note/ram: support multiple noterams to dump data when panic occurs
When creating a noteram, you can choose whether to dump
this noteram when the system crashes.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-24 19:33:17 +08:00
Bowen Wang
2795918932 drivers/rpmsg: unify cpuname/local_cpuname to struct rpmsg_s
Unify all the cpuname/local_cpuname to struct rpmsg_s, so we can
remove the ops->get_cpuname and ops->get_local_cpuname in
struct rpmsg_ops_s.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-24 17:10:18 +08:00
buxiasen
c4acb35000 drivers/rpmsg_virtio_lite: init the pm wakelock name
Fix the issue that pm feature not picked before
rename the rpmsg_virtio to rpmsg_virtio_lite

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-24 17:10:18 +08:00
yinshengkai
2bfff207fd drivers/serial: Fix SIGINT not delivered to foreground process on Ctrl-C.
When pressing Ctrl-C, the foreground process did not receive SIGINT
and failed to terminate.

The serial driver called nxsig_tgkill(-1, dev->pid, signo) from
interrupt context. With pid=-1, nxsig_dispatch() was called with
thread=true, which requires stcb->group == this_task()->group.
However, in interrupt context, this_task() returns the IDLE task,
whose group differs from the target process group. This caused
the signal dispatch to fail with -ESRCH.

Solution:
Replace nxsig_tgkill(-1, pid, signo) with nxsig_kill(pid, signo).
nxsig_kill() uses thread=false, which routes through group_signal()
without the same-group check, allowing signals to be delivered
correctly from interrupt context.

Impact:
- Fixes Ctrl-C signal delivery in serial console
- No API changes
- Affects serial driver interrupt handling only

Testing: Verified on QEMU ARM64 simulator with serial console

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
2026-01-24 16:54:36 +08:00
yukangzhi
1b22f8c65b driver/note: Fix compilation error when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Add compilation condition for 'nx_vsyslog' syscall.
Export 'sched_note_printf_ip' syscall when CONFIG_SYSLOG_TO_SCHED_NOTE=y
Put the implementation of sched_note_printf_ip in libc/misc/lib_note.c

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-23 07:48:08 -03:00
Bartosz Wawrzynek
585d954d0b boards/sim: Fix watchdog callback
drivers: Fix types and sx127x driver rx
net/pkt: Fix type

Small fixes.

Signed-off-by: Bartosz <bartol2205@gmail.com>
2026-01-23 09:46:02 +08:00
guohao15
5e117fda60 mtdconfig: support ram_mtdconfig device && lomtdconfig device
For nvs test in qemu

Signed-off-by: guohao15 <guohao15@xiaomi.com>
2026-01-22 23:18:26 +08:00
yinshengkai
2c1a615442 net: access the serial port in raw format to avoid character escaping
If the serial port is set to isconsole,
\n will be escaped as \r\n, causing communication failure.

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
2026-01-22 23:17:08 +08:00
dongjiuzhu1
f9c5647813 drivers/sensors: sensor deadlock fix.
using read-write lock to avoid deadlock

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 23:15:48 +08:00
likun17
6a8262314f drivers/sensors: sensor bug fix.
flush fixes the problem of not being able to get the lock.
call trace:

A thread:                               rptun thread:
lock upper_lock
	lock upper_lock
        rpmsg send             ->       wait upper_lock
        unlock upper_lock
        wait response        <--\--     don't reponse this rpmsg request
unlock upper_lock

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 23:15:48 +08:00
dongjiuzhu1
61f7582cc7 drivers/sensors: sensor bug fix.
fix cross-core flush failed when physical driver without flush interface

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 23:15:48 +08:00
dongjiuzhu1
6203332457 drivers/sensors: sensor deadlock fix.
remove lock when driver run set_interval and batch to avoid deadlock

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-22 23:15:48 +08:00
yukangzhi
bcddaa59a9 drivers/pipe: fix POLLHUP handling in poll()
For POLICY_0, when a pipe only has a reader and no writer,
if the pipe is empty, set POLLHUP.

For POLICY_1, when a pipe only has a reader but no writer,
if the pipe is empty, POLLHUP will not be set.

This change corrects poll() behavior to match the two pipe policies.
No API changes.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 22:09:01 +08:00
Bowen Wang
ccf660ce10 drivers/rpmsg: use explicit NULL comparisons for pointer checks
Replace implicit pointer checks (!ptr and ptr) with explicit
NULL comparisons (ptr == NULL and ptr != NULL) to follow
NuttX coding style guidelines.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
6a4feb4fc4 drivers/rpmsg_router: rename dst_ept to peer_ept
peer_ept is a better name than dst_ept

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
7d61b7c43f drivers/rpmsg_router: fix race condition lead to use-after-fre
Should only destroy one side endpoint when receive one side
NS destroy message.

Before:
edge1           hub                  edge2
destroy -->     edge1 destroy
                edge2 destroy
                (used-after-free)
                edge2 destroy    <-- destroy
                edge1 destory

After
edge1           hub                  edge2
destroy -->     edge1 destroy
                edge2 destroy    <-- destroy

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
31664023f9 drivers/rpmsg_router: avoid rpmsg:cpu failed to bind dest
nxsig_clockwait
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_timedwait.c:329 (discriminator 1)
nxsig_clockwait
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_timedwait.c:320
nxsig_nanosleep
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_nanosleep.c:96
nxsig_usleep
/home/work/data/miui_codes/build_home_rom/nuttx/sched/signal/sig_usleep.c:84
__metal_sleep_usec
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/../include/metal/system/nuttx/sleep.h:27
rpmsg_device_destory
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg.c:473
rpmsg_port_unregister
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg_port.c:751
rpmsg_port_spi_process_packet
/home/work/data/miui_codes/build_home_rom/nuttx/drivers/rpmsg/rpmsg_port_spi.c:572
nxtask_start
/home/work/data/miui_codes/build_home_rom/nuttx/sched/task/task_start.c:111

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
28e2ca5d23 drivers/rpmsg_router: Distinguish NS_CREATE or NS_ACK for rpmsg_router_edge
If ns_msg->flags == RPMSG_NS_CREATE_ACK, means already know peer's address
so direclty use usr_ept->dest_addr

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
6e3f0b0a53 drivers/rpmsg_router: fix double free at rpmsg_router_hub_unbind
fist free when rpmsg_port_unregister at rpmsg spi thread
<free+12>
<rpmsg_router_hub_ept_release+6>
<rpmsg_ept_decref+28>
<rpmsg_unregister_endpoint+120>
<rpmsg_destroy_ept+40>
<rpmsg_router_hub_unbind+22>
<rpmsg_device_destory+172>
<rpmsg_port_unregister+26>

this thread will free r:droid and r:audio at last;
But in this process,
rpmsg_destroy_ept "r:droid" will send NS_destroy to audio;
audio will response NS_destroy to ap; if r:droid has not been
removed from the ept list yet, the rptun_audio thread on ap will
occur as follows:

3  0x103016fa in kasan_check_report
4  0x103018b6 in __asan_store4_noabort
5  0x106ca352 in metal_list_del
6             in rpmsg_unregister_endpoint
7  0x106ca77a in rpmsg_destroy_ept
8  0x102db232 in rpmsg_router_hub_unbind
9  0x106cabb2 in rpmsg_virtio_ns_callback
10 0x106cad5c in rpmsg_virtio_rx_callback
11 0x106cc190 in virtqueue_notification
12 0x106ca064 in rproc_virtio_notified
13 0x106c9ad0 in remoteproc_get_notification
14 0x102dd4ba in rptun_worker at rptun/rptun.c:334
15 rptun_worker (arg=<optimized out>) at rptun/rptun.c:328
16 0x102dd974 in rptun_thread  rptun/rptun.c:353
17 0x102cd558 in nxtask_start () at task/task_start.c:1

this will lead to r:audio be freed again.

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
e2e5827c88 drivers/rpmsg_router: Use rpmsg_send_offchannel_raw to fix stuck issue
Use rpmsg_send_offchannel_raw to fix stuck issue avoid getting stuck
when remote destroy ept.

When send messages from ap to android in Rptun thread, Android may
have sent NS_DESTROY through rpmsg_port and changed ept->dst to
RPMSG_ADDR_ANY in rpmsg_port_ns_callback; So rptun thread may be
stuck at this time because rpmsg_send detected dst_ept's dst_addr
is RPMSG_ADDR_ANY.

rpmsg_virtio_thread(rptun audio):
rpmsg_virtio_rx_callback -> rpmsg_router_cb -> rpmsg_send(dst_ept)
send to android

rpmsg_port_thread (android send NS_DESTROY):
rpmsg_port_ns_callback -> dst_ept->dest_addr = RPMSG_ADDR_ANY

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
yintao
f568f6b0bc drivers/rpmsg_router: user_ept's dst_addr should set to RPMSG_ADDR_ANY
when edge_ept received NS_DESTROY message to sync the behavior with
other rpmsg transport

if (ns_msg.flags == RPMSG_NS_DESTROY) {
	if (_ept)
		_ept->dest_addr = RPMSG_ADDR_ANY;
		...

Signed-off-by: yintao <yintao@xiaomi.com>
2026-01-22 22:08:32 +08:00
ligd
0a5940d9ab drivers/rpmsg_router: check hub ept ready before rpmsg_send pm msg
to avoid rpmsg_send() blocked when rpmsg channel is not ready

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-22 22:08:32 +08:00