JianyuWang0623 opened a new pull request, #20119:
URL: https://github.com/apache/nuttx/pull/20119
## Summary
Switch every `rv-virt` (qemu-rv) flat-build defconfig whose init entry point
was
`nsh_main` to nxinit (`init_main`): citest, citest64, fb, fb64, flats,
flats64,
leds, leds64, leds64_rust, leds64_zig, libcxx, libcxx64, lvgl64_vector,
netnsh,
netnsh64, netnsh64_smp, netnsh_smp, nsh, nsh64, python, smp, smp64, virt_nsh,
plus pnsh/pnsh64 (`CONFIG_BUILD_PROTECTED=y`) — 25 configs total. `nsh` now
runs
as a "console sh" service started by `init.rc` instead of being the top-level
init task, matching the pattern already used by `boards/arm/qemu-armv7a`,
`boards/arm64/qemu-armv8a` and `boards/sim`.
`elf` (entrypoint `elf_main`) and the 11 kernel-build configs
(`CONFIG_INIT_FILEPATH="/system/bin/init"`) are out of scope and untouched.
Each switched defconfig only gains the nxinit-essential keys (minimal delta,
regenerated with `make savedefconfig`): `CONFIG_INIT_ENTRYPOINT="init_main"`,
`CONFIG_SYSTEM_NXINIT=y` (+ its deps `EXPERIMENTAL`, `LIBC_EXECFUNCS`,
`SCHED_CHILD_STATUS`), `CONFIG_ETC_ROMFS=y`/`CONFIG_FS_ROMFS=y` to ship
`init.rc`. Board changes: new `src/etc/init.d/init.rc`,
`Makefile`/`CMakeLists.txt`
to ship it via ROMFS, and a `CONFIG_FS_BINFS`-gated `mount(NULL, "/bin",
"binfs", ...)`
in `qemu_rv_boardinit.c` so `posix_spawnp("sh")` can resolve the builtin.
smp/smp64 additionally re-enable binfmt (they had `CONFIG_DEFAULT_SMALL=y`
pulling
in `CONFIG_BINFMT_DISABLE=y`, which would block
`LIBC_EXECFUNCS`→`SYSTEM_NXINIT`).
pnsh/pnsh64 rely on the boardctl(BOARDIOC_BUILTINS) hand-off; see the second
commit.
## Impact
- Behavior: on the affected rv-virt configs the interactive shell is now a
service child of `init_main` rather than the init task itself.
- Build: board-only defconfig/Make/CMake changes; no core changes.
- pnsh/pnsh64 depend on the apps-side `boardctl(BOARDIOC_BUILTINS)`
registration
(nuttx-apps `system/nxinit`) to populate the kernel builtin table under
PROTECTED build — see the `Depends-on:` trailer on the second commit.
## Known dependency for one runtime symptom
During full-runtime testing, the switched `rv-virt:smp`/`smp64` show an
**intermittent zero-output boot hang** on QEMU 8.2.2. This was root-caused
to a
pre-existing use-after-scope of the `_inode_search()` path buffer under
`CONFIG_LIBC_TEMPBUFFER=n` (`DEFAULT_SMALL` default): the buffer escapes its
`alloca` frame and occasionally corrupts a freshly-registered inode name
such as
`/dev/console`, which then breaks console setup. It is **not caused by this
defconfig switch** — it reproduces on the pre-switch `nsh_main` configs and
is
core-count-independent — but nxinit's extra task spawn raises its hit rate.
That underlying bug is fixed separately by **apache/nuttx#20118**
(`fs: fix use-after-scope of alloca path buffers
(CONFIG_LIBC_TEMPBUFFER=n)`).
With #20118 applied, the switched rv-virt:smp boots reliably
(smp8 60/60, smp4 20/20, smp1 20/20) vs. ~27.5%/10% zero-byte hangs without
it.
**This PR is kept as a draft pending #20118** so the two land in a sensible
order.
## Testing
- Toolchain: xPack `riscv-none-elf-gcc` 14.2.0; QEMU 8.2.2.
- Built and booted the switched configs; `ps` shows `init_main` as the
parent and
`sh` as its running child. pnsh (PROTECTED) additionally verified `ls /bin`
lists the builtins and `hello` runs (confirms the boardctl hand-off).
- The smp intermittent-hang analysis and the fix verification are captured
in the
dependency note above (#20118).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]