Commit graph

7589 commits

Author SHA1 Message Date
dongjiuzhu1
3c486b98dd fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes
Implement Linux-compatible TFD_TIMER_CANCEL_ON_SET flag for timerfd to
allow applications to detect discontinuous changes to CLOCK_REALTIME.

Background:
According to Linux timerfd_create(2) man page, when a timerfd is created
with CLOCK_REALTIME and TFD_TIMER_CANCEL_ON_SET flag is specified, the
read() operation should fail with ECANCELED if the real-time clock
undergoes a discontinuous change. This allows applications to detect
and respond to system time changes.

Implementation:
1. Add clock notifier infrastructure (clock_notifier.h/c) to notify
   interested parties when system time changes
2. Implement TFD_TIMER_CANCEL_ON_SET flag support in timerfd
3. Register timerfd with clock notifier when flag is set
4. Cancel timer and return ECANCELED when clock change is detected
5. Notify clock changes in:
   - clock_settime()
   - clock_initialize()
   - clock_timekeeping_set_wall_time()
   - rpmsg_rtc time synchronization

Changes include:
- New files: include/nuttx/clock_notifier.h, sched/clock/clock_notifier.c
- Modified: fs/vfs/fs_timerfd.c to handle TFD_TIMER_CANCEL_ON_SET
- Modified: clock subsystem to call notifier chain on time changes
- Modified: rpmsg_rtc to notify time changes during sync

Use case example:
Applications using timerfd with absolute time can now detect when
system time is adjusted (e.g., NTP sync, manual time change) and
take appropriate action such as recalculating timeouts or updating
scheduled events.

Reference: https://man7.org/linux/man-pages/man2/timerfd_create.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-30 17:20:24 +08:00
lipengfei28
edd86a5b59 drivers/pci:fix pci_disable_irq/pci_enable_irq parameter
fix pci_disable_irq/pci_enable_irq parameter

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-30 12:50:42 +08:00
lipengfei28
6526f2371a drivers/pci:write legacy num to config space when enable legacy irq
write legacy num to config sapce when enable legacy irq

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-30 12:50:42 +08:00
wangjianyu3
91e2ddf5b0 drivers/sensors/gnss: Add monitor logs for activation
Add sensor monitor logs to analyze issues related to driver activation.

This commit adds comprehensive sensor monitoring logs to the GNSS uORB driver
to facilitate debugging and analysis of driver activation issues.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-01-29 21:20:03 +08:00
Bowen Wang
16763e4c67 drivers/rpmsg_port: support release the rx buffer in ept->cb
Now we can release the rx buffer in ept->cb, ept->cb should copy
the rx buffer it's private buffer and then return
RPMSG_SUCCESS_BUFFER_RETURNED.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-29 09:26:50 -03:00
yangsong8
e57e7008aa timers/timer_wdog: Remove the wd_start_period.
Replaced the periodical wdog APIs with wd_start_next.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-29 09:25:07 -03:00
xucheng5
500768c38b timer: add timer wdog
Add timer implemented by watchdog functionality.

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2026-01-29 09:25:07 -03:00
chenzihan1
54cdd8c269 drivers/sensors: add sensor monitor log.
add flush sensor monitor log

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-01-29 18:30:38 +08:00
chenzihan1
18731b509e drivers/sensors: add sensor monitor log.
debug patch to monitor some sensor topic.

Signed-off-by: chenzihan1 <chenzihan1@xiaomi.com>
2026-01-29 18:30:38 +08:00
zhaoxingyu1
2061ef5d2b mtdconfig/nvs: clean up block without valid data during GC
Invalid data is cleared during garbage collection rather than
deleted during initialization, thus accelerating the
initialization speed.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
dd60589895 mtdconfig/nvs: add key check when gc
When key string found corrupted during garbage collection,
then remove key-value pair from the flash.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
9a3f2003df mtdconfig/nvs: add dirty data clean ablility
Remove dirty data to ensure sufficient available
storage space in the flash memory.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
84a16e6842 mtdconfig/nvs: fix -Werror=unused-variable
when enable MTD_CONFIG_BUFFER_SIZE,
1669:10: error: unused variable 'ate_size' [-Werror=unused-variable]
1669 |   size_t ate_size = nvs_ate_size(fs);
2160:10: error: unused variable 'ate_size' [-Werror=unused-variable]
2160 |   size_t ate_size = nvs_ate_size(fs);

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
1b587db667 mtdconfig/nvs: use a fixed size buffer instead of vla
use a fixed size buffer on stack instead of vla,
When it needs to pass misra-c check

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
2e4ce22774 mtd_config/nvs: add data crc8
The purpose is to reduce the conflict rate of ate CRC and
verify the data

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
59f05be525 mtd_config/nvs: keep offset increasing during ate traversal
Enhance the robustness of ATE traversal.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
73de239ad2 mtdconfig/nvs: return 0 when delete a non-exist kv
Deleting a non-existent key-value pair is deemed a successful deletion.

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
zhaoxingyu1
4b7b56a096 mtd/nvs: Fix the issue of compilation failure using the tasking compiler
the tasking compiler reports the error: expression must be constant
in line 510

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-29 14:56:19 +08:00
Bowen Wang
0a27aef078 virtio/virtio-pci-modern: support PCI_RESOURCE_MEM_64 capability
On 64-bit platforms, the capability flags use PCI_RESOURCE_MEM_64
instead of PCI_RESOURCE_MEM. Add support to find both flag types.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 13:09:19 -03:00
Bowen Wang
4f591e19db virtio/virtio-pci: add PCI INTX interrupt fallback support
Fall back to INTX interrupt mode when MSI/MSI-X is not supported
or MSI-X IRQ connection fails. This improves compatibility with
more virtio-pci devices.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 13:09:19 -03:00
Bowen Wang
63c147bfa4 virtio/virtio-pci: remove unused config change IRQ handler
The config change IRQ is not currently used. Remove it now and
add it back when actually needed.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 13:09:19 -03:00
Bowen Wang
5c835881b2 virtio/virtio-pci: improve debug logging and fix comments
- Replace pciXXX() debug calls with vrtXXX() for consistency
- Add additional debug logging for better traceability
- Fix minor comment typos

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-28 13:09:19 -03:00
dongjiuzhu1
1946bc4e44 drivers/serial: fix crash when buffer is full and only recvbuf is implemented
When the receive buffer is full and the driver only implements recvbuf
operation without receive operation, the code would crash due to calling
a NULL function pointer. This patch fixes the issue by:

1. Check if recvbuf is available before calling it
2. When buffer is full, use a temporary buffer to drain hardware FIFO
   to prevent data accumulation in hardware
3. Add proper NULL check for receive operation to avoid crash
4. Initialize pbuf to NULL to prevent uninitialized variable usage

This ensures the serial driver works correctly even when only recvbuf
is implemented and the receive buffer is full.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-28 22:19:21 +08:00
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