Commit graph

9238 commits

Author SHA1 Message Date
raiden00pl
53c234880c netutils/paho_mqtt: separate library worker stack size
Add CONFIG_LIB_MQTT5_THREAD_STACKSIZE for threads created
internally by Paho and use it in Thread.c.
Keep CONFIG_UTILS_MQTT5_STACKSIZE scoped to the two utility
application tasks.

This permits S2OPC to enable MQTT through LIB_MQTT5 without
also building unrelated command-line utilities.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: OpenAI Codex:gpt-5
2026-08-22 17:10:33 -03:00
raiden00pl
6e56388956 netutils/paho_mqtt: fix package preparation and utilities
The bundled patch still contains an MQTTPacket.h hunk for a bool
typedef that no longer exists in Paho 1.3.15. Make and CMake both
hide the resulting rejection, allowing a partially patched source
tree to be compiled. Remove the stale hunk and make patch failures
fatal.

The Make context target also allows VersionInfo.h generation to
race source extraction under parallel builds. Make the generated
header depend on the extraction target so the input template is
present first.

The publisher and subscriber samples live below src/samples but
include public headers from src. Add the Paho source include directory
to the Make flags, matching the CMake targets, so CONFIG_UTILS_MQTT5
builds both utilities.

Finally, define distclean independently of whether the downloaded
tree exists when Make parses the file. Remove package-owned archives
and sources while preserving a developer Git checkout, and ignore
those downloaded paths.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: OpenAI Codex:gpt-5
2026-08-22 17:10:33 -03:00
raiden00pl
e3dc165ccc examples/nxterm: add serial console fallback
Prevent framebuffer startup failures from leaving the system without NSH.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-22 17:09:58 -03:00
raiden00pl
c775800214 examples/nxterm: add PTY-backed keyboard console
Convert event-mode keyboard records into the TTY input and signals NSH expects.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-22 17:09:58 -03:00
raiden00pl
6b3b42008b examples/nxterm: add full-screen window option
Use the full framebuffer instead of the example's centered three-quarter window.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-22 08:47:01 -03:00
raiden00pl
96f6e7d460 system/readline: restore terminal attributes safely
Track successful mode changes so failed setup cannot corrupt terminal state.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-22 08:45:03 -03:00
wangjianyu3
247a8c03cb system/nxinit: fix argument parser treating --option as -- separator
The init_parse_arguments() function checked for '--' by only
comparing the first two characters, causing options like --system,
--nofork to be misinterpreted as the '--' argument separator. This
truncated the remaining arguments. Add an isblank() check on the
third character to ensure only standalone '--' followed by whitespace
triggers the separator logic.

Assisted-by: GitHubCopilot:claude-4.6-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-22 17:36:04 +08:00
wangjianyu3
8ff98a6b51 system/nxinit: Parse default cpu-specific configs
On the basis of init.rc, add default parsing of cpu-specific configs.
- /etc/init.d/init.rc
- /etc/init.d/init.cpu${CPUID}.rc

Refactor function `init_parse_configs()` to parse files from the default path
instead of identifying and parsing directories or files, as the functionality
is unnecessary.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-22 17:36:04 +08:00
Acfboy
d7f64eca5b example/microwindows: exports microwindows/src/include
registers microwindows/src/include through the EXPORTED_INCLUDES
 mechanism in its Make.defs

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
Acfboy
564cabe9b1 build: introduce EXPORTED_INCLUDES machanism
* Introduce EXPORTED_INCLUDES in apps/Make.defs; every entry is
  prefixed with INCDIR_PREFIX and added to CFLAGS/CXXFLAGS so it
  takes effect in the in-tree build as well
* The export target in apps/Makefile copies the content of the listed
  directories into the include directory of the export package, so
  out-of-tree applications built from the package can still find the
  public headers

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
Acfboy
1080111f99 graphics/microwindows: add NONETWORK mode for linking Nano-X apps with the server
* Add CONFIG_MICROWINDOWS_NANOX_NONETWORK which builds the Nano-X
  client library and server in the linked-in (NONETWORK) mode, so
  client applications are linked directly with the server and run in
  the same task, requiring no network stack or socket at all
* Reorganize the source lists: the drawing sources (nxdraw, nxutil,
  nxtransform, nxpaintnc) are shared by both modes, while the server
  is built from srvnet.c in the network mode and srvnonet.c in the
  NONETWORK mode
