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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>