Skip to content

system/nxinit: add CONFIG_SYSTEM_NXINIT_STDOUT for printf-based log output - #3765

Open
JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:nxinit-stdout-log-output
Open

system/nxinit: add CONFIG_SYSTEM_NXINIT_STDOUT for printf-based log output#3765
JianyuWang0623 wants to merge 1 commit into
apache:masterfrom
JianyuWang0623:nxinit-stdout-log-output

Conversation

@JianyuWang0623

Copy link
Copy Markdown
Contributor

Summary

system/nxinit currently logs everything through syslog(). On
products where syslog is routed through a userspace service (e.g.
DFX), that channel may not be usable yet during early boot, or may
not be visible at all if the service itself is what's failing (e.g.
a service start failure, or an exception inside the DFX consumer).
When that happens, init_debug/info/warn/err output is silently
lost and there is no way to see why init failed to bring up a
service.

Add a debug-only Kconfig option SYSTEM_NXINIT_STDOUT that redirects
all four log macros to printf() (with an appended newline) instead
of syslog(), selected at compile time via a new init_log_output()
macro. Default is n (unchanged syslog behavior).

Impact

  • Only touches system/nxinit/{Kconfig,init.h}. No behavior change
    when SYSTEM_NXINIT_STDOUT is left at its default (n).
  • No new dependencies; stdio.h is already transitively available.

Testing

Built with the sim:nsh target (host gcc, nxinit-qemu-sim-all-nsh-defconfigs
branch of nuttx which enables CONFIG_SYSTEM_NXINIT). nxstyle
clean on both touched files.

Verified the actual failure mode this fixes: pointed
CONFIG_SYSTEM_NXINIT_RC_FILE_PATH at a nonexistent file so init
hits its own init_err() path on boot, and disabled
CONFIG_SYSLOG_DEFAULT so syslog() has no console channel at all
(simulating "syslog not available/not visible"):

# CONFIG_SYSTEM_NXINIT_STDOUT is not set, CONFIG_SYSLOG_DEFAULT is not set
$ ./nuttx
nsh>                     # no init_err output at all - the bug this fixes

# CONFIG_SYSTEM_NXINIT_STDOUT=y, CONFIG_SYSLOG_DEFAULT still not set
$ ./nuttx
Error Opening /etc/init.d/init.rc.MISSING 2
nsh>                     # init_err output now visible via printf

With CONFIG_SYSTEM_NXINIT_STDOUT left unset (default), behavior is
unchanged from before this patch (verified boot log is identical to
apache/master).

…utput

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>
@JianyuWang0623
JianyuWang0623 force-pushed the nxinit-stdout-log-output branch from 6ec234a to 4f7c896 Compare September 2, 2026 07:49
@JianyuWang0623
JianyuWang0623 marked this pull request as ready for review September 2, 2026 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant