This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b4aa94d8440 Documentation/applications/system/nxinit: document the 
"console" option
b4aa94d8440 is described below

commit b4aa94d844058c5f39ffaee38fc3e0aaa6c0a99e
Author: wangjianyu3 <[email protected]>
AuthorDate: Wed Sep 9 18:47:53 2026 +0800

    Documentation/applications/system/nxinit: document the "console" option
    
    Document the per-service "console [<device>]" option added to nxinit
    by the companion apache/nuttx-apps PR: what it does (open the given
    device, or CONFIG_SYSTEM_NXINIT_CONSOLE_DEV if omitted, and dup it onto
    the service's stdin/stdout/stderr before spawning), why a plain shell
    service needs it (unlike nsh, it never opens a console device on its
    own), and why a USB gadget console additionally needs the gadget
    brought up first (e.g. via "exec -- sercon"), since the device does not
    exist until then.
    
    Assisted-by: Kiro:claude-sonnet-5
    Signed-off-by: wangjianyu3 <[email protected]>
---
 Documentation/applications/system/nxinit/index.rst | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/Documentation/applications/system/nxinit/index.rst 
b/Documentation/applications/system/nxinit/index.rst
index 4f59b4ceeb6..16f030bf586 100644
--- a/Documentation/applications/system/nxinit/index.rst
+++ b/Documentation/applications/system/nxinit/index.rst
@@ -52,10 +52,46 @@ File path configured by 
``CONFIG_SYSTEM_NXINIT_RC_FILE_PATH``.
   via the override option).
 - Options are modifiers for services, affecting their running mode and timing.
   Examples include class (specify service category for batch start/stop),
+  console (redirect the service's stdio to a console device; see below),
   override (override previously defined services), restart_period (interval
   for restarting exited services), and reboot_on_failure (critical services
   trigger device reboot on startup failure or abnormal exit).
 
+The ``console`` Option
+-----------------------
+
+.. code-block::
+
+    service <name> <pathname> [ <argument> ]*
+       console [ <device> ]
+
+A service does not open a console device on its own - it simply inherits
+whatever stdin/stdout/stderr NXInit itself has, which for many boards is
+never set up at all (there is no ``/dev/console`` unless
+``CONFIG_DEV_CONSOLE`` is enabled). ``console`` fixes this by opening
+``<device>`` (``CONFIG_SYSTEM_NXINIT_CONSOLE_DEV``, ``/dev/console`` by
+default, if omitted) and duplicating it onto the service's stdin, stdout
+and stderr before it is spawned.
+
+This is required for a plain shell service (e.g. ``service console sh``)
+to actually be usable as an interactive console. It is not needed for
+``nsh`` (the full NSH application, as opposed to plain ``sh``), which
+already does the equivalent internally via ``nsh_consolemain()``.
+
+For a USB gadget console (``CONFIG_CDCACM_CONSOLE``/``CONFIG_PL2303_CONSOLE``),
+the device does not exist until the gadget is actually registered with the
+USB stack - unlike a plain UART, this does not happen implicitly during
+early boot. The gadget must be brought up once, before any service using
+``console`` is started, e.g. via ``apps/system/cdcacm``'s ``sercon``:
+
+.. code-block::
+
+    on init
+        exec -- sercon
+
+    service console sh
+        console
+
 Triggers
 ========
 

Reply via email to