Documentation/admin-guide/serial-console.rst
Source file repositories/reference/linux-study-clean/Documentation/admin-guide/serial-console.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/admin-guide/serial-console.rst- Extension
.rst- Size
- 5749 bytes
- Lines
- 148
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. _serial_console:
Linux Serial Console
====================
To use a serial port as console you need to compile the support into your
kernel - by default it is not compiled in. For PC style serial ports
it's the config option next to menu option:
:menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port`
You must compile serial support into the kernel and not as a module.
It is possible to specify multiple devices for console output. You can
define a new kernel command line option to select which device(s) to
use for console output.
The format of this option is::
console=device,options
device: tty0 for the foreground virtual console
ttyX for any other virtual console
ttySx for a serial port
lp0 for the first parallel port
ttyUSB0 for the first USB serial device
options: depend on the driver. For the serial port this
defines the baudrate/parity/bits/flow control of
the port, in the format BBBBPNF, where BBBB is the
speed, P is parity (n/o/e), N is number of bits,
and F is flow control ('r' for RTS). Default is
9600n8. The maximum baudrate is 115200.
You can specify multiple console= options on the kernel command line.
The behavior is well defined when each device type is mentioned only once.
In this case, the output will appear on all requested consoles. And
the last device will be used when you open ``/dev/console``.
So, for example::
console=ttyS1,9600 console=tty0
defines that opening ``/dev/console`` will get you the current foreground
virtual console, and kernel messages will appear on both the VGA
console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
The behavior is more complicated when the same device type is defined more
times. In this case, there are the following two rules:
1. The output will appear only on the first device of each defined type.
2. ``/dev/console`` will be associated with the first registered device.
Where the registration order depends on how kernel initializes various
subsystems.
This rule is used also when the last console= parameter is not used
for other reasons. For example, because of a typo or because
the hardware is not available.
The result might be surprising. For example, the following two command
lines have the same result::
console=ttyS1,9600 console=tty0 console=tty1
console=tty0 console=ttyS1,9600 console=tty1
The kernel messages are printed only on ``tty0`` and ``ttyS1``. And
``/dev/console`` gets associated with ``tty0``. It is because kernel
tries to register graphical consoles before serial ones. It does it
because of the default behavior when no console device is specified,
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.