* Use MULTITHREAD_SERVER in the network mode so that several client
  tasks can run at the same time in the flat build
* Let the examples/nanoxterm start the server task only in the
  network mode (NONETWORK applications run the server inside main)

Assisted-by: OpenCode:DeepSeek-V4-Flash
Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
Acfboy
634d2dbdea examples/nanoxterm: add Nano-X terminal emulator example
* Port the nxterm demo from Microwindows
* Starts the Nano-X server as a separate task before connecting
* Runs an NSH shell instance on a pseudo terminal in the spwaned child
  instead of exec /bin/sh (no filesystem binaries in flat builds)

Assisted-by: OpenCode:DeepSeek-V4-Flash
Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
Acfboy
d79e503612 examples/nanoxcalc: add Nano-X calculator example
* Port the nxcalc demo from Microwindows
* Connects to the Nano-X server started by examples/nanoxterm
* Requires CONFIG_LIBC_FLOATINGPOINT for the result formatting

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
Acfboy
edb4d26663 graphics/microwindows: add Nano-X client library and built-in server support for NuttX
Build the Nano-X client library, server and (optional) built-in window manager
from the bundled Microwindows tree

Signed-off-by: Acfboy <AcfboyU@outlook.com>
2026-08-21 10:59:06 -03:00
raiden00pl
e21cf5c292 system/expat: add reusable XML parser package
add reusable XML parser package

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: OpenAI Codex:gpt-5
2026-08-21 20:09:58 +08:00
aviralgarg05
c0143f0f46 tools: export package metadata and RGB565 icons
Write optional package metadata and convert icons to bounded RGB565 assets. Reject paths outside the package directory.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-21 08:15:34 -03:00
Abhishek Mishra
0b3d36a1a6 testing: add ostest coverage for chroot
Check jail visibility, host-path isolation, child inheritance, and that
a pre-opened host fd remains usable after chroot().

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-21 02:54:29 +08:00
Abhishek Mishra
f75251f7e3 nshlib: close extra fds before jailed execvp
chroot <newroot> <command> closes non-stdio, non-O_CLOEXEC descriptors
before execvp so inherited host fds cannot bypass the jail.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-21 02:54:29 +08:00
Abhishek Mishra
bcf2cd1795 nshlib: add chroot command
chdir into the new root, call chroot("."), then chdir("/") so relative
paths stay in the jail. With a command, execvp() after the jail is set.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-21 02:54:29 +08:00
aviralgarg05
68aa7a838b games/brickmatch: add touchscreen input and module support
Route touch presses through BrickMatch's input layer and allow the game to build as a module.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-20 09:17:22 -03:00
Justin Hammond
f4d71b6074 testing/libc/arch_libc: Time against a clock that runs.
Every measurement repeats until a stated interval has passed, so a clock
that reads the same value twice does not slow the benchmark down, it stops
it returning at all.

CLOCK_MONOTONIC does not advance on every target.  On qemu-intel64 it
reports success and stays at zero, while CLOCK_REALTIME advances normally,
and the benchmark spins in its first measurement with no output after the
heading.

Sample each candidate twice around a busy wait and take the first one whose
reading changes.  Where none does, say so and skip the timing rather than
hang.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 15:27:07 -03:00
Justin Hammond
f45a02c938 testing/libc/arch_libc: Test memccpy and stpncpy.
Neither is covered here, and both are overridable, so a machine or libc
implementation of either goes in unmeasured and unchecked.

memccpy is checked with the search character present, where the copy
stops just past it and the result points there, and absent, where the
whole length is copied and the result is NULL.  stpncpy is checked
against every capacity from zero to four past the length, for the
content, the zero padding beyond the terminator, and the returned
pointer, which is the terminator when the string fits and one past the
end when it does not.

Both sweep all sixty four source and destination alignment pairs, and
both are added to the benchmark, which now covers nineteen functions.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 15:27:07 -03:00
Justin Hammond
f4bb54e4d1 testing/libc/arch_libc: Test strlcpy.
strlcpy is the one function in this directory's reach that nothing here
covers, and a machine directory may override it like any other.

Sweep every source and destination alignment pair against sizes 1 to 64,
and for each of those every capacity from zero to one past the length.
Check the return value, which is the length of src whether or not the
copy fit, the truncation point, the content, that a capacity of zero
writes nothing at all, and that nothing lands past the terminator.

