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>
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>
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>
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 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Move the NuttX-specific Rust target specification files from apps/tools
to nuttx/tools so files with the same purpose are kept in one place.
The existing aarch64 Mach-O target spec for macOS simulator builds
already lives under nuttx/tools. Keeping the remaining NuttX Rust target
specs there as well makes the layout consistent and lets both Make and
CMake builds refer to target specs from the NuttX tree.
Signed-off-by: Shoji Tokunaga <toku@mac.com>
The ROS 2 C client API generates symbols via rosidl token-pasting
macros. Each message type ends up with a name of the form
<pkg>__msg__<Type>, and the bare type token (Int32, Float64, ...)
appears in user code as an argument to ROSIDL_GET_MSG_TYPE_SUPPORT().
Neither form can be renamed without breaking the public API.
Add the ROS 2 standard message package prefixes (std_msgs,
geometry_msgs, sensor_msgs, nav_msgs, builtin_interfaces,
rcl_interfaces) and the rosidl scalar type names (Int8/16/32/64,
UInt8/16/32/64, Float32/64) to g_white_prefix so nxstyle does not
flag the resulting mixed-case identifiers in apps that consume
micro-ROS via apps/system/microros.
Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This change causes the frame buffer allocation to use the connected
device's physical resolution by default. The user also has the option to
force a request for a different, compile-time selected resolution if the
physical display can support something else the user would prefer.
Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
This commit adds a configuration which uses the new "NXInit" to start up
the board and the NSH shell. The `init.rc` file is pulled from the SD
card, allowing users to create their own.
Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
dac7554_initialize() calls kmm_malloc twice without checking the return
value. If either allocation fails, the subsequent pointer dereferences
lead to a NULL pointer access and crash.
Add NULL checks for both allocations, following the pattern already used
in mcp3008.c, mcp48xx.c, and mcp47x6.c. When the second allocation
fails, free the first allocation before returning NULL.
Signed-off-by: hanzj <hanzjian@zepp.com>
Rename rpmsg_device_destory() to rpmsg_device_destroy() to fix a
spelling error in the function name. The function is declared in the
private header drivers/rpmsg/rpmsg.h and used only within the
drivers/rpmsg/ subsystem (rpmsg.c, rpmsg_virtio.c,
rpmsg_router_edge.c, rpmsg_port.c), so there is no public API or
ABI impact.
Signed-off-by: hanzj <hanzjian@zepp.com>
The uid example was missing documentation. This commit adds complete
documentation including:
- Command syntax and options
- Synopsis explaining the tool's purpose
- Options table with all available flags
- Usage examples for each query type:
- Query user by ID (-uid)
- Query user by name (-uname)
- Query group by ID (-gid)
- Query group by name (-gname)
- Help display example
- Configuration options
The documentation is based on the actual source code in
apps/examples/uid/uid_main.c.
Signed-off-by: hanzj <hanzjian@zepp.com>
This commit is needed to get PR #18951 passing on CI test.
I think this USB Device could be used in the future to do
real hardware tests, including automated tests on our CI.
Signed-off-by: Alan C. Assis <acassis@gmail.com>
Add a custom aarch64 Mach-O Rust target for macOS sim builds and use it
instead of an Apple Darwin Rust target. This keeps Rust cfg values aligned
with NuttX while producing Mach-O objects required by the simulator link.
Also align sim host handling for aarch64 Linux by detecting `aarch64` as
`HOST_ARM64` and avoiding x86-specific `-mcmodel` and `-no-pie` options
on ARM64 hosts.
Signed-off-by: Shoji Tokunaga <toku@mac.com>
Rename static function lan9250_set_txavailabe() to
lan9250_set_txavailable() — missing letter 'l' in 'available'.
This is a static function used only within drivers/net/lan9250.c,
so there is no API or ABI impact.
Signed-off-by: hanzj <hanzjian@zepp.com>
Fix two issues in ads1115_initialize():
1. Add missing kmm_free(priv) when adcdev allocation fails:
If the second kmm_malloc() for adcdev returns NULL, the function
returns without freeing the already-allocated priv structure,
causing a memory leak.
2. Use kmm_free() instead of free() for consistency:
The error path after cmdbyte_init() failure used free(priv) to
release memory allocated by kmm_malloc(). Use kmm_free() instead
to match the allocation API.
Signed-off-by: hanzj <hanzjian@zepp.com>
On some boards, the PCF85263 RTC does not count between reboots. Due to STOP_ENABLE (register 0x2E), bit=0 = 1, which freezes the RTC counter.
The exact trigger is unknown - not all boards exhibit the issue. The bit is battery-backed and
persists across reboots, so once set (e.g. by a power glitch or undefined hardware state) the
RTC stays frozen until explicitly cleared. The old driver never did this.
Fix: write `0x00` to `STOP_ENABLE` on init, which is the correct reset value per the datasheet.
Fix: set time properly:
Due to datasheet the set_time should be as follow:
1. set stop_enable
2. clear prescaler
3. set time
4. clear stop_enable
Signed-off-by: Marin Doetterer <marin@auterion.com>
Fix two bugs in mcp3008_initialize():
1. Remove dead free(priv) when priv is NULL (line 382):
The first allocation checks if priv == NULL, then calls free(priv)
which is a no-op since priv is NULL. Remove the dead call.
2. Add missing kmm_free(priv) when adcdev allocation fails (line 396):
If the second kmm_malloc() for adcdev fails, the function returns
NULL without freeing the already-allocated priv, causing a memory
leak. Add kmm_free(priv) before the return.
Signed-off-by: hanzj <hanzjian@zepp.com>
Document the AM62x platform and add board guides for BeaglePlay and
PocketBeagle2. The BeaglePlay guide includes the validated manual
U-Boot boot flow used for hardware testing.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add initial board support for BeaglePlay and PocketBeagle2, including
defconfigs, linker scripts, board initialization, procfs bring-up, and
LED stubs. BeaglePlay provides the validated runtime target for this
bring-up series.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add the AM62x architecture support needed to boot NuttX on TI K3
AM62x platforms. This includes the chip integration, memory map, IRQ
definitions, low-level console support, boot code, and the AM62x 16550
serial lower half.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Adjust the generic 16550 driver for the AM62x console path. Preserve
the FIFO programming sequence needed by the TI UART, keep the bootloader
owned early console state when requested, and drain the transmit buffer
correctly when polling mode is enabled.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
AM62x enters NuttX through EL2 before dropping to EL1. Enable the
GICv3 system register interface for lower exception levels during the
EL2 handoff so EL1 can use the CPU interface without depending on
firmware state.
Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Add documentation for the ping6 ICMPv6 ECHO request command.
The ping6 tool sends ICMPv6 ECHO_REQUEST packets to a remote
IPv6 host and reports round-trip times and packet loss statistics.
Refs #11081
Signed-off-by: hanzj <hanzjian@zepp.com>
Guard CMN_UCSRCS += arm_perf.c in arch/arm/src/armv7-r/Make.defs so that arm_perf.o is not added twice during flat builds, preventing the duplicate target make error.
Signed-off-by: Nazmi Aras <nazmi.aras@t3gemstone.org>
Add documentation for the T3 Gemstone O1 (t3-gem-o1) development board,
including board specifications, serial console, available
configurations (nsh), and installation instructions via RemoteProc.
Signed-off-by: Erkan Vatan <evatan@t3gemstone.org>
This commit introduces basic support for the T3 Gemstone O1 (t3-gem-o1)
development board, including board configuration, linker scripts, and
drivers for NSH. Currently only UART console is supported.
All necessary files and configurations are added to enable building and
running NuttX on this TI AM67-based board.
Co-authored-by: Emre Cecanpunar <emreleno@gmail.com>
Co-authored-by: Abdullah Türkmen <abdullahturkmen@protonmail.com>
Co-authored-by: Muhammet Onur Bayraktar <mobayraktar@t3gemstone.org>
Co-authored-by: Bayram Akay <bakay@t3gemstone.org>
Co-authored-by: Nazmi Aras <nazmi.aras@t3gemstone.org>
Signed-off-by: Erkan Vatan <evatan@t3gemstone.org>