RPTUNIOC_START returns the (positive) pid of the rptun kernel thread
in async mode (CONFIG_RPTUN_START_SYNC unset). The action engine
treats any positive builtin return value as the pid of a spawned
child and waitpid()s on it (action.c: "if (ret > 0) pid_running =
ret"). The rptun thread is a detached kthread, never a child of init,
so that wait blocks the whole action queue forever and "on init" /
console never run. Normalize a successful start to 0.
Assisted-by: OpenCode:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
BL uses init framework (not NSH), so the NSH rptun command is not
available. Add rptun as an init builtin command that supports
start and stop subcommands. Also add a generic unlink builtin
command for removing device nodes.
Usage in init.bl.rc:
rptun stop /dev/rptun/corecs
unlink /dev/rptun/corecs
rptun start /dev/rptun/corecs
- rptun start/stop: open device, ioctl(RPTUNIOC_START/STOP), close
- unlink: generic command to unlink any file/device node
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
usbtrace_enable(TRACE_BITSET) was copied from nsh's CONFIG_USBDEV_TRACE
block without also copying nsh's local #define TRACE_BITSET or the
<nuttx/usb/usbdev_trace.h> include it needs. TRACE_BITSET has no
built-in definition; every other CONFIG_USBDEV_TRACE caller in the
tree (nsh, composite, cdcacm, usbmsc) defines its own. This compiled
fine as long as CONFIG_SYSTEM_NXINIT and CONFIG_USBDEV_TRACE were never
both on for the same board; the two combined for the first time and
init.c failed to build with 'TRACE_BITSET' undeclared.
Add the missing include and inline the same error-only bitset those
other callers fall back to when none of their granular trace options
are enabled, since this file has no such granular Kconfig of its own.
Assisted-by: OpenCode:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add a focused wqueue entry that exercises predefined and dynamically
created work queues without changing the no-argument ostest flow.
Share the semaphore wait and basic worker helpers across configurations.
Flat builds exercise scheduler queues, Protected builds exercise USRWORK,
and pthread-enabled builds additionally cover configurable custom worker
pools. When pthread support is disabled, only predefined USRWORK cases are
compiled.
Cover invalid arguments, priority lookup, immediate and delayed work,
pending replacement and cancellation, periodic requeue, synchronous and
parallel cancellation, concurrent queues, callback self-destruction, and
queue teardown.
Assisted-by: Codex:GPT-5
Signed-off-by: DuoYuWang <thirteenking.wang@gmail.com>
Syslog may be output via services such as DFX. When debugging the init
component (e.g., service startup failures, including DFX-related
exceptions), syslog may not be output properly.
Add a debug Kconfig option SYSTEM_NXINIT_STDOUT that redirects all init
log macros (init_debug/info/warn/err) to printf instead of syslog.
This is useful for early boot debugging when syslog is not yet
available or serial console shows no output.
Introduce init_log_output() macro as the common log backend, selected
at compile time between printf (with appended newline) and syslog.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The nxstyle check on CI flagged three spots in monkey_main.c where a
declaration block runs directly into the following statement. Insert a
blank line after the declarations at each location; no logic change.
Fixes the Check job failure on PR #3784:
https://github.com/apache/nuttx-apps/actions/runs/34935981535/job/104273851956?pr=3784
Before:
```
graphics/input/monkey/monkey_main.c:223:2: error: Missing blank line after declarations
graphics/input/monkey/monkey_main.c:363:2: error: Missing blank line after declarations
graphics/input/monkey/monkey_main.c:526:6: error: Missing blank line after declarations
```
After:
```
nxstyle monkey_main.c -> exit 0
```
Assisted-by: Claude Code (GLM-5.3) <claude@anthropic.com>
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
Block SIGTERM at startup and add it to the sigtimedwait() set in
monkey_wait(): a blocked signal is never swallowed by the handler, it
either wakes the in-progress wait or stays pending on the task until
the next sigtimedwait() returns it immediately, so the exit through
the regular monkey_delete() cleanup path is deterministic. Because
the kernel keeps the signal mask and pending queue per task, sibling
monkey instances (e.g. multiple instances started for different
input devices) each stop independently, and no shared state is
involved.
Also add a signal_handler() that logs the received signal and
register it for SIGTSTP/SIGCONT/SIGTERM, so these signals never fall
back to their default actions and stay consumable by sigtimedwait()
/ sigwaitinfo().
Before:
kill -15 <pid> terminates the task via the default SIGTERM action
with no cleanup: no "monkey_delete: OK" is ever printed.
After:
kill -15 <pid> exits within one loop iteration (<= one event period,
100-500ms by default) via monkey_delete(), independently for each
running instance, and restarting monkey works.
Testing:
Built and verified on the NuttX simulator (host: Ubuntu 22.04):
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
# enable in build/.config:
# CONFIG_INPUT=y
# CONFIG_GRAPHICS_INPUT_MONKEY=y
# CONFIG_NSH_MAXARGUMENTS=16
ninja -C build olddefconfig && ninja -C build
./build/nuttx
Run in the nsh prompt (uinput injection mode):
nsh> monkey -t 0x11 -p 100-300 -s 454x454 & (uinput touch)
nsh> monkey -t 0x12 -p 100-300 -s 454x454 -b 0 & (uinput button)
nsh> ps
nsh> kill -15 <pid>
ps with both instances running (each monkey task shows "Waiting
Signal" with SIGMASK 0x8000, i.e. SIGTERM blocked while sitting in
sigtimedwait):
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 0 FIFO Kthread - Ready 0000000000000000 0069584 Idle_Task
1 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067456 sim_loop_wq 0x71204b2003f0 0x71204b200478
2 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067464 hpwork 0x40188860 0x401888e8
4 4 0 100 FIFO Task - Waiting Semaphore 0000000000000000 0067496 init_main
9 9 4 100 FIFO Task - Running 0000000000000000 0067504 sh
10 10 9 110 FIFO Task - Waiting Signal 0000000000008000 0069472 monkey -t 0x11 -p 100-300 -s 454x454
11 11 9 110 FIFO Task - Waiting Signal 0000000000008000 0069448 monkey -t 0x12 -p 100-300 -s 454x454 -b 0
After "kill -15 10" (touch instance exits, button instance
unaffected):
nsh> kill -15 10
[monkey] monkey_wait: Recv sig: SIGTERM
[monkey] monkey_delete: OK
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 0 FIFO Kthread - Ready 0000000000000000 0069584 Idle_Task
1 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067456 sim_loop_wq 0x71204b2003f0 0x71204b200478
2 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067464 hpwork 0x40188860 0x401888e8
4 4 0 100 FIFO Task - Waiting Semaphore 0000000000000000 0067496 init_main
9 9 4 100 FIFO Task - Running 0000000000000000 0067504 sh
11 11 9 110 FIFO Task - Waiting Signal 0000000000008000 0069448 monkey -t 0x12 -p 100-300 -s 454x454 -b 0
After "kill -15 11" (second instance exits the same way, no monkey
task left):
nsh> kill -15 11
[monkey] monkey_wait: Recv sig: SIGTERM
[monkey] monkey_delete: OK
nsh> ps
TID PID PPID PRI POLICY TYPE NPX STATE EVENT SIGMASK STACK COMMAND
0 0 0 0 FIFO Kthread - Ready 0000000000000000 0069584 Idle_Task
1 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067456 sim_loop_wq 0x71204b2003f0 0x71204b200478
2 0 0 224 FIFO Kthread - Waiting Semaphore 0000000000000000 0067464 hpwork 0x40188860 0x401888e8
4 4 0 100 FIFO Task - Waiting Semaphore 0000000000000000 0067496 init_main
9 9 4 100 FIFO Task - Running 0000000000000000 0067504 sh
A new instance started after both kills (PID 12) runs normally and
is again stopped cleanly by kill -15.
Note: on the simulator the uinput devices register as /dev/utouch
and /dev/ubutton, while monkey opens /dev/input0 and /dev/buttons;
the run above used a local (uncommitted) path patch to work around
this. On a board where the device paths match, no patch is needed.
Assisted-by: Claude Code (glm-5.3) <claude@anthropic.com>
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
Add a lightweight Micro XRCE-DDS Client integration with UDP transport support and a publisher example.
Signed-off-by: lljwork2021 <lljwork2021@163.com>
Add ptpinfo()/ptpwarn() calls, gated by the existing
CONFIG_DEBUG_PTP_INFO/_WARN symbols (zero cost when disabled), at
points that previously failed silently: an unrecognized L2 protocol,
a domain mismatch, and a Delay_Resp rejected by the source/requester
identity check. These were essential to diagnosing the drift and
Delay_Req bugs fixed in the two preceding commits on real hardware,
and are kept for future maintainers debugging this path.
Assisted-by: Claude:claude-sonnet-5
Assisted-by: Gemini:gemini-3.8-flash-medium
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
1. On AF_PACKET SOCK_RAW sockets in NuttX, msg_name must be NULL because
the destination MAC address is already contained in the Ethernet header.
Previously, passing sockaddr_in caused sendmsg() to fail immediately
with -EAFNOSUPPORT, completely blocking transmission of Delay_Req.
2. Correct PTP primary multicast MAC address to 01:1b:19:00:00:00
(IEEE 1588 Annex F) and ensure ether_type is in network byte order.
3. Initialize delayreq_interval to 1 second default and guard against 0.
4. Set logmessageinterval to 0x7f (IEEE 1588-2008 Table 23 sentinel for
Delay_Req) instead of inheriting 0 from the announce header template.
5. Update PTP version to 0x12 (2.1, minorVersionPTP=1) to match the
value used by mature implementations such as linuxptp.
Assisted-by: Claude:claude-sonnet-5
Assisted-by: Gemini:gemini-3.8-flash-medium
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
1. Post-jump drift bootstrap: on the first Sync packet following a step
jump, do not compute frequency drift against a synthesized zero delta,
which previously caused the entire residual phase offset (~ms) to be
mistaken for frequency drift (~million ppb) and immediately absorbed.
2. Drift rate formula: normalize the adjustment contribution by the actual
measurement interval instead of the adjtime slew period, and compute
natural delta rate as (delta - last_delta + last_adjtime) / interval.
3. Remove broken last_delta > delta comparison that prevented offsets from
converging and applied inverted corrections on negative overshoots.
4. Correct ptp_adjtime() invocation to always pass adjustment_ns for
CLOCK_REALTIME slewing rather than dropping drift compensation when
delta exceeds threshold. Clamp adjustment_ns to the hardware slew limit
so last_adjtime_ns accurately mirrors the true slew applied.
5. Enable Delay_Req in E2E mode once clock is tracking (not jumping) and
allow software timestamping latency in ptp_process_delay_resp().
6. Propagate initialization return code from ptpd_start() and avoid
unconditional failure print in do_ptpd_start().
Assisted-by: Claude:claude-sonnet-5
Assisted-by: Gemini:gemini-3.8-flash-medium
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Add a dedicated NSH tool for testing and interacting with analog
comparator devices (/dev/comp*). Supports reading comparator output
state, enabling/disabling via IOCTL, and performing an automated voltage
ramp sweep using a DAC device when available.
Assisted-by: Gemini:gemini-2.5-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Declare and define the uORB metadata for the resistance, conductivity,
energy and charge types, and register them in g_sensor_list[] so that
orb_get_meta() and uorb_listener can resolve them by name.
Signed-off-by: likun17 <likun17@xiaomi.com>
Declare and define the uORB metadata for the voltage, current and power
types, and register them in g_sensor_list[] so that orb_get_meta() and
uorb_listener can resolve them by name.
Signed-off-by: likun17 <likun17@xiaomi.com>
SENSOR_TYPE_VELOCITY and SENSOR_TYPE_AMBIENT_TEMPERATURE have an
entry in the kernel g_sensor_meta[] table but no ORB_DECLARE/ORB_DEFINE
in user space, so ORB_ID() fails to link, callers must fall back to
orb_open() by name and lose the o_size check, and uorb_listener cannot
monitor them.
Add the missing metadata and register both in g_sensor_list[];
ambient_temp reuses struct sensor_temp the same way sensor_light_uncal
already reuses struct sensor_light.
Signed-off-by: likun17 <likun17@xiaomi.com>
The guard tested the literal string "{NUTTX_APPS_BINDIR}/dummy.c"
instead of the expanded path, so dummy.c was re-touched after each
reconfigure, invalidating its object. Add the missing '$' so the
guard checks the intended path.
Assisted-by: Claude Code (glm-5.3) <claude@anthropic.com>
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
The guard tested the literal string "{WAMR_MODULE_DIR}" instead of
the expanded path, so it never short-circuited and
file(MAKE_DIRECTORY) ran on every configure. Add the missing '$' so
the guard checks the intended path.
Assisted-by: Claude Code (glm-5.3) <claude@anthropic.com>
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
The guard tested the literal string "{LUAMOD_DIR}" instead of the
expanded path, so it never short-circuited and file(MAKE_DIRECTORY)
ran on every configure. Add the missing '$' so the guard checks the
intended path.
Assisted-by: Claude Code (glm-5.3) <claude@anthropic.com>
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
Services started by nxinit (e.g. "sh") do not open a console device on
their own, unlike nsh_main, which explicitly does so via
nsh_consolemain()/nsh_waitusbready() for USB gadget consoles
(CDC-ACM/PL2303). When such a board switches its top-level init from
nsh_main to nxinit, no code path ever registers/connects the USB
console gadget, and a service that just execs a plain "sh" inherits
whatever (invalid, for a USB gadget console not yet opened at the time
the idle task file descriptors are set up) stdio nxinit itself has.
Add a "console [<device>]" service option: a service declared with it
gets the given device (CONFIG_SYSTEM_NXINIT_CONSOLE_DEV, "/dev/console"
by default, if no device is given) opened and dup'd onto its stdin,
stdout and stderr via posix_spawn_file_actions before it is spawned.
This does not depend on nsh being enabled at all.
For a USB gadget console, the device does not exist until the gadget
is actually registered; boards using one are expected to bring it up
themselves before any service using "console" is started (e.g. via an
"exec -- sercon" action in their init.rc, since apps/system/cdcacm
already implements exactly that registration step and does not depend
on nxinit or nsh either).
console_file_actions() runs after the previous commit's time_started
update, so a failure to build the console's file actions is covered by
the same up to date timestamp - no separate clock_gettime() call is
needed on this failure path.
Covered by a new unit test, test_nxinit_service_console_option, that
exercises the option with and without an explicit device, and confirms
services without the option are left untouched.
Assisted-by: Kiro:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init_service_refresh() ignored the return value of init_service_start().
If spawning a restarting service failed for any reason (e.g.
posix_spawnp() itself failing), the service stayed SVC_RESTARTING
forever with nothing left to re-arm its retry timer: this function's
return value drives the poll timeout in the caller's event loop
(main()), and a failed spawn does not fork a child, so there is no
SIGCHLD either to wake it up some other way. If this service happens
to be the only pending timer, the poll blocks indefinitely and the
service is never attempted again.
Check the return value and, on failure, feed the service restart
period into the poll timeout computed by this function, the same way
a successfully started/still-restarting service already does.
Also move the CLOCK_MONOTONIC read that updates a service's
time_started from after a successful spawn to before the spawn is
even attempted, so that time_started stays current on a failed spawn
too - otherwise, once woken up (by the fix above or by an unrelated
event), a repeatedly failing service would look permanently overdue
(elapsed time computed against a stale timestamp) and get retried
immediately regardless of its restart_period.
Assisted-by: Kiro:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
nxstyle flags a missing blank line between the declaration of "s" and
the first statement in option_reboot_on_failure(); pre-existing,
unrelated to any behavioral change here.
Assisted-by: Kiro:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add a CMocka regression test for zero-length checksum fragments.
The test verifies that an empty IOB between fragments does not affect
the checksum calculation or pending odd-byte state.
Assisted by: GitHub Copilot
Signed-off-by: Megha Rajput <i.meghar.2408@gmail.com>
Add a standalone grep application under apps/system/grep/. It uses the
NuttX libc regex library (regcomp/regexec) to support -i, -n, -v, -r,
-H and -h options plus stdin input and recursive directory search.
SYSTEM_GREP depends on LIBC_REGEX, so the regex library must be enabled
first -- CONFIG_SYSTEM_GREP only becomes selectable once LIBC_REGEX is
turned on.
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
Add a small high-level S2OPC server with an anonymous SecurityPolicy None
endpoint and a generated C address space.
Assisted-by: OpenAI Codex:gpt-5
Signed-off-by: raiden00pl <raiden00@railab.me>
MicroMutableOpResolver<8> only registered 8 ops, missing
DEPTHWISE_CONV_2D, required by any depthwise-separable CNN
(MobileNet-style, DS-CNN keyword-spotting models). The kernel
already exists upstream (Register_DEPTHWISE_CONV_2D_INT8() in
tensorflow/lite/micro/kernels/depthwise_conv.h); this wires it
into the resolver and bumps the template size to <9>.
Verified with micro_speech_quantized.tflite on sim:tflm.
Before: Didn't find op for builtin opcode 'DEPTHWISE_CONV_2D'.
After: RESHAPE/DEPTHWISE_CONV_2D/FULLY_CONNECTED/SOFTMAX all execute.
Signed-off-by: Ansh Rai <anshrai331@gmail.com>
This update introduces the following changes in mw:
- Fixed all idetified -Werror warnings in CI.
- Fixed the issue where the backspace key was not working in QEMU
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
This update introduces the following changes in mw:
- Fixed some -Werror warnings in CI.
- Fixed the issue where the backspace key was not working in QEMU
Signed-off-by: Acfboy <AcfboyU@outlook.com>
nuttx-ntfc-testing's release-0.0.1 tag pins ntfc.yaml's citest
requirement to CONFIG_INIT_ENTRYPOINT=nsh_main, so any sim/citest
defconfig that switches to a different init entrypoint (e.g. nxinit's
init_main) fails CI with:
OSError: Missing kconfig dependency: ['CONFIG_INIT_ENTRYPOINT', 'nsh_main']
Maintainer raiden00pl cut nuttx-ntfc-testing release-0.0.2, which drops
that CONFIG_INIT_ENTRYPOINT requirement from ntfc.yaml, and requested
both nuttx and nuttx-apps workflows be updated to it:
https://github.com/apache/nuttx-ntfc-testing/issues/7#issuecomment-5480486089
Only the `git clone -b release-0.0.1` line is changed; the unrelated
`ntfc==0.0.1` PyPI package pin (build.yml) is untouched.
Assisted-by: opencode-agent/claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add SHA2-224 HMAC verification to the crypto hmac test using
CRYPTO_SHA2_224_HMAC through the /dev/crypto interface. Uses
standard HMAC test vectors producing a 28-byte digest.
Signed-off-by: guao <guao@xiaomi.com>
Add test cases for ChaCha20 stream cipher and ChaCha20-Poly1305
AEAD algorithm using the NuttX cryptodev interface. Tests cover
RFC 7539 test vectors including encryption/decryption with various
key/nonce/counter combinations.
Signed-off-by: guao <guao@xiaomi.com>
Add a test/ subdirectory (mirroring apps/system/uorb/test/) with
cmocka-based unit tests covering the NxInit logic most prone to
regression:
- init_parse_arguments(): plain/quoted arguments, "--" separator vs.
"--option" long options (regression coverage for a previously fixed
bug), argv-capacity truncation (asserting the exact folded contents
of the last slot, not just its presence).
- init_parse_config_file()/init_parse_config_lines()/
init_parse_config_buffer(): section routing, blank/whitespace-only
line skipping, unknown-section rejection, over-length line rejection,
and a line straddling two read-buffer refills, exercised through both
the file-based and buffer-based entry points.
- Action event matching: exact match, invert (!=), fnmatch wildcards,
and AND semantics across multiple events per action.
- Service conflict detection: duplicate service name rejection,
override replacing an earlier duplicate, and the SERVICE_ARGS_MAX
boundary built dynamically from CONFIG_SYSTEM_NXINIT_SERVICE_ARGS_MAX
rather than a hardcoded value.
Test sources compile action.c/parser.c/service.c a second time into a
separate nxinit_unit_test program, gated behind new
CONFIG_SYSTEM_NXINIT_TEST (depends on TESTING_CMOCKA); the default init
program is unaffected. The CMake path builds a dedicated
nxinit_unit_test target (with test/test_nxinit.c placed first in SRCS
so nuttx_add_application() renames its main() correctly); the Make path
appends the test sources into the shared CSRCS list.
Supporting bits required to make the suite exercise the real code:
- init_parse_config_buffer() is declared in parser.h and made
non-static so the buffer-based boundary test can call it directly,
alongside the existing init_parse_config_file() entry point.
- CONFIG_SYSTEM_NXINIT_ACTION_EVENTS_MAX default is raised from 1 to 2
so an action can carry more than one event ("on evA && evB"), which
the multi-event AND-semantics test exercises; a single event slot
made that test dead code.
- CONFIG_SYSTEM_NXINIT_TEST_STACKSIZE defaults to 8192: several parser
test cases build multi-hundred-byte stack buffers on top of cmocka's
own overhead, and the previous DEFAULT_TASK_STACKSIZE (2048)
overflowed the test task's stack silently on real hardware (no crash
dump, no watchdog reset, output just stopped) partway through the
suite.
Testing:
Built via `make CROSSDEV=riscv-none-elf-` for
esp32p4-pico-wifi-wareshare:nsh (CONFIG_SYSTEM_NXINIT_TEST=y) and ran
nxinit_unit_test on real esp32p4-pico-wifi-wareshare hardware over
UART:
nsh> nxinit_unit_test
[==========] nxinit_tests: Running 18 test(s).
...
[==========] nxinit_tests: 18 test(s) run.
[ PASSED ] 18 test(s).
nxstyle clean on all touched files.
Assisted-by: GitHubCopilot:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init_parse_config_buffer() computed the per-refill copy length as
MIN(len - off, sizeof(tmp)) without subtracting the 'n' leftover bytes
already held at the front of 'tmp' from a previous refill, so
memcpy(&tmp[n], ..., r) could write past the end of tmp[]. The
file-based twin, init_parse_config_file(), already gets this right
(read(fd, &buf[n], sizeof(buf) - n)).
Reproduced locally with an AddressSanitizer host harness feeding the
real 95-byte builtin "preset" rc content through
init_parse_config_buffer() at CONFIG_SYSTEM_NXINIT_RC_LINE_MAX=32/48:
ASan reports a stack-buffer-overflow on the 'tmp' array. Fixed to
MIN(len - off, sizeof(tmp) - n) and reverified clean at
RC_LINE_MAX=32/48/64/128.
The default config never hits this (the builtin preset is 95 bytes and
the default RC_LINE_MAX is 128), but SYSTEM_NXINIT_RC_LINE_MAX had no
lower bound, so lowering it towards 32/48 for a smaller build would
silently corrupt the stack while parsing the preset during boot. Add a
"range 64 4096" bound so the value can no longer be set below the
builtin preset's needs.
Assisted-by: opencode:mimo-v2.5-pro
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init_parse_config_file() declares 'r' inside the read loop with no
blank line before the following 'if (r < 0)' statement, violating the
NuttX coding standard (nxstyle: "Missing blank line after
declarations"). checkpatch.sh runs a whole-file nxstyle check on any
file a commit touches, not diff-only, so this pre-existing issue
surfaced on this PR's CI once parser.c was touched again.
Assisted-by: GitHubCopilot:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
init_parse_config_lines() had a dead early "continue" for a truly
empty line (buf == "\0") that skipped the memmove() bookkeeping its
sibling whitespace-only-line branch performs. When a real empty line
appeared mid-buffer, subsequent bytes were never shifted to the front
of the working buffer, corrupting the remaining-length tracking and
silently dropping every line after it for that refill chunk.
The whitespace-skip loop right below already handles the empty-string
case correctly (the loop body never executes, so it falls straight
into the "only whitespace" -> memmove -> continue path), so the buggy
early exit is simply redundant and removed.
Assisted-by: GitHubCopilot:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Previously, 'set KEY VALUE' in init.rc was not recognized as a builtin
command. It fell through to posix_spawnp(), which ran it in a
temporary child shell. The environment variable was set only in the
child process and lost when it exited, so services started afterward
never inherited it.
Register cmd_set as an init builtin that calls setenv(key, value, 1)
directly in the init process. The command takes exactly 2 arguments
(key and value). All code is guarded by CONFIG_DISABLE_ENVIRON so it
compiles out when environment support is disabled.
Since child processes inherit init's environment, 'set TZ Asia/Shanghai'
in init.rc now correctly propagates to all subsequently started
services.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The previous default of 8 is insufficient for services with many
arguments (e.g. ptpd needs 10 argv slots). When exceeded, argv lacks
a NULL terminator, causing posix_spawnp to read out of bounds.
Increase default to 16 to prevent argument truncation for typical
daemon services.
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Because this PR modifies nsh_fscmds.c and wamr/Kconfig, CI runs
nxstyle and codespell over the whole files and rejects pre-existing
issues that are unrelated to the rename:
- nsh_fscmds.c: reindent misaligned switch/case blocks in cmd_dmesg,
cmd_losetup, cmd_losmart, cmd_lomtd, cmd_mkdir, cmd_mkfatfs and
cmd_mkrd to the standard NuttX layout.
- wamr/Kconfig: fix two spelling typos flagged by codespell
("expections" -> "exceptions", "Configuable" -> "Configurable").
Style/whitespace and spelling only; no functional change.
Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
The link support is no longer limited to the pseudo file system and now
covers both soft (symbolic) links and hard links across the VFS. Update
all references to the renamed configuration option PSEUDOFS_SOFTLINKS,
which has been renamed to FS_LINKS in the NuttX kernel, so that nshlib,
the interpreters, adb, tlpi and the test suites keep building.
This must be merged together with the corresponding NuttX change that
performs the actual kernel-side rename.
Signed-off-by: zhengyu16 <zhengyu16@xiaomi.com>
The uLUt and libshvc declare headers intended for make export
by EXPORTED_INCLUDES mechanism implemented during 2026
Micowindows GSoC. The shv-libs4c has been updated as well
to support newer pyshv versions and that way firmware updates
when shv-nxboot-updater is used through pyshv based shvflasher.py
and related GUI.
For pyshv see https://github.com/silicon-heaven/pyshv
New commits from shv-libs4c project
https://github.com/silicon-heaven/shv-libs4c
- shv_com_common: shv_unpack_discard and shv_unpack_skip
required to skip additional parameters and query requests
introduced introduced by newer silicon-heaven protocol
and pyshv. Incorrect skipping was a bug even against
previous protocol version but did not present itself because
older pyshv did not send additional requests which need
to be ignored.
- shv_file_node: small, but crucial unpack change
Ignore any other messages than PARAM in file node's write unpack
function. Other different states should be handled, too.
- shv_file_node: fix the CRC unpack method too
Any other messages than PARAM are ignored.
- shv_com: add a method to close a connection only
- shv_dotdevice_node.c: close the conn with the other side when resetted
- shv_com.h: use array designators for error strings
- libshvtree: move shv_con_errno_strs to the C file to not waste space
by copies
- shvtree/shv_clayer_posix: provide alternative socketpair notification
support
This allows to use shv-libs4c and related pysimCoder support
on RTEMS system which does not provide functional pipe
directive/system call but BSD networking supported local/UNIX
socket pair is fully supported.
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
codespell flagged this in PR #3751 CI:
system/nxinit/init.c:119: unkown ==> unknown
system/nxinit/init.c:130: unkown ==> unknown
Both entries were introduced by the resetcause-for-triggers commit and
are unrelated to the earlier nxstyle regression already discussed on
the PR.
Assisted-by: GitHubCopilot:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add the missing mapping entries in the resetflag[] array to prevent
potential NULL pointer dereference when accessing reset.flag.
The resetflag array uses designated initializers and must have entries
for all BOARDIOC_SOFTRESETCAUSE_* values to avoid array holes.
Reported by: xuchuntian@xiaomi.com
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Add built-in property sys.boot.reason, which allows action triggers to be
executed on specific reset cause.
For example:
```
on property:sys.boot.reason=cpu_soft_reset(bootloader)
echo "bootloader mode ..."
start fastboot
```
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Changes PSEUDOTERM dependency from 'select' to 'depends on' which was
missing from the initial pull request.
Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>