Commit Graph

60711 Commits

Author SHA1 Message Date
pangzhen1 7acb0df84f arch/arm: Add the macro definitions for CFI instructions for greenhills compiler
Add the macro definitions for CFI instructions for greenhills compiler

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-24 19:32:25 +08:00
trns1997 9159f6e353 build/cmake: Add toolchain C++ library linking for all platforms.
Extend CONFIG_LIBCXXTOOLCHAIN support to all remaining platforms
in CMake builds by explicitly locating and linking libstdc++.a
from the toolchain. This prevents build failures caused by STL
header/library mismatches where toolchain headers are included
without the corresponding library.
* Adds nuttx_find_toolchain_lib() calls for all platforms.
* Aligns CMake behavior with Make build system.

Signed-off-by: trns1997 <trns1997@gmail.com>
2026-01-24 19:30:21 +08:00
yukangzhi b82ad5c495 arch/tricore: disable CPU and system watchdogs during startup
Some Aurix Boot-FW configurations leave watchdogs enabled by default,
which can cause unexpected resets during early bring-up. This change
explicitly disables the CPU and system watchdogs during core0 startup to
ensure reliable system initialization.

- For TC3XX chips, call `IfxScuWdt_disableCpuWatchdog()` and
  `IfxScuWdt_disableSafetyWatchdog()`.
- For TC4XX chips, call `IfxWtu_disableCpuWatchdog()` and
  `IfxWtu_disableSystemWatchdog()`.

