blob: a8d1e36b627a11a38fcb6ecf96177ee89efac13e [file] [log] [blame]
Mauro Carvalho Chehab8e7fbec2016-09-21 14:44:59 -03001.. _serial_console:
2
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -03003Linux Serial Console
4====================
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
6To use a serial port as console you need to compile the support into your
7kernel - by default it is not compiled in. For PC style serial ports
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -03008it's the config option next to menu option:
9
10:menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port`
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012You must compile serial support into the kernel and not as a module.
13
14It is possible to specify multiple devices for console output. You can
15define a new kernel command line option to select which device(s) to
16use for console output.
17
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030018The format of this option is::
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20 console=device,options
21
22 device: tty0 for the foreground virtual console
23 ttyX for any other virtual console
24 ttySx for a serial port
25 lp0 for the first parallel port
Randy Dunlapf1a1c2d2006-03-25 03:08:17 -080026 ttyUSB0 for the first USB serial device
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28 options: depend on the driver. For the serial port this
Randy Dunlapf1a1c2d2006-03-25 03:08:17 -080029 defines the baudrate/parity/bits/flow control of
30 the port, in the format BBBBPNF, where BBBB is the
31 speed, P is parity (n/o/e), N is number of bits,
32 and F is flow control ('r' for RTS). Default is
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 9600n8. The maximum baudrate is 115200.
34
35You can specify multiple console= options on the kernel command line.
36Output will appear on all of them. The last device will be used when
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030037you open ``/dev/console``. So, for example::
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 console=ttyS1,9600 console=tty0
40
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030041defines that opening ``/dev/console`` will get you the current foreground
Linus Torvalds1da177e2005-04-16 15:20:36 -070042virtual console, and kernel messages will appear on both the VGA
43console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
44
45Note that you can only define one console per device type (serial, video).
46
47If no console device is specified, the first device found capable of
48acting as a system console will be used. At this time, the system
49first looks for a VGA card and then for a serial port. So if you don't
50have a VGA card in your system the first serial port will automatically
51become the console.
52
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030053You will need to create a new device to use ``/dev/console``. The official
54``/dev/console`` is now character device 5,1.
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Randy Dunlapf1a1c2d2006-03-25 03:08:17 -080056(You can also use a network device as a console. See
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030057``Documentation/networking/netconsole.txt`` for information on that.)
Randy Dunlapf1a1c2d2006-03-25 03:08:17 -080058
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030059Here's an example that will use ``/dev/ttyS1`` (COM2) as the console.
Linus Torvalds1da177e2005-04-16 15:20:36 -070060Replace the sample values as needed.
61
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -0300621. Create ``/dev/console`` (real console) and ``/dev/tty0`` (master virtual
63 console)::
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030065 cd /dev
66 rm -f console tty0
67 mknod -m 622 console c 5 1
68 mknod -m 622 tty0 c 4 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
702. LILO can also take input from a serial device. This is a very
71 useful option. To tell LILO to use the serial port:
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030072 In lilo.conf (global section)::
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030074 serial = 1,9600n8 (ttyS1, 9600 bd, no parity, 8 bits)
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
763. Adjust to kernel flags for the new kernel,
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030077 again in lilo.conf (kernel section)::
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030079 append = "console=ttyS1,9600"
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
814. Make sure a getty runs on the serial port so that you can login to
82 it once the system is done booting. This is done by adding a line
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030083 like this to ``/etc/inittab`` (exact syntax depends on your getty)::
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030085 S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -0300875. Init and ``/etc/ioctl.save``
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030089 Sysvinit remembers its stty settings in a file in ``/etc``, called
90 ``/etc/ioctl.save``. REMOVE THIS FILE before using the serial
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 console for the first time, because otherwise init will probably
92 set the baudrate to 38400 (baudrate of the virtual console).
93
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -0300946. ``/dev/console`` and X
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 Programs that want to do something with the virtual console usually
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030096 open ``/dev/console``. If you have created the new ``/dev/console`` device,
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 and your console is NOT the virtual console some programs will fail.
98 Those are programs that want to access the VT interface, and use
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -030099 ``/dev/console instead of /dev/tty0``. Some of those programs are::
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -0300101 Xfree86, svgalib, gpm, SVGATextMode
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103 It should be fixed in modern versions of these programs though.
104
Mauro Carvalho Chehabc2ffd5d2016-09-21 14:08:10 -0300105 Note that if you boot without a ``console=`` option (or with
106 ``console=/dev/tty0``), ``/dev/console`` is the same as ``/dev/tty0``.
107 In that case everything will still work.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
1097. Thanks
110
111 Thanks to Geert Uytterhoeven <geert@linux-m68k.org>
112 for porting the patches from 2.1.4x to 2.1.6x for taking care of
113 the integration of these patches into m68k, ppc and alpha.
114
115Miquel van Smoorenburg <miquels@cistron.nl>, 11-Jun-2000