Commit graph

1421 commits

Author SHA1 Message Date
Nightt
5355adb9cf apps: Fix codespell warnings.
Fix the reported typo warnings and ignore the V4L2 parm field name in apps codespell configuration, matching the main NuttX repository.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Nightt
b4f1e29494 apps: Fix additional open() arguments.
Add missing mode arguments to direct open() calls that use O_CREAT.

Also open the lp503x device with explicit read-only flags instead of O_CREAT, matching the device-node usage.

Signed-off-by: Nightt <87569709+nightt5879@users.noreply.github.com>
2026-05-22 13:39:04 +08:00
Xiang Xiao
f9f59bd0f8 !apps: drop redundant casts on tv_sec/tv_nsec and fix printf formats
Now that time_t is unconditionally 64-bit (signed int64_t) and the
struct timespec fields tv_sec / tv_nsec are wide enough on their own,
the explicit (uint64_t)/(int64_t)/(int) casts that used to guard the
multiplications and subtractions in *_us / *_ms / *_ns helpers are no
longer needed.  Drop them to keep the timekeeping math readable.

In the same spirit, this commit also normalises the printf-style format
specifiers and casts used to print tv_sec / tv_nsec / tv_usec values.
The prior code was a mix of "%d"/"%u"/"%ld"/"%lu"/"%lld" with matching
(int)/(unsigned long)/(long long) casts; some formats truncated time_t
on 32-bit hosts, others mismatched signedness or width.  Replace all
such cases with the portable POSIX-recommended forms:

  - tv_sec  (time_t,       signed, impl-defined width) -> %jd  + (intmax_t)
  - tv_nsec (long,         signed)                     -> %ld  (no cast)
  - tv_usec (suseconds_t / long)                       -> %ld  (no cast)

Also drop two stale `(FAR const time_t *)&ts.tv_sec` casts that are
unnecessary now that ts.tv_sec is plain time_t.

Arithmetic-cleanup files (existing scope):

  - benchmarks/cyclictest/cyclictest.c:        timediff_us()
  - benchmarks/sd_bench/sd_bench_main.c:       get_time_delta_us()
  - examples/oneshot/oneshot_main.c:           maxus computation
  - examples/watchdog/watchdog_main.c:         current_time_ms (x2)
  - industry/nxmodbus/nxmb_internal.h:         nxmb_util_clock_ms()
  - netutils/ntpclient/ntpclient.c:            timespec2ntp()
  - netutils/ptpd/ptpd.c:                      ptp_adjtime()
  - system/dd/dd_main.c:                       elapsed accounting
  - testing/drivers/drivertest/drivertest_posix_timer.c:
                                               get_timestamp()
  - testing/drivers/sd_stress/sd_stress_main.c:get_time_delta()
  - testing/sched/getprime/getprime_main.c:    elapsed accounting
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c:
                                               timespec_avg()

Printf-format-fix files (new in this revision):

  - examples/adjtime/adjtime_main.c
  - examples/charger/charger_main.c
  - examples/netpkt/netpkt_ethercat.c
  - fsutils/mkfatfs/mkfatfs.c
  - graphics/tiff/tiff_initialize.c
  - netutils/ptpd/ptpd.c
  - nshlib/nsh_timcmds.c
  - system/coredump/coredump.c
  - system/ptpd/ptpd_main.c
  - testing/drivers/drivertest/drivertest_oneshot.c
  - testing/mm/kasantest/kasantest.c
  - testing/ostest/semtimed.c
  - testing/sched/pthread_mutex_perf/pthread_mutex_perf.c
  - testing/sched/timerjitter/timerjitter.c
  - testing/testsuites/kernel/time/cases/clock_test_clock01.c
  - testing/testsuites/kernel/time/cases/clock_test_smoke.c

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-22 13:38:25 +08:00
Arjav Patel
e9d1141f7c apps/system/microros: Add CMakeLists.txt for CMake support.
Add CMakeLists.txt file for CMake build system integration.
Enables the micro-ROS library module to be built using NuttX CMake
build system alongside traditional Make-based builds.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
faf07ed3b0 apps/system/microros: Add .gitignore for library build artifacts.
Ignore build outputs and generated files:
- Directories: micro_ros_src/, micro_ros_dev/, build/, install/
- Build outputs: libmicroros.a, toolchain.cmake, colcon.meta
- Archives: *.tar.gz

