Add more refined options for sched/misc/assert to control how verbose
crash dumps are printed out:
- SCHED_DUMP_TASKS
- SCHED_DUMP_STACK
These default to y unless DEFAULT_SMALL is defined. The options can
be undefined to save flash space on a small system.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
- Use shared string for "stack pointer out of range" to avoid duplicate in flash
- Re-use already calculated stack_used instead of calling up_check_tcbstack again
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Some GCC-based external toolchains define **FLT_EVAL_METHOD** but do not
leave the standard FLT_EVAL_METHOD macro visible when the NuttX cmath shim
evaluates its guards.
As a result, C math symbols such as log and pow are declared by NuttX
math.h, but are not imported into namespace std by include/cxx/cmath.
Define FLT_EVAL_METHOD locally from **FLT_EVAL_METHOD** when needed in the
non-CONFIG_LIBM_TOOLCHAIN path.
This fixes compilation of valid C++ code using std::log and std::pow with
arm-none-eabi-g++.
Signed-off-by: nicolasWDC <nicolasWDC@users.noreply.github.com>
Add pseudoFS permission enforcement for unlink(), mkdir(), and rename() VFS mutation operations.
This change validates parent-directory permissions before modifying pseudoFS inode topology and returns -EACCES for unauthorized operations.
The implementation preserves mountpoint filesystem behavior and fixes multiple inode lifetime/search-state issues in the rename path.
Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
Add support for building Rust apps on the NuttX simulator running on
Intel (x86_64) macOS.
- Add tools/x86_64-unknown-nuttx-macho.json, a Mach-O Rust target for
the macOS sim.
- Rust.defs: select the new x86_64 macho target for sim on macOS.
- boards/sim/.../Make.defs: keep the default PIC/PIE-compatible code
generation on macOS by not adding -fno-pic/-mcmodel=medium.
- sethost.sh: enable CONFIG_HOST_X86_64 for non-arm64 hosts.
Signed-off-by: Shoji Tokunaga <toku@mac.com>
Add documentation for the sensortest system tool which reads data
from sensor drivers via the uORB topic interface.
Signed-off-by: hanzj <hanzj@xiaomi.com>
__start is the kernel boot entry for each chip, while _start (defined
in crt0.c) is the correct C runtime entry point for ELF executables.
Signed-off-by: leisiji <2265215145@qq.com>
In SPLIT build mode, nuttx_add_kernel_library(mm SPLIT) creates two
targets: mm (system library) and kmm (kernel library). The compile
options were being applied to the mm target via
target_compile_options(mm ...), but the kasan instrumentation is
compiled as part of the kmm target.
Change target_compile_options(mm ...) to target_compile_options(kmm
...) so that FLAGS (including -fno-builtin and NO_LTO) are correctly
applied to the kernel target where kasan code is compiled.
Signed-off-by: leisiji <2265215145@qq.com>
Bad block management and the logical->physical mapping is only needed
with raw NAND type memories, so we can compile that in conditionally,
saving ~600 bytes of flash on a 32-bit arm when NAND is not used.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add documentation for the tcpdump system command, covering
command-line options (-i, -w, -s), Kconfig configuration,
usage examples, and notes on pcap output format compatibility.
Signed-off-by: hanzj <hanzjian@zepp.com>
It can happen that multiple display configuration is used in which some
displays require explicit update while others do not.
If the updatearea() is NULL, simply skip the update instead of erroring out.
Signed-off-by: Martin Vajnar <martin.vajnar@gmail.com>
The default sim:nsh config has no RTC, causing NSH_DISABLE_DATE to be
auto-enabled (default: DEFAULT_SMALL || !RTC). This means the date
command is not compiled in, and the system time defaults to a hardcoded
value instead of syncing with the host.
Enable CONFIG_RTC, CONFIG_RTC_DRIVER, and CONFIG_RTC_ARCH in the
sim:nsh defconfig so the date command is available and shows the
correct host time out of the box.
Signed-off-by: hanzj <hanzjian@zepp.com>
When CONFIG_FB_UPDATE is defined the missing updatearea() trigger caused
the splashscreen to not be displayed.
Signed-off-by: Martin Vajnar <martin.vajnar@gmail.com>
Wrap the NXSEM_COUNT() and NXSEM_MHOLDER() macro arguments in an extra pair of parentheses before member access.
This makes the helpers safer for complex expressions passed as the macro argument and aligns them with common macro style.
Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
Add `EXTRA_LIB_DEPS` to the simulator nuttx target prerequisites.
This lets Make notice when an extra application library, such as a Rust
static library rebuilt by Cargo, has changed and ensures the final
simulator binary is relinked.
Signed-off-by: Shoji Tokunaga <toku@mac.com>
Add NULL check for g_uart_devs[i] before accessing ->priv in
arm_earlyserialinit() loop. When a USART is not enabled in defconfig,
g_uart_devs[i] is NULL, causing a HardFault crash during early boot.
The bug occurs because the original code only checked g_uart_devs[i]->priv
without first verifying g_uart_devs[i] is not NULL. On Cortex-M4, NULL
pointer dereference reads from Flash vector table (0x00000000 maps to
0x08000000), returning a function pointer that causes BusFault when
written to.
This fix matches the existing NULL check pattern used in arm_serialinit()
at line 2835 of the same file.
Tested on mplant-gd32f450 board with only USART5 enabled in defconfig.
Before fix: HardFault at boot (IPSR=3, PC=0x080003e0)
After fix: System boots normally to NSH Shell
Signed-off-by: lccosy <1191294205@qq.com>
SDIO_REGISTERCALLBACK is only defined when both CONFIG_SCHED_WORKQUEUE and CONFIG_SCHED_HPWORK are enabled.
Guard the callback registration call in mmcsd_sdio.c so the source matches the SDIO callback API availability and avoids
build issues when HPWORK support is not configured.
Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
Make preprocess-generated outputs depend on included files by
emitting depfiles for GNU/Clang Ninja/Makefile builds.
This fixes stale generated rc.sysinit and ROMFS images when a
board-specific included fragment such as rc.sysinit.ap changes,
because the previous custom command only depended on the top-level
source file.
Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
This adds 3 configuration options for the lib_strftime, which can be
used to save flash memory when all the formatters are not needed by an
embedded application.
There is always a minimal set of formatters supported:
"%a, %b/%h, %d, %H, %m, %M, %S, %Y, %%". To add on top of that one can
specify:
- LIBC_STRFTIME_C_STANDARD_FORMATS : All ISO-C conversion specifiers
- LIBC_STRFTIME_POSIX_FORMATS : Additional posix formats
- LIBC_STRFTIME_NONSTANDARD_FORMATS : Additional GNU nonstandard formats
All of these are enabled by default unless building for CONFIG_DEFAULT_SMALL.
Disabling these options can save over 3KB of flash on an 32-bit
ARM system, when all the format specifiers are not needed.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
The previous up_backtrace() relied entirely on host_backtrace() (a thin
wrapper around glibc's backtrace()), which can only unwind the host
thread that calls it. As a result, when assert / dump_tasks() walked the
task list and called sched_dumpstack() for every task, every task other
than the currently-running one returned a zero-length backtrace, and the
output was silently dropped. In practice this meant that on sim only
the crashing task ever produced a usable trace.
Fix this by walking the frame-pointer chain ourselves whenever the
target tcb is not the running task. Because sim's setjmp/longjmp is
provided by NuttX itself (libs/libc/machine/sim/arch_setjmp_*.S) and not
by host libc, the rbp/rsp/rip (or arm fp/sp/pc) saved in tcb->xcp.regs
are plain unmangled pointers, identical across Linux, macOS and Windows
hosts. The frame layout ([fp]=prev fp, [fp+1]=return address) is also
shared by every host ABI sim supports (x86, x86_64, ARM, ARM64).
The walker validates that fp lies inside the task's stack and is
properly aligned, and stops when fp[0] is NULL, so a corrupted stack
cannot make us read out of bounds. The running-task path is unchanged
and still uses host_backtrace() so DWARF unwinding through host
libraries continues to work.
Requires CONFIG_FRAME_POINTER=y so the compiler emits a usable fp link.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Several documentation files are referenced in multiple toctrees,
causing Sphinx build warnings like:
document is referenced in multiple toctrees: [...], selecting: [...]
Fix by narrowing glob patterns in parent toctrees to only match
subdirectory index files, and replacing a toctree directive with
a :doc: cross-reference:
- platforms/arm/index.rst: glob */* -> */index
- platforms/index.rst: glob */* -> */index
- guides/changing_systemclockconfig.rst: toctree -> :doc: ref
Fixes#14785
Signed-off-by: hanzj <hanzj@xiaomi.com>
Fix
====================================================================================
Cmake in present: sim\windows
Configuration/Tool: sim\windows
2026-06-02 12:57:35
------------------------------------------------------------------------------------
Cleaning...
Skipping: sim\windows
------------------------------------------------------------------------------------
End: 2026-06-02 12:57:35
====================================================================================
The "windows-latest" and “windows-2025” labels in GitHub Actions will be migrated to use Visual Studio 2026 by default. Customers needing Visual Studio 2022 must migrate to the windows-2022 image.
https://github.com/actions/runner-images/issues/14017
Signed-off-by: simbit18 <simbit18@gmail.com>
When the CONFIG_MMCSD_MMCSUPPORT is disabled, we can remove the
mmc partition support, saving ~300+ bytes of flash on a 32-bit Arm
target. These partitions don't exist on SD cards.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
readdir() returned NULL at end-of-directory without ensuring errno was
clean. POSIX requires errno to be unchanged at EOF, but the underlying
read() path may leave a stale errno value. Callers that follow the
POSIX idiom (set errno to 0 before the call, test it after a NULL
return), such as readdir_r() and scandir(), then misread this as a
readdir() failure.
Save errno on entry and restore it on the end-of-directory return so
that EOF no longer reports a spurious error, while genuine errors
(read() returning a negative value) still propagate.
Signed-off-by: yushuailong <yyyusl@qq.com>
Replace the default nsh-based init flow on the lckfb-szpi-esp32s3 :adb
defconfig with system/nxinit so that services (sh console, adbd) are
spawned and reaped by init through /etc/init.d/init.rc.
- Enable CONFIG_SYSTEM_NXINIT and set INIT_ENTRYPOINT to init_main
(CONFIG_EXPERIMENTAL is required by SYSTEM_NXINIT).
- Add a common init.rc under boards/xtensa/esp32s3/common/src/etc/init.d
defining 'console' (sh) and 'adbd' services and starting both on init.
fastbootd is wired in for completeness when configured.
- Append the new init.rc to RCSRCS only when SYSTEM_NXINIT is enabled
so existing nsh-based configs remain unaffected.
Verified on lckfb-szpi-esp32s3 hardware: init_main spawns sh and adbd
(both with PPID=init), 'adb shell' reaches a working NuttShell.
Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Fix crypto hash test errors due to SHA224 test which are not supported on NuttX for Xtensa based Espressif devices.
Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
uart_tcdrain() takes a caller-supplied timeout (e.g. 10s from the
TCDRN ioctl path), but the timeout was only applied to the final
TX-FIFO polling loop. The earlier xmit-buffer drain loop called
nxsem_wait(&dev->xmitsem) with no timeout, so any condition that
prevents the lower half from posting xmitsem (e.g. a stuck DMA
completion path, a wedged hardware-flow-control stall) would block
tcdrain() indefinitely, regardless of the timeout the caller asked
for. The pre-existing comment ("NOTE: There is no timeout on the
following loop. ... the caller should call tcflush() first") openly
acknowledged this hang.
Move the start timestamp before both phases and replace the bare
nxsem_wait() with nxsem_tickwait() using the remaining time, so the
total time spent in tcdrain() honors the caller's timeout regardless
of which phase stalls. When the remaining time is already exhausted,
short-circuit to -ETIMEDOUT without calling into the scheduler. The
existing exit path (drop critical section, skip the FIFO polling
loop, unlock the xmit mutex, leave the cancellation point) handles
the new -ETIMEDOUT propagation correctly without further changes.
Also fold the "Set up for the timeout" comment into the kludge
REVISIT comment, since the timestamp is no longer set up at that
point.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
uart_tcdrain() registers a cancellation point on entry via
enter_cancellation_point() (when called with cancelable=true), and the
normal exit path calls leave_cancellation_point() before returning.
However the timeout path inside the FIFO drain loop returns -ETIMEDOUT
directly without going through the normal exit path, leaking one
cancellation point reference (tcb->cpcount is left incremented). Over
repeated timeouts this counter will desync and prevent
pthread_cancel() / pthread_setcancelstate() from behaving correctly
for the calling thread.
Fix by calling leave_cancellation_point() before the early return,
matching the existing exit path.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
Fix crypto hash test errors due to SHA224 test which are not supported on NuttX for
risc-v based Espressif devices.
Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
usrsock_ioctl_handler() copies req->arglen bytes from the request
payload into the fixed-size usrsock->out buffer without validating
that the payload fits either the received request or the destination
buffer. This is the same class of vulnerability as the one already
fixed in nrf91_modem_sock.c (commit a43fb69283).
Add three checks before the copy:
- len >= sizeof(*req): ensure the full request header is present.
- copylen <= len - sizeof(*req): payload must fit the received data.
- copylen <= SIM_USRSOCK_BUFSIZE - sizeof(*ack): payload must fit
the destination buffer.
Signed-off-by: hanzj <hanzjian@zepp.com>
nrf91_usrsock_ioctl_handler() copies req->arglen bytes from the
request payload into the fixed-size usrsock->out buffer without
validating that the payload actually fits either the received
request or the destination buffer. A crafted ioctl request with
an inflated arglen triggers:
1. OOB read — memcpy reads past the end of the received request.
2. OOB write — memcpy writes past the end of usrsock->out.
Add three checks before the copy:
- len >= sizeof(*req): ensure the full request header is present.
- copylen <= len - sizeof(*req): payload must fit the received data.
- copylen <= sizeof(usrsock->out) - sizeof(*ack): payload must fit
the destination buffer.
The recvfrom handler in the same file already performs the equivalent
buffer-size check (line 892). Fixes#18515.
Signed-off-by: hanzj <hanzjian@zepp.com>
Add declarations for dpopen() and dpclose() to unistd.h. These are
the descriptor-based counterparts of popen()/pclose() declared in
stdio.h. The implementation lives in apps/system/popen/dpopen.c.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
The Micro XRCE-DDS Client custom-transport API expects user
callbacks with prototypes of the form
bool open_cb (struct uxrCustomTransport *transport);
size_t read_cb(struct uxrCustomTransport *transport, ...);
The struct tag is fixed by the upstream public header
<uxr/client/profile/transport/custom/custom_transport.h> and
cannot be renamed. nxstyle currently flags every callback
signature in apps/system/microros/transport with 'Mixed case
identifier found'.
Add the 'uxrCustom' prefix to g_white_prefix, following the same
pattern used for the ROS 2 message type names added in
commit bc3a2596c8 ("tools/nxstyle: Whitelist ROS 2 message type
identifiers.").
Signed-off-by: Arjav Patel <arjav1528@gmail.com>