Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) .. _serial_console:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) Linux Serial Console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) To use a serial port as console you need to compile the support into your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) kernel - by default it is not compiled in. For PC style serial ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) it's the config option next to menu option:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) :menuselection:`Character devices --> Serial drivers --> 8250/16550 and compatible serial support --> Console on 8250/16550 and compatible serial port`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) You must compile serial support into the kernel and not as a module.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) It is possible to specify multiple devices for console output. You can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) define a new kernel command line option to select which device(s) to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) use for console output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) The format of this option is::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	console=device,options
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	device:		tty0 for the foreground virtual console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 			ttyX for any other virtual console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 			ttySx for a serial port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 			lp0 for the first parallel port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 			ttyUSB0 for the first USB serial device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	options:	depend on the driver. For the serial port this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			defines the baudrate/parity/bits/flow control of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 			the port, in the format BBBBPNF, where BBBB is the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 			speed, P is parity (n/o/e), N is number of bits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			and F is flow control ('r' for RTS). Default is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 			9600n8. The maximum baudrate is 115200.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) You can specify multiple console= options on the kernel command line.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) Output will appear on all of them. The last device will be used when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) you open ``/dev/console``. So, for example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	console=ttyS1,9600 console=tty0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) defines that opening ``/dev/console`` will get you the current foreground
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) virtual console, and kernel messages will appear on both the VGA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) console and the 2nd serial port (ttyS1 or COM2) at 9600 baud.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) Note that you can only define one console per device type (serial, video).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) If no console device is specified, the first device found capable of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) acting as a system console will be used. At this time, the system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) first looks for a VGA card and then for a serial port. So if you don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) have a VGA card in your system the first serial port will automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) become the console.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) You will need to create a new device to use ``/dev/console``. The official
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) ``/dev/console`` is now character device 5,1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) (You can also use a network device as a console.  See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) ``Documentation/networking/netconsole.rst`` for information on that.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) Here's an example that will use ``/dev/ttyS1`` (COM2) as the console.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) Replace the sample values as needed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 1. Create ``/dev/console`` (real console) and ``/dev/tty0`` (master virtual
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)    console)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)      cd /dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)      rm -f console tty0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)      mknod -m 622 console c 5 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)      mknod -m 622 tty0 c 4 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 2. LILO can also take input from a serial device. This is a very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)    useful option. To tell LILO to use the serial port:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)    In lilo.conf (global section)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)      serial  = 1,9600n8 (ttyS1, 9600 bd, no parity, 8 bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 3. Adjust to kernel flags for the new kernel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77)    again in lilo.conf (kernel section)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)      append = "console=ttyS1,9600"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 4. Make sure a getty runs on the serial port so that you can login to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)    it once the system is done booting. This is done by adding a line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)    like this to ``/etc/inittab`` (exact syntax depends on your getty)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)      S1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 5. Init and ``/etc/ioctl.save``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)    Sysvinit remembers its stty settings in a file in ``/etc``, called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)    ``/etc/ioctl.save``. REMOVE THIS FILE before using the serial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)    console for the first time, because otherwise init will probably
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)    set the baudrate to 38400 (baudrate of the virtual console).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 6. ``/dev/console`` and X
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)    Programs that want to do something with the virtual console usually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)    open ``/dev/console``. If you have created the new ``/dev/console`` device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)    and your console is NOT the virtual console some programs will fail.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)    Those are programs that want to access the VT interface, and use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)    ``/dev/console instead of /dev/tty0``. Some of those programs are::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)      Xfree86, svgalib, gpm, SVGATextMode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)    It should be fixed in modern versions of these programs though.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)    Note that if you boot without a ``console=`` option (or with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)    ``console=/dev/tty0``), ``/dev/console`` is the same as ``/dev/tty0``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)    In that case everything will still work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 7. Thanks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)    Thanks to Geert Uytterhoeven <geert@linux-m68k.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)    for porting the patches from 2.1.4x to 2.1.6x for taking care of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)    the integration of these patches into m68k, ppc and alpha.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) Miquel van Smoorenburg <miquels@cistron.nl>, 11-Jun-2000