Prevents build artifacts and downloaded sources from being committed.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
0be4928893 apps/system/microros: Add Makefile skeleton.
Add Makefile with standard NuttX build system integration. Follows
the MENUDESC + Directory.mk pattern used throughout nuttx-apps.
Enables the system/microros module to be built as part of the apps
directory build process.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
2a3a41d53a apps/system/microros: Add Kconfig with configuration options.
Add Kconfig file defining CONFIG_SYSTEM_MICROROS and related options:
- MICROROS_DISTRO: ROS 2 distribution selection (default jazzy)
- MICROROS_TRANSPORT_UDP/SERIAL: Transport method selection
- MICROROS_AGENT_IP/PORT: UDP agent address configuration
- MICROROS_SERIAL_DEVICE/BAUD: Serial transport configuration
- Resource limits: MAX_NODES, MAX_PUBLISHERS, MAX_SUBSCRIPTIONS,
  MAX_SERVICES, MAX_CLIENTS

Allows menuconfig integration for micro-ROS library configuration.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Arjav Patel
bda3448106 apps/system/microros: Create empty library skeleton.
Add Make.defs with copyright header for the micro-ROS library
build system. This establishes the directory structure for Phase 2,
with actual build logic to follow in subsequent steps.

Signed-off-by: Arjav Patel <arjav1528@gmail.com>
2026-05-22 06:49:02 +08:00
Filipe Cavalcanti
43bc7e99d6 system/nxdiag: add CMake support for NXDiag tool
Supports building NXDiag with CMake.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-05-21 12:34:05 +08:00
Shunchao Hu
02153debae system/ping: Fallback to ping6 for gethost error handling.
When ping only receives an IPv6 DNS response, the current command
reports "ping_gethostip" and exits even though ping6 can still
handle the target.

Keep the existing ping and ping6 netutils interfaces unchanged and
add a one-way fallback in the ping command. If IPv4 name resolution
fails, ping will spawn ping6 with the same arguments and let ping6
report the final result.

Signed-off-by: Shunchao Hu <ankohuu@gmail.com>
2026-05-19 09:56:01 +02:00
Xiang Xiao
a6477ec8dc !apps: replace sclock_t with clock_t and drop redundant time_t/off_t casts
Align with the upstream nuttx change that drops the sclock_t alias now
that clock_t is itself a signed 64-bit type (int64_t).  Beyond the pure
sclock_t -> clock_t rename, this commit also removes the
now-unnecessary (time_t)-1 / (time_t)0 / (off_t)-1 casts that were
papering over the previously-unsigned time_t.

Files touched:

  - examples/alarm/alarm_main.c:        sclock_t -> clock_t
  - netutils/dhcpd/dhcpd.c:             sclock_t -> clock_t
  - netutils/ftpd/ftpd.c:               sclock_t -> clock_t
  - netutils/thttpd/libhttpd.c,
    netutils/thttpd/tdate_parse.c:      drop (time_t)-1 / (time_t)0 /
                                        (off_t)-1 sentinel casts
  - system/resmonitor/filldisk.c,
    system/zmodem/zm_receive.c:         sclock_t -> clock_t
  - testing/ostest/wdog.c:              sclock_t -> clock_t (the bulk
                                        of the rename, 30 sites)
  - testing/testsuites/kernel/syscall/cases/{clock_nanosleep_test,
    fsync_test,time_test}.c:            drop (time_t)-1 casts in the
                                        new signed-time_t world

No behavioural change.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Xiang Xiao
3adb14f12d !compiler: drop CONFIG_HAVE_LONG_LONG and require long long support
The matching nuttx commit removes CONFIG_HAVE_LONG_LONG; clean up the
remaining users in nuttx-apps so that "long long" is always assumed:

  - examples/noteprintf, examples/nxscope:
        unconditionally exercise the %lld / long long branch.
  - fsutils/mkfatfs/configfat.c:
        drop the 32-bit fall-back paths in mkfatfs_nfatsect12/16/32;
        always use uint64_t for the FAT-size arithmetic.
  - logging/nxscope/nxscope_chan.c:
        drop the CONFIG_HAVE_LONG_LONG guard around the 64-bit
        sample helpers.
  - netutils/ftpd, netutils/ntpclient:
        always emit the 64-bit format strings.
  - testing/fs/fstest/fstest_main.c:
        drop the parallel 32-bit verification path; keep only the
        64-bit (long long) random pattern generator.
  - system/zmodem/host/nuttx/compiler.h:
        remove the host-side CONFIG_HAVE_LONG_LONG stub macro.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