The alignment pairs are the point.  An implementation that walks one of
the two pointers to a boundary and then copies a register at a time is
correct whenever the two agree, so a test that only ever passes matching
alignments says nothing about it.

The timing half is guarded.  perf_gettime() is not a system call, so an
application reaches it only where the C library builds its own copy or
where the application and the kernel are one image; calling it
unconditionally leaves the test unbuildable on a kernel build, which is
where the correctness half is still wanted.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 15:27:07 -03:00
Justin Hammond
d4fd491f5a testing/libc/arch_libc: Add a throughput benchmark.
The existing speed checks time one call at one size, 128 bytes, with both
operands aligned.  A machine implementation usually takes its wide path
only when the pointers satisfy some alignment condition, so that single
point reports the best case and says nothing about the rest of the input
space.

Measure the same functions across a size sweep and every source and
destination alignment pair instead, plus strlcpy.  On rv64 the difference
this exposes is not marginal:

  strcpy    32768 B  s+0/d+0     2938.0 MB/s
  strcpy    32768 B  s+1/d+1     2942.0 MB/s
  strcpy    32768 B  s+1/d+2      626.0 MB/s
  memcmp    32768 B  s+0/d+0      412.4 MB/s
  memcmp    32768 B  s+1/d+2       41.0 MB/s

Two pointers misaligned by the same amount run at the aligned rate;
misaligned by different amounts they fall to a tenth of it.  Neither
number is visible from an aligned measurement alone.

A function with no machine implementation reports the same rate at every
alignment, so the sweep also shows which of them a machine directory
actually covers.

Each result reports MB/s, which compares across machines, and cycles per
byte where perf_gettime() is reachable from an application, both from one
timed loop.  strcat starts from an empty destination on each turn, since
appending to the last result would grow it without bound, so its figure
includes that store.

It sits behind TESTING_ARCH_LIBC_BENCH, default n, because a measurement
runs for a fixed interval and a full sweep takes about a minute.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 15:27:07 -03:00
aviralgarg05
5e057f38b9 build: add declarative shared library support
Add Library.mk for declarative shared-library builds. Reuse the compiler-runtime lookup shared with Application.mk and cover multi-source libraries with sotest.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-18 15:26:18 -03:00
raiden00pl
fa4a430080 interpreters/python: fix build for x86_64 targets built with the host gcc
NuttX x86_64 (qemu-intel64) builds with the native host gcc, which
exposed several host-environment leaks in the CPython cross build:

- Pass the -D/-U macro flags from CFLAGS as CPPFLAGS so
  preprocessor-only configure probes (Misc/platform_triplet.c) do not
  see the host's __linux__ and misdetect the platform as
  x86_64-linux-gnu, enabling Linux-only code such as the perf
  trampoline.

- Force linux/random.h and sys/xattr.h probes to no in config.site:
  NuttX provides neither, but a native toolchain resolves them against
  the host /usr/include.  The former drags host ioctl macros into
  posixmodule, the latter enables os xattr support with no xattr
  syscalls to link against.

- Disable _curses, _curses_panel, _dbm, _gdbm, _hashlib and _tkinter:
  their host libraries are discovered via pkg-config when the target
  compiler can compile host headers.  hashlib keeps working through
  the built-in HACL implementations.

- Only build _posixsubprocess when the arch has a real fork(): its
  vfork() support is only an optimization and the fork() fallback path
  (PyOS_BeforeFork/PyOS_AfterFork_*) is compiled unconditionally but
  declared only under HAVE_FORK.  This also fixes rv-virt:python,
  which became vfork-only after the fork/vfork split.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 15:23:54 -03:00
aviralgarg05
0eb44a1085 system/nxstore: add an LVGL app-store front end
Add an LVGL front end for browsing, installing, updating, and launching nxpkg entries. Keep network and install work off the UI path, and stop launched apps with SIGTERM.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-18 15:23:15 -03:00
000exploit
191e244082 graphics/pdcurs34: Fixes for wide char build
Signed-off-by: 000exploit <illialoo99@gmail.com>
2026-08-19 00:49:57 +08:00
zhaoyutao1
a59eb5ce1a nshlib: fix builtin_isavail() index 0 check
builtin_isavail() returns 0-based index on success and negative
errno on failure. The condition 'index > 0' incorrectly rejects
valid index 0, making the first builtin app (index 0) unusable
as an NSH command under CONFIG_NSH_BUILTIN_AS_COMMAND.

