Commit graph

7366 commits

Author SHA1 Message Date
zhangbo56
6735550815 drivers/rpmsg_port_uart: Fix some compile warnings
some printf formats warning fix

Signed-off-by: zhangbo56 <zhangbo56@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
6b7acc1760 drivers/rpmsg_port_uart: clear the connected stats first when recv poweroff
When recv peer poweroff command, should clear the connected status
first to avoid there is data to send when call the rpmsg_unregister(),
then tx thread hang at the data send process but peer has power
off.

When clear the connected status first, rpmsg_port_uart_tx_ready()
will drop the tx packet to avoid tx thread is waked up to send useless
data.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
8889bdd967 drivers/rpmsg_port_uart: do rpmsg_port_unreigster when connected
rpmsg_port_unreigster() should be called after rpmsg_port_reigster(),
so add the connected condition when receive poweroff command.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
f93876228a drivers/rpmsg_port_uart: add rpmsg_port_uart dump support
Dump the rx/tx thread backtrace.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
7496666de3 drivers/rpmsg_port: support dump ops and dump when get buffer timeout
To debug the tx buffer get failed issue, the rpmsg port uart/spi
can use this mechanism to dump more debug informations.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
e36fd2d05a drivers/rpmsg_port_uart: support the rx recursive logic
Fix the case that tx thread want to send data to peer and try to
wakeup peer, but rx thread blocked on the tx buffer got procees and
so rx thread can't process the commands includes the wakeup ack
command, then the tx thread will hang at the wakeup process forever.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
b200f49697 drivers/rpmsg_port: notify the lower transport when no free buffers
When no free buffers, notify the lower transport, so the lower
transports can know this thing and do some work, such as continue
to process the rx data to avoid the rx thread is blocked that
even can't process the commands.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
5efa6b8ecd drivers/rpmsg_port_uart: move the command process to a function
Extract command process code to a standalone function to simplify
the rx thread code.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
4dce10e024 drivers/rpmsg_port_uart: rename tx/rxwakelock to tx/rx_wakelock
Unified naming method

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
42809c17a7 drivers/rpmsg_port_uart: use ping-pong wake/ack to fix wake/ack issue
Orignal issue: the new wakeup process may be waked by the last Ack
command from peer, and lead the data is lost because peer may have
enter into the sleep mode.

W = Wake, A = WakeAck, R = Relax, D = Data
TX: [0]W-[1]R--------[4]W----[6]DDDDDDDDDDDD-------
RX: ------------[3]A----[5]Enter Sleep-------------

In this figure, Ack command [3] wakeup the wakeup process [4] because
[3] may be received with a delay.

Now use the ping-pong wake/ack command to fix this issue because
the different wake/ack command can block the last Ack command
wake the wrong wakeup process.
W1 = Wake1, A1 = WakeAck1, W2 = Wake2, A2 = WakeAck2, R = Relax, D = Data
TX: [0]W1-[1]R-------[4]W2----------[6]DDDDDDDDDDD--
RX: ------------[3]A1---------[5]A2-----------------

With this patch, the Ack comamnd [3] can't wakeup the wakeup process [4]
because [3] is Ack1 but [4] is Wake2, and local will not send data until
peer response a [5]Ack2.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
4025f258c7 drivers/rpmsg_port_uart: dump error data when recv error char
Try to dump more error log to catch the uart trasmission issue.
1. dump the received error char when received the non start char
at the wait start state;
2. dump the dbg buffer and received buffer when received the
duplicate end char at the wait start state;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
f833f0ed79 drivers/rpmsg_port_uart: add debug buffer for rpmsg_port_uart
Record the history receive data for debug

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
df366b591f drivers/rpmsg_port_uart: add reboot notifier for rpmsg_port_uart
Peer will receive the power off command and unregister the rpmsg
connections to avoid the rpmsg services stuck at the rpmsg operations.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
3e9003802b drivers/rpmsg_port_uart: support wake up by peer core
Support wakeup by peer core (Linux)

1. Add 3 commands: STAYWAKE/RELAXWAKE/STAYWAKEACK

Local will stay the wakeup source when received the STAYWAKE command
and relax the pm wake soucre when received the RELAXWAKE.
And local should response the STAYWAKEACK to peer to notify local has
been waked up.

Local core must send the RELAXWAKE command to peer when there is nothing
to do (send/receive data) otherwise peer can't enter into sleep mode.
So we wakeup the tx thread to send the RELAXWAKE command at the time
that may blocked in the file_read() in rx thread.

NOTE:
Local core should relax the pm wakelock when received POWEROFF
command to allow enter into sleep mode when peer core SHUTDOWN.

2. Change all the flags to event, use event is more convinent
to reprsent all the flags. But the tx sem must be kept because we need
support notify the tx is ready event the tx thread is running to avoid
miss any tx ready event.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
af7ff1b52b drivers/rpmsg_port_uart: process the commands as much as possible
To avoid the command is not processed when hang in the rx_cb

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
d0185e2746 drivers/rpmsg_port_uart: change some important debug logs level
Increace some important debug logs level fot debug

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
ee02d0c769 drivers/rpmsg_port_uart: switch the uart IO to GPIO when peer poweroff
Use the TIOCVHANGUP to notify the driver to switch the uart io
to gpio mode to avoid the current leak caused by the uart io because
peer core may already poweroff so the io can be in high voltage
state.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
579cf47299 drivers/rpmsg_port_uart: reserved more commands for future use
To maintain compatibility in future update, the data transfer is
still valid even can't process the new added command.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Bowen Wang
2386d80d53 drivers/rpmsg_port_uart: do not panic when received error happened
1. Dump the error log and continue process the next packet when
received error happened instead direclty panic to allow use adb
to update peer core's firmeware;
2. Add more error log to debug the receive error;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 19:23:41 +08:00
Xiang Xiao
91d4aeba66 drivers/rpmsg_port_uart: unify the timeout usage
All the timeout use macro RPMSG_PORT_UART_TIMEOUT

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-28 19:23:41 +08:00
Xiang Xiao
4bbccac6f0 drivers/rpmsg_port_uart: Zero next when hit RPMSG_PORT_UART_RX_WAIT_START twice
align the behaviour with Linux driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-28 19:23:41 +08:00
dongjiuzhu1
90fa0ed122 drivers/sensors: sensor bug fix.
fix deadlock about set_nonwakeup.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-28 16:50:19 +08:00
yukangzhi
dea1bc1121 note: add NOTE_DUMP_BINARY support for binary log dumping
Add NOTE_DUMP_BINARY to the note_type_e enum and implement its handling
in noteram_dump_one. This enables the recording and dumping of binary
logs in hexadecimal format, improving traceability for binary event data.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-27 21:56:03 +08:00
likun17
c52d54d500 drivers/sensors: Remove the uncalibrated member of the sensor
lowerhalf layer.

The uncalibrated type is passed in with type. The driver defaults
to the calibrated type.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-27 19:34:33 +08:00
wangzhi16
4fa66a6850 drivers/pwm : remove critical section and mutex.
Use spinlock to replace critical section and mutex.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 17:59:07 +08:00
wangzhi16
4a68e55277 drivers/timer : remove critical section.
Use spinlock to replace critical section

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-27 17:59:07 +08:00
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