raiden00pl
783957da07 system/uorb: DEBUG_UORB depends on float data
DEBUG_UORB depends on float data, FIXED16 not supported

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-06 08:54:32 +02:00
raiden00pl
b3cf222836 system/sensorscope: support for fixe16 data
system/sensorscope: support for fixe16 data

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-05-06 08:54:32 +02:00
Matteo Golin
5b0cae9ab0 !apps: Simplify NuttX initialization
BREAKING: In an effort to simplify board initialization logic for NuttX,
NSH will no longer support architecture initialization. This will happen
during boot via the BOARD_LATE_INITIALIZE option. The boardctl command
BOARDIOC_INIT is also no longer available from user-space.

Quick fix:
Any application relying on BOARDIOC_INIT should now enable
BOARD_LATE_INITIALIZE to have initialization performed by the kernel in
advance of the application running. If control over initialization is
still necessary, BOARDIOC_FINALINIT should be implemented and used.
Boards relying on NSH for initialization should also enable
BOARD_LATE_INITIALIZE instead.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-05-06 13:27:05 +08:00
wangjianyu3
62f3d37041 examples/vncviewer: add VNC viewer for LCD display
Add a minimal VNC viewer application that connects to a VNC server
and renders the remote desktop on a local LCD.

Features:
- RFB 3.8 protocol with VNC Authentication (DES, pure software)
- Raw encoding with pixel format auto-detected from LCD driver
- Row-by-row rendering via LCDDEVIO_PUTAREA (minimal RAM usage)
- LCD resolution and format queried at runtime via LCDDEVIO_GETVIDEOINFO
- Auto-reconnect on connection loss with 2-second retry

Usage:
  vncviewer <host> [port]
  vncviewer -p <password> <host> [port]
  vncviewer -p <password> -d <lcd_devno> <host> [port]

Assisted-by: GitHubCopilot:claude-4.6-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-04-24 14:58:49 +02:00
Tiago Medicci
6379e531de system/irtest: Set irtest command line size to CONFIG_LINE_MAX
Let `irtest` command line size be equal to CONFIG_LINE_MAX so that
bigger (or smaller) commands can be set.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
Tiago Medicci
9b6b7607f2 system/irtest: Avoids silently truncating long write_data commands
Long write_data commands can be truncated without any check due to
the maximum size of CONFIG_SYSTEM_IRTEST_MAX_SIRDATA. This commit
adds a check to avoid a silent fail.

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
Tiago Medicci
6cb1a04fe7 system/irtest: Fix issues regarding portability and buffer size
This commit fixes issues regarding portability by using variables
with fixed width (and their format macro constants).

Signed-off-by: Tiago Medicci <tiago.medicci@espressif.com>
2026-04-24 14:58:05 +02:00
raiden00pl
773f69d5d9 modbus: add nxmodbus
NxModbus is a lightweight Modbus protocol stack implementation for NuttX RTOS.

This commit adds:
- nxmodbus stack
- nxmbserver - Modbus Server (Slave) example
- nxmbclient - Modbus Client (Master) tool

Supported Modbus transports:
- ASCII
- RTU over serial port
- TCP
- RAW (ADU) for custom transport implementations

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-04-20 12:45:17 -03:00
Piyush Patle
96a003072d include/debug.h: fix checkpatch fallout in touched apps files
Clean up style issues in the files touched by the <nuttx/debug.h> include
migration so the full apps-side PR passes checkpatch.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
Piyush Patle
9d849adfab include/debug.h: Use <nuttx/debug.h> in apps
Replace app-side includes of <debug.h> with <nuttx/debug.h> to use the
header from the NuttX tree explicitly after the header move.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
wangjianyu3
6a1b2c6903 system/nxrecorder: Fix null pointer dereference in argument parsing
When a command has no arguments (e.g., 'q', 'quit', 'stop'), the strtok_r()
function returns NULL for the arg parameter. The argument trimming loop was
dereferencing this NULL pointer without checking, causing undefined behavior
and system hang on ESP32-S3.