Fix by changing to 'index >= 0'.

Signed-off-by: zhaoyutao1 <zhaoyutao1@xiaomi.com>
2026-08-18 19:27:44 +08:00
raiden00pl
cc3c3aa316 ci: do not trigger Build on PR description edits
The Depends-On feature (commit 2aebae740) made the Build workflow
trigger on PR description edits. A gate job checks whether the edit
changed any Depends-On declaration: if yes, the build jobs run again
with the new dependencies; on any other edit the gate skips all build
jobs.

The gate has a side effect that breaks PR check results. Skipped jobs
still register check results on the PR, and the PR checks view shows
the newest check run of each name. So after any description edit the
PR shows "skipped" for every build check instead of the pass/fail
from the real run. Re-running that newest run only repeats the skip,
so the real results never come back. This can also hide a red X from
a failed build.

Fix by not triggering Build on description edits at all: remove the
"edited" event type and the gate job.

Depends-On keeps working: dependencies are read from the description
at the start of every run against master, as before. Fetch-Source now
re-reads the description through the API instead of using the copy
stored in the event payload, so every run uses the current Depends-On
state no matter how it was triggered.

After editing a Depends-On line, retrigger CI by any of:
- pushing new or rebased commits to the PR branch
- closing and reopening the PR
- pressing "Re-run all jobs" on the existing Build run

A description edit alone no longer triggers anything, which is
exactly the behavior that corrupted the PR check results.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 10:42:51 +08:00
aviralgarg05
e269d1cbe5 examples/lvgltouch: add touchscreen diagnostics
Add a separate LVGL example that reports touchscreen state, presses, and coordinates without changing lvgldemo.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-17 14:54:55 +02:00
aviralgarg05
2fcb2dfbdd system/nxpkg: complete the package lifecycle
Add the remaining package commands. Order database and payload updates so failures do not leave stale version pointers.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-17 09:20:57 -03:00
aviralgarg05
c4fd2b9b0e system/nxpkg: fetch repositories over HTTP
Download catalogs and artifacts with bounded buffers and atomic staging. Prepare storage before taking the lock so first-run syncs are safe.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-17 09:20:39 -03:00
aviralgarg05
0717e05248 system/nxpkg: validate catalog and database contents
Validate package fields before using them and ensure version pointers refer to installed entries. Keep installed manifests available for rollback.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-17 09:20:22 -03:00
aviralgarg05
d0c15c8c87 system/nxpkg: make package storage crash-safe
Make the nxpkg storage root configurable and write owned files through temporary paths before renaming them. Record lock ownership so processes can recover abandoned locks safely.

Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
2026-08-17 09:13:41 -03:00
Abhishek Mishra
7358692c59 system/sudo: add setuid privilege helper
Install a UNIX-style setuid-root sudo app: the kernel raises euid on
exec, userspace verifies the caller with passwd_verify(), then
setresuid/setgroups and execvp() run the command.  Ostest covers
setuid exec after a hard credential drop.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-17 09:06:13 -03:00
Alan Carvalho de Assis
84ffa84e24 system/toybox: Add toybox a tool box similar to busybox
Toybox is the toolbox used on Android by default. Adding it to NuttX
allows to have more advanced features from Linux, even better support
for shell scripts.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-15 22:28:49 +02:00
wangjianyu3
3328bbb0be system/nxinit: fix on-event actions re-running on every trigger
The `on <event>` action re-executed on every property poll because the
event pending flag was sticky: event_callback returned the same non-zero
pending value whether the event had just changed or had stayed satisfied
from an earlier change. init_action_foreach_event could not distinguish
an edge from a steady state and re-enqueued the action each round
(board_netinit ran 262 times per boot).

Introduce a three-state result (EVENT_STATE_UNSATISFIED / SATISFIED /
TRIGGERED). event_callback now returns TRIGGERED only on the edge where
pending flips false -> true. foreach folds per-event states into a
product clamped to TRIGGERED, enqueuing the action only when every event
is satisfied AND at least one fired this round.

Assisted-by: GitHubCopilot:claude-4.8-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
wangjianyu3
1503c29f5d system/nxinit: Fix index underflow issue
Decrementing i when it's 0 in "for (; i >= 0; i--)" causes size_t
underflow to a huge value.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
wangjianyu3
5b6299100f system/nxinit: Fix multi-event action triggering
Action triggered on any event before this fix (e.g. both opposite actions in
init.rc below triggered when event "boot" triggered).