This is a low-risk startup change and does not alter watchdog behavior
after system initialization.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-24 19:29:31 +08:00
yukangzhi 8cdf58d124 libs/libc/regex: remove logically dead code in regcomp.c
This change removes redundant and unreachable checks of `status != REG_OK`
that were reported by static code scanning. Two occurrences were fixed in
`libs/libc/regex/regcomp.c`

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-24 19:28:56 +08:00
liwenxiang1 b1fe00fa1e arch/acpi:Fix issue 02 Compile acpidump crash problem
At certain optimization levels, GCC/Clang may insert UD2 if it detects undefined behavior (such as integer overflow or illegal pointer access), causing the program to crash immediately instead of executing unpredictable code.

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2026-01-24 19:28:22 +08:00
pangzhen1 5a1a7dc38e sched/irq: Every function must have exactly one entry point and one exit point
According to MISRA C-2004 Rule 14.7, Every function must have exactly one entry point and one exit point.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-24 19:26:17 +08:00
cuiziwei f17b82bd65 libcxx/libstdc++: Add libsupc++.defs to support libsupc++
This patch adds support for building libsupc++ (the C++ runtime
support library from GCC's libstdc++-v3).

libsupc++ provides core C++ runtime support including:
- Exception handling (eh_*.cc)
- RTTI (Run-Time Type Information)
- Memory allocation operators (new/delete)
- Type info support

The implementation includes:
- libsupc++.defs for libsupc++ build integration
- support make and cmake build
- Use gthr.h, gthr-posix.h and unwind-pe.h from libgcc
- LIBSTDCXX_VERSION config option with default 14.2.0

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-01-24 17:33:19 +08:00
humzak711 e47a0dd228 arch/x86_64: optimize assembly instructions for size and performan
Signed-off-by: humzak711 <humzak711@gmail.com>

arch/x86_64: optimize assembly instructions for size and performance
2026-01-24 17:24:41 +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
hujun5 fd67ef3af9 assert: fix DEBUGASSERT recursive triggering
Add head pointer checks in notifier_call_chain macros to prevent recursion into
sched_lock() when assertions are triggered during early system startup. This avoids
cascading DEBUGASSERT failures when the notifier head is empty or uninitialized.
backtrace:
  DEBUGASSERT(rtcb && rtcb->lockcount < MAX_LOCK_COUNT);
  sched_lock()
  panic_notifier_call_chain
  _assert()
  arm64_fatal_handler

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-24 17:03:57 +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
pangzhen1 72117428fb sched/irq: Avoid directly converting variables of type uintptr_t to void*
According to MISRA C-2012 Rule 11.6, a cast shall not be performed between pointer to void and an arithmetic type

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-23 20:30:05 -03:00
zhanghongyu d5d6b65213 Revert "net: limit TCP and UDP send/recv buffer usage with throttled IOB"
This reverts commit fa652f9c24.

When testing iperf on boards such as ESP32-C6, ESP32-C3, and ESP32,
blocking issues are encountered, so the patch is reverted.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-23 14:40:06 -03:00
yinshengkai 9015f40909 trace: add mark and printf support
Build Documentation / build-html (push) Has been cancelled
Add new trace macros: trace_mark and trace_printf.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-23 11:30:28 -03:00
pangzhen1 d7bb8da695 sched/irq: Fix potential deadlock in irqchain_detach
Release g_irqchainlock before calling irq_detach to avoid holding two locks
simultaneously, which can cause thread deadlock.

The irqchain_detach function was calling irq_detach while holding g_irqchainlock,
and irq_detach attempts to acquire g_irqlock. This lock ordering violation could
lead to deadlock in multithreaded scenarios.

Fix:
- Move spin_unlock_irqrestore(&g_irqchainlock, flags) before irq_detach call
- Ensure locks are released in proper order to prevent circular wait

This is part of the irq_chain_lock feature for safer IRQ chain handling.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-23 08:17:49 -03: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
hujun5 5f92db54a6 sched: fix regression from PR #18040 by adding NULL pointer safety
Replace DEBUGASSERT checks with proper NULL pointer validation in getpid() and
task_get_info() functions. Return IDLE_PROCESS_ID or -ESRCH on NULL conditions
instead of asserting, improving robustness during early system startup and error conditions.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-23 16:59:55 +08:00
yinshengkai cd1000575e docs/dumpstack: improve documentation
Add dumpstack usage and configuration instructions

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
2026-01-23 16:33:01 +08:00
yinshengkai 5892554984 arch/arm64: fix backtrace return address precision
The return address stored in the frame should point to the instruction
after the call. To get the actual call site, we need to subtract the
instruction size (sizeof(void *)) from the saved return address.

This ensures that backtrace addresses correctly point to the calling
instruction rather than the next instruction.

Signed-off-by: yinshengkai <yinshengkai@bytedance.com>
2026-01-23 16:33:01 +08:00
wangchengdong 1d6d682947 boards/sim: enable list-based hrtimer in CI ostest
Enable list-based hrtimer in CI ostest

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-23 16:28:22 +08:00
chenxiaoyi dbbcd7c88c arch/xtensa: remove the use of XCHAL_SYSCALL_LEVEL
After PR#14672, there is no use of XCHAL_SYSCALL_LEVEL.

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2026-01-23 10:52:43 +08:00
chenxiaoyi 775c95a599 arch/xtensa: delete XCHAL_SYSCALL_LEVEL macro definition
After PR#14672, there is no use of XCHAL_SYSCALL_LEVEL.

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2026-01-23 10:52:43 +08: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
hujun5 5051721298 sched/pthread: move pthread mutex from syscall to user-space
Move pthread mutex operations from kernel-space syscall
interface to user-space implementations
to reduce syscall overhead. Relocate mutex holder list
tracking from task control block (tcb) to
thread local storage (tls) to improve memory layout and
cache efficiency. Add helper macros for
conditional mutex implementations and update syscall
interface accordingly.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 12:40:49 -03: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
pangzhen1 b45a658f67 sched/irq: Change the function parameter "regs" to "context"
The identifier regs has been used to represent a type, and cannot be used in here. So change the "regs" to "context"

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 23:15:32 +08:00
hujun5 a3273e6a96 arch: Add stack alignment and stack size checking when CONFIG_TLS_ALIGNED=y
Build Documentation / build-html (push) Has been cancelled
Add validation to ensure allocated stack size does not exceed TLS_MAXSTACK when
CONFIG_TLS_ALIGNED is enabled, and verify proper stack alignment using STACK_ALIGN_MASK
across all architectures. This improves stack safety and prevents potential TLS overflow conditions.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 22:18:11 +08:00
pangzhen1 3522ee372d sched/irq: Fix MISRA C-2012 Rule 8.9 - declare objects in block scope
This patch fixes a Coverity issue where static objects that are only referenced
within a single function should be declared in block scope rather than file scope.
This improves code encapsulation and reduces global namespace pollution.

Changes:
- Moved 'g_irqchainpool[]' from file-level static variable to function-level
  static variable within irqchain_initialize()

This ensures compliance with MISRA C-2012 Rule 8.9 which states: 'An object
should be declared in block scope if its identifier is only referenced within
one function.' The change improves code clarity, maintainability, and follows
best practices for variable scoping.

Benefits:
- Reduces file-level namespace pollution
- Improves code encapsulation
- Makes the scope of the variable immediately obvious
- Maintains static storage duration for the array

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 22:15:30 +08:00
pangzhen1 02eaf3c973 sched/irq: Fix MISRA C-2012 Rule 10.4 - avoid implicit signed to unsigned cast
This patch fixes a Coverity issue where implicit casting from signed int to
unsigned int could lead to unexpected behavior. The fix replaces the implicit
cast with an explicit unsigned literal suffix to ensure type safety.

Changes:
- In irqchain_attach(): Changed comparison 'sq_count(&g_irqchainfreelist) < 2'
  to 'sq_count(&g_irqchainfreelist) < 2u' to use explicit unsigned literal

This ensures compliance with MISRA C-2012 Rule 10.4 which prohibits implicit
conversions between signed and unsigned types. This change prevents potential
integer conversion issues and improves code correctness.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-22 22:15:30 +08:00
ouyangxiangzhen 048ef54c55 include/clock: Remove the inclusion of the macro.h.
Since the macro.h may confilict with the user definition, we should
avoid including the macro.h in clock.h.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 22:14:00 +08:00
ouyangxiangzhen d404b15d8f arch/x86_64: Fix compilation error.
This commit fixed a compilation error about the undefined sizeof(struct tls_info_s).

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 e01fbb757c include/clock.h: Fix type of macro defination of constants
keep type of constants as ul add clock_t cast to tick relate macro.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 bc386d73b4 sched/signal: Fix compilation warning uninitialized.
vela caros CI compilation error: 'stop' may be used uninitialized in this function.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 3491cef8a8 sched/timer: Fix MISRA Rule 10.3
Fix MISRA Rule 10.3 exist clock to sclock cause wide type implicit conversion to narrow type, NSEC_PER_USEC to l

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 2b33168cc0 sched/semaphore: Fix illegal abstime.
Remove CONFIG_DEBUG_FEATURES to check illegal abstime.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 caafba07bc sched/timer: Fix MISRA Rule 10.4
Fix MISRA Rule 10.4 convert signed variabled to unsigned ones.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 51bb9e0417 sched/timer: Fix timer multiple return.
Fix timer multiple return.

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 3b005dbdf7 sched/wdog: Fix MISRA 2004 rule 10.1
Fix MISRA 2004 rule 10.1 implicit type conversion

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
jiangtao16 e171415897 sched/clock: has external linkage but is only used in one translation unit
Fix for MISRA-C rule 8.10

Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
2026-01-22 22:14:00 +08:00
chenxiaoyi 397e7e7a4f macro: use portable variadic macros
The old implementation used a GCC extension related to variadic macros,
where a name prepends the ellipsis, which has portability issues.

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2026-01-22 22:14:00 +08:00
yinshengkai 34e8267fcc macro: FOREACH_ARG Add parameter field
Adjust the definition and fix CONCATENATE.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-22 22:14:00 +08:00
yinshengkai cc578e33a9 macro: FOREACH_ARG Add parameter field
FOREACH_ARG Add parameter field.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2026-01-22 22:14:00 +08:00
daichuan 763caabf6d boards/boardctl: Add BOARDIOC_MACADDR command
Add a new boardctl command BOARDIOC_MACADDR to retrieve the MAC address of the network interface.

The board_macaddr function needs to be implemented by the board logic.

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-22 22:13:31 +08:00
wangzhi16 d9d438f205 sched/sched: Fix the bug of sched_setaffinity in some special scenarios.
TESTCASE: On CPU1, create a thread with affinity CPU1. Since the priority is the same as the current thread, the newly created thread has not yet been executed. Then, call sched_setaffinity() to reset the affinity of the new thread to CPU0, and then call join to wait for the new thread to finish executing. At this point, the current system is found to be stuck. However, when I create a new thread on CPU0 and set its affinity to CPU1, it can be successfully executed.

REASON: There is a logical judgment in the nxsched_set_affinity function called by sched_setaffinity at the bottom layer. When the affinity is changed, whether nxsched_set_priority() needs to be called to modify the task queue of each CPU. The judgment condition here is "(tcb->affinity & (1 << tcb->cpu)) == 0". If it is for a running program, this is no problem, because tcb->cpu will be assigned the correct value when the task is activated. However, for a program that has not yet run, the value of tcb->cpu is not valid, and the default value is 0. At this time, if you want to change the affinity from CPU1 to CPU0, affinity is 1, tcb->cpu is 0, then the expression (tcb->affinity & (1 << tcb->cpu)) = 1, which does not meet the judgment condition, so the nxsched_set_priority() function is not called. Therefore, it is necessary to set a CPU value that can run for the ready task.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-01-22 22:11:17 +08:00