This commit adds a null check before dereferencing the arg pointer in the
leading space trimming loop.

Tested on ESP32-S3 (lckfb-szpi-esp32s3) - quit command now works correctly.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-26 10:42:48 +01:00
wangjianyu3
460281a90f system/fastboot: fix socket() parameter order for TCP transport
SOCK_CLOEXEC and SOCK_NONBLOCK were incorrectly passed as the
third argument (protocol) instead of being OR'd into the second
argument (type). This caused socket() to fail with EPROTONOSUPPORT
(errno 93) on NuttX.

Move SOCK_CLOEXEC | SOCK_NONBLOCK to the type parameter and set
protocol to 0.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-03-23 08:46:18 -03:00
raiden00pl
b986eef7a7 system/sensorscope: fix compilation
fix compilation error:

sensorscope_main.c:314:3: error: implicit declaration of function 'list_initialize'; did you mean 'fs_initialize'? [-Wimplicit-function-declaration]

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-03-23 11:00:44 +01:00
zhaoxingyu1
102c078834 mtd/nvs: modify config name to MTD_CONFIG_NVS part1
Because the MTD_CONFIG configuration item in
drivers/mtd/Kconfig has changed

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-02-02 11:01:19 +08:00
wangxingxing
2908f10154 apps/system/ymodem: Optimized ymodem for burn during bootloader
If device automatically enters the ymodem rb mode when it starts up,
the PC tool does not need to send rb command anymore. Here, when a
specified number of consecutive 'C' are received, the subsequent
ymodem protocol content will continue.

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
2026-02-02 11:00:19 +08:00
anjiahao
8804f086b3 ymodem:sbrb.py send command need flush and reset input buffer
These changes fix reliability issues when initiating ymodem transfers
over serial connections.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-02-02 11:00:19 +08:00
yukangzhi
71593dffad apps/system/trace: support binary dump of noteram
This patch adds support for dumping binary contents from noteram via the
`trace dump -b <file>` command. Changes include:

- Add a `binary` parameter to `trace_dump()` and the public header
  `system/trace/trace.h` to indicate binary output mode.
- Update `trace_dump()` to set the noteram read mode to binary using
  `NOTERAM_SETREADMODE` when requested.
- Update `trace dump` CLI parsing in `system/trace/trace.c` to accept
  the `-b` flag and pass it through to `trace_dump()`.
- Update usage/help text to include the new `-b` option.

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-26 19:32:42 +08:00
hongfengchen
b56c785640 testing: add missing header files
Add missing header files in netutils and lsan modules to fix
implicit function declarations and improve compilation compatibility.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-26 19:32:27 +08:00
dongjiuzhu1
854d00e49e system/uorb: uorb_listener add new features.
Add nonwakeup ways to using uorb_listener

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-26 19:31:45 +08:00
dongjiuzhu1
1f990388ec system/uorb: support non-wakeup subscribe.
default subscribing is wakeup.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-26 19:31:45 +08:00
likun17
a454cf4d94 system/uorb: uorb_listener flush functionality optimization.
uorb/listener:Added flush failure prompt information.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
likun17
ada12ce175 system/uorb: uorb_listener adds new features.
uorb/listener.c: Added flush function.
aurora:/ # uorb_listener -f sensor_accel_uncal,sensor_mag_uncal,sensor_aaa
Waited for 5 seconds without flush complete event. Giving up. err:25

Result:
        Topic [sensor_mag_uncal0] flush: FAILURE. [-1]
        Topic [sensor_accel_uncal0] flush: SUCCESS.
Total number of flush topics: 1/2

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
likun17
183deb66e9 system/uorb: uorb_listener adds new features.
add get sensor device information based on topic.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-23 10:01:33 +08:00
Bartosz Wawrzynek
f09d0b2e09 apps: Fix minor issues for latest toolchains
- crypto/mbedtls: Add -Wno-cpp flag to suppress warnings
- interpreters/quickjs: Add flags to suppress warnings
- lte/alt1250: Fix spelling issues in comments
- system/dd: Add missing includes for modern compilers
- system/zlib: Add -Wno-cpp flag
- testing/cxx: Include missing algorithm header