init.rc

  on boot && property:sys.boot.reason=bootloader
     echo "On boot, the reason is BL."

  on boot && property:sys.boot.reason!=bootloader
     echo "On boot, the reason is not BL."

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
wangjianyu3
1290acf35c system/nxinit: Fix action event parsing loss
init.rc

  on boot && property:sys.boot.reason!=bootloader
     echo "On boot, the reason is not BL."

Before fixing

    init_main: action 0x40436120
    init_main:   sys.boot.reason!=bootloader
    init_main:   argv[0] 'echo'
    init_main:   argv[1] 'On boot, the reason is not BL.'

After fixing

    init_main: action 0x40436120
    init_main:   sys.boot.reason!=bootloader
  + init_main:   default==boot
    init_main:   argv[0] 'echo'
    init_main:   argv[1] 'On boot, the reason is not BL.'

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
wangjianyu3
99dd131a72 system/nxinit: Add support for action triggers
Previously only supported event trigger, now added support for
action triggers (property setting).

Steps to enable action triggers:
  - Define all init_property_*() interfaces declared in this file.
  - Data structures or functions that will likely be used:
    - struct action_trigger_s
    - init_action_for_every()

Example
  ```
  on boot
     setprop key_test
     setprop key_test value_test  /* property changed and matched */
     trigger event_test

  on event_test && property:key_test=value_test
     echo "on event_test, property changed!"

  on property:key_test=value_test
     echo "property changed!"
  ```

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
fangpeina
d04cffd986 system/nxinit: Add setprop support for action
Add the property backend and a setprop builtin so that setting a
property can feed action triggers.  property_simple.c provides a minimal
init_property_*() implementation whose init_property_set() forwards the
key/value pair to init_action_trigger_event(), and init.c wires the
property poller into the init poll loop.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-08-15 18:51:45 +08:00
Abhishek Mishra
2ca518bad7 nshlib: apply privilege prompt markers only after real login
nsh_consolemain always passes NSH_LOGIN_LOCAL, so treating any
non-NONE session as a login rewrote nsh> to nsh# whenever
SCHED_USER_IDENTITY was enabled.  NTFC boot detection then timed
out on sim/citest and qemu-rv/citest.

Keep CONFIG_NSH_PROMPT_STRING until a successful console or telnet
login (or su).

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-15 18:42:18 +08:00
Abhishek Mishra
0faa02f29f nshlib: apply #/$ prompt markers after login
When NSH_PROMPT_STRING_ROOT/USER are empty, keep NSH_PROMPT_STRING at
boot (for example, "nsh> ") so CI/NTFC boot detection still works.
After login, su, or telnet login, replace the last '>' with '#' (euid 0)
or '$' (non-zero euid) and ensure a trailing space.  Refresh readline
after console/telnet login when line editing is enabled.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-14 11:44:18 -03:00
Abhishek Mishra
3385bc3ef6 testing/ostest: expand multiuser coverage for groups and setresuid
Add supplementary-group, setresuid/setresgid ordering, and saved
set-UID/GID child tests for the POSIX credential APIs.

Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
2026-08-14 11:44:18 -03:00
fangpeina
be038ce406 system: Add stty utility for terminal control
This commit adds a system utily 'stty' to NuttX, providing a standard
Unix-like interface for configuring terminal (TTY) device settings.
The command allows runtime configuration of termios attributes for
serial ports and other character devices.

Usage examples:

  # Set raw mode on ttyS0 (for binary communication)
  nsh> stty -F /dev/ttyS0 raw -echo

  # Set console mode for interactive terminal
  nsh> stty -F /dev/ttyS0 cooked

  # Display current settings
  nsh> stty -F /dev/ttyS0

  # Configure stdin (if it's a TTY)
  nsh> stty echo icanon

  # Set baudrate (if driver support)
  nsh> stty -F /dev/ttyS1 speed 115200

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-08-14 07:51:00 -03:00
Marco Casaroli
860815a33a testing/ostest: Split the fork test into vfork and fork.
ostest's "vfork" test was never testing vfork().  It has the child write a
global and the parent observe the write -- the defining property of *sharing*,
not of vfork(), whose defining property is that the parent is suspended and
whose contract forbids the child to write anything at all.  It passed because
NuttX implemented fork() and vfork() as the same sharing primitive, which
apache/nuttx#19562 separates.

vfork.c is rewritten to test what vfork() promises.  The child does only what
POSIX permits -- it calls _exit(42) and nothing else, not even exit(), which
would run atexit handlers and flush stdio in the parent's address space.  Since
the child may not write memory and the parent cannot run while the child lives,
the observable is the child's exit status:  had the parent not been suspended,
it would have reached waitpid() while the child was still alive.  Where child
status is not retained -- ostest_main() sets SA_NOCLDWAIT for the whole run,
deliberately -- ECHILD is accepted as equally good evidence, since it says the
child was already gone when the parent asked.

fork.c is new and tests POSIX fork():  the child's writes to .data, .bss and
the heap are invisible to the parent and vice versa, a pointer to a stack local
taken before the fork names the same object in both, and the child does
everything a vfork() child may not -- calls malloc() and printf(), and returns
from the function that called fork().

Both run at the top of user_main().  They exercise the lowest-level machinery
in the suite -- address environments, stack setup, the architecture's register
context -- so a fault in one takes the process down instead of reporting a
failure.  Learning that in seconds rather than after everything else has passed
matters when a port is being brought up.

Each test gates on the one primitive it tests, ARCH_HAVE_VFORK and
ARCH_HAVE_FORK respectively.  There is no compatibility layer and no mapping
between symbols.  vfork.c no longer requires SCHED_WAITPID:  the suspension is
in the kernel primitive now, so the test's core assertion holds without it and
only the status check is conditional.

The simulator is the one exception.  It selects ARCH_HAVE_VFORK, but ostest
takes the sim down as soon as the test runs there, so the call keeps the
!ARCH_SIM guard that apps ee7642793 put on the old test in 2024.  The old gate
hid this:  ARCH_HAVE_FORK is not set on the sim, so the test was not built
there at all.

The other in-tree callers are audited for which primitive they actually meant:

* interpreters/python's _posixsubprocess and netutils/libwebsockets'
  LWS_HAVE_WORKING_VFORK want the fork-then-exec path -- ARCH_HAVE_VFORK.
* python's os.fork() and libwebsockets' LWS_HAVE_FORK mean real fork() and stay
  on ARCH_HAVE_FORK, so they become *absent* rather than silently wrong.
* testing/fs/fdsantest's vfork case follows ARCH_HAVE_VFORK.

interpreters/bas is deliberately left alone.  Its SHELL and EDIT statements
reach for vfork() under an ARCH_HAVE_FORK guard and want the same treatment,
but checkpatch.sh checks the whole of any file a patch touches and
bas_statement.c produces 1681 pre-existing findings against master, so a
one-line change there fails CI on its own.  The consequence is small:
EXAMPLES_BAS_SHELL is EXPERIMENTAL and already depends on ARCH_HAVE_FORK, so it
becomes unselectable rather than misbehaving.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-08-14 07:46:54 -03:00
Ricard Rosson
569d8f31db examples/apa102: use fprintf() instead of the kernel _err() macro
_err() is a kernel-internal debug macro from <debug.h>; it resolves to
the kernel-only _err symbol, which an application cannot reference.  In a
flat build the example therefore fails to link:

  apa102_main.c: undefined reference to `_err'

(observed on xtensa/esp32s3).  Report the failure with fprintf(stderr),
which is what the open() error path a few lines above already does.

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude Opus 5 (Claude Code)
2026-08-11 18:13:21 -03:00
Ricard Rosson
a76f5bab50 examples/apa102: depend on LEDS_APA102, not LCD_APA102
This example drives the APA102 LED-strip character driver: it opens
/dev/leddrv0 and writes an array of struct apa102_ledstrip_s from
<nuttx/leds/apa102.h>, which is provided by drivers/leds/apa102.c
(CONFIG_LEDS_APA102).  CONFIG_LCD_APA102 selects an unrelated driver,
drivers/lcd/apa102.c, which drives an APA102 matrix as a framebuffer LCD
and registers no /dev/leddrvN node at all.

The wrong dependency makes the example unusable either way: with the LED
strip driver enabled the example cannot be selected in menuconfig, and
with CONFIG_LCD_APA102 the dependency is met but the driver the example
needs is absent, so it fails at open().

Signed-off-by: Ricard Rosson <ricard@groundbits.com>
Assisted-by: Claude Opus 5 (Claude Code)
2026-08-11 18:13:21 -03:00