Signed-off-by: Bartosz <bartol2205@gmail.com>
2026-01-23 10:00:52 +08:00
fangpeina
715da6bde6 system/ymodem: fix send err when partial write
Fix buffer offset calculation in ymodem_send_buffer() to correctly
handle partial writes by advancing the buffer pointer and adjusting
the remaining size on each retry.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-01-23 09:43:22 +08:00
hongfengchen
b72f7997a3 system/popen: close newfd correctly
Fixes a bug where newfd is not properly closed when newfd[0] equals newfd[1].
This can cause file descriptor leaks in certain edge cases where the read
and write sides of the pipe are duplicated.

Signed-off-by: hongfengchen <hongfengchen@xiaomi.com>
2026-01-22 19:54:56 +08:00
likun17
8146403512 system/uorb: uorb listener bug fix.
Fixed the issue that instance+1 subscription will be triggered when
topic exists in this core

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-22 03:34:51 +08:00
guoshichao
755fae7ac1 system/cu: merge the cu.h to cu_main.c
Merge the cu.h header file contents into cu_main.c to simplify the
code structure. The cu_globals_s structure and related definitions
are now directly in cu_main.c.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-20 10:23:34 +01:00
makejian
ddc699a4f3 system/cu: fix signal handler to use sa_sigaction
The sigint() function uses siginfo->si_user but was declared with
only one parameter (int sig). This causes compilation error because
siginfo is undeclared.

Fix by:
1. Rename sigint to cu_exit with proper sigaction signature
2. Use sa_sigaction instead of sa_handler to receive siginfo_t
3. Pass cu pointer via sa.sa_user for signal handler access

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-20 10:23:34 +01:00
wangchengdong
d9afe2db8c signals: fix build and runtime issues when signals all isabled
Fix build and runtime issues when signals all disabled.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-19 22:55:19 +08:00
guoshichao
782de2748f cu: implement the cu exit logic like top cmd
using the local cu_globals_s instance to manange the cu exit procedure

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-19 22:48:25 +08:00
likun17
ed7bb51b14 system/uorb:unit_test bug fix
Fixed the error message caused by inconsistent definitions of pthread_t on different platforms.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-19 12:22:40 +08:00
dongjiuzhu1
7ba3638507 system/uorb: merge set_info to orb_advertise_multi_queue_info.
support new api: orb_advertise_multi_queue_info to advertise topic
with info

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-19 12:22:40 +08:00
likun17
3d97bf02e4 system/uorb:Loop bug fix
Fixed the epoll issue that when multiple events come only the first POLLIN is entered.

Signed-off-by: likun17 <likun17@xiaomi.com>
2026-01-19 12:22:40 +08:00
guoshichao
e804886c68 libuv: fix sendmsg parameter type in NuttX port
Update the libuv NuttX port patch to change sendmsg() parameter from
"struct msghdr *msg" to "const struct msghdr *msg" in the NuttX-specific
implementation stub. This maintains compatibility after NuttX's socket API
was made POSIX-compliant with const-correct parameters.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:10:55 +08:00
zhanghongyu
2b0a4a20f5 iptables: add file lock to prevent concurrent overwrite
the kernel can only prevent the concurrency of s/getsockopt, but
iptables will call these interfaces multiple times at a time. We
need to wait for one iptables to complete before executing the second
one, otherwise the data will be overwritten.

iptables flow:
get current iptables entries [1] -> add new entry 2 [1,2] -> set to kernel [1,2]
get current iptables entries [1] -> add new entry 3 [1,3] -> set to kernel [1,3]
entry 2 is lost

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 17:20:03 +08:00
zhanghongyu
5f634815cb iptables: fix the ipv4 mask conversion error
the configured mask should be in network byte order, but the logic here
calculates it as host byte order.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-15 17:12:03 +08:00
wangchengdong
60d814efa2 sched/signal: Add support to disable partial or all signals
Fix dependency issue when signals are partially or fully enabled

Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-15 15:48:54 +08:00