old-www/HOWTO/Remote-Serial-Console-HOWTO/preparation-setspeed.html

993 lines
17 KiB
HTML

<HTML
><HEAD
><TITLE
>Select a serial speed and parameters</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Remote Serial Console HOWTO"
HREF="index.html"><LINK
REL="UP"
TITLE="Preparation"
HREF="preparation.html"><LINK
REL="PREVIOUS"
TITLE="Select a serial port "
HREF="preparation-setport.html"><LINK
REL="NEXT"
TITLE="Configure the modem or the null-modem cable"
HREF="preparation-modem.html"></HEAD
><BODY
CLASS="SECTION"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Remote Serial Console HOWTO</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="preparation-setport.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 2. Preparation</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="preparation-modem.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECTION"
><H1
CLASS="SECTION"
><A
NAME="PREPARATION-SETSPEED"
></A
>2.3. Select a serial speed and parameters</H1
><P
>This <I
CLASS="CITETITLE"
>HOWTO</I
> does not discuss the
<SPAN
CLASS="ACRONYM"
>RS-232</SPAN
> standard, which is formally known as
<I
CLASS="CITETITLE"
><SPAN
CLASS="ACRONYM"
>ANSI/TIA/EIA-232-F-1997</SPAN
> Interface
Between Data Terminal Equipment and Data Circuit-Terminating
Equipment Employing Serial Data Interchange</I
>. For an
explanation of <SPAN
CLASS="QUOTE"
>"bits per second"</SPAN
>, <SPAN
CLASS="QUOTE"
>"start
bits"</SPAN
>, <SPAN
CLASS="QUOTE"
>"data bits"</SPAN
>, <SPAN
CLASS="QUOTE"
>"parity"</SPAN
>,
<SPAN
CLASS="QUOTE"
>"stop bits"</SPAN
> and <SPAN
CLASS="QUOTE"
>"flow control"</SPAN
> refer to the
<A
HREF="http://www.tldp.org/HOWTO/Serial-HOWTO.html"
TARGET="_top"
><I
CLASS="CITETITLE"
>Serial-HOWTO</I
></A
>
and the <A
HREF="http://www.tldp.org/HOWTO/Modem-HOWTO.html"
TARGET="_top"
><I
CLASS="CITETITLE"
>Modem-HOWTO</I
></A
>.</P
><P
>The description of the command syntax for setting the serial
parameters in the kernel, boot loaders and login applications uses
the following variables which describe <SPAN
CLASS="ACRONYM"
>RS-232</SPAN
>
parameters.</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="REPLACEABLE"
><I
>&#60;speed&#62;</I
></TT
></DT
><DD
><P
>The speed of the serial link in bits per second.</P
><P
>The <SPAN
CLASS="SYSTEMITEM"
>Linux</SPAN
> kernel
on a modern <SPAN
CLASS="ACRONYM"
>PC</SPAN
> supports a serial console
speeds of 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200
bits per second.</P
><P
>The kernel supports a much wider range of serial bit rates
when the serial interface is not being used as a serial
console.<A
NAME="AEN472"
HREF="#FTN.AEN472"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></P
><P
>Very recent <SPAN
CLASS="SYSTEMITEM"
>Linux</SPAN
>
kernels can also offer a serial console using a
<SPAN
CLASS="ACRONYM"
>USB</SPAN
> serial dongle at speeds of 1200, 2400,
4800, 9600, 19200, 38400, 57600 and 115200 bits per
second.</P
><P
>Most boot loaders only support a different range of speeds
than are supported by the kernel.
<SPAN
CLASS="PRODUCTNAME"
>LILO</SPAN
>
<SPAN
CLASS="PRODUCTNUMBER"
>21.7.5</SPAN
> supports 110, 150, 300,
600, 1200, 2400, 4800, 9600, 19200, 38400, 56000, 57600 and
115200 bits per second. <SPAN
CLASS="PRODUCTNAME"
>SYSLINUX</SPAN
>
<SPAN
CLASS="PRODUCTNUMBER"
>1.67</SPAN
> supports 75 to 56000 bits
per second. <SPAN
CLASS="PRODUCTNAME"
>GRUB</SPAN
>
<SPAN
CLASS="PRODUCTNUMBER"
>0.90</SPAN
> supports 2400, 4800, 9600,
19200, 38400, 57600 and 115200 bits per second.</P
><P
>You must chose the same speed for both the boot loader and
for the <SPAN
CLASS="SYSTEMITEM"
>Linux</SPAN
> kernel.
An operating system may use more than one boot loader. For
example, <SPAN
CLASS="PRODUCTNAME"
>Red Hat Linux</SPAN
> uses
<SPAN
CLASS="PRODUCTNAME"
>SYSLINUX</SPAN
> to install or upgrade the
operating system; <SPAN
CLASS="PRODUCTNAME"
>LILO</SPAN
> as the boot
loader for <SPAN
CLASS="PRODUCTNAME"
>Red Hat Linux</SPAN
>
<SPAN
CLASS="PRODUCTNUMBER"
>7.1</SPAN
> and earlier; and
<SPAN
CLASS="PRODUCTNAME"
>GRUB</SPAN
> as the boot loader for
<SPAN
CLASS="PRODUCTNAME"
>Red Hat Linux</SPAN
>
<SPAN
CLASS="PRODUCTNUMBER"
>7.2</SPAN
> and later.</P
><P
>If you are using a serial terminal or if you are using a
dumb modem then the bit rate of the terminal or dumb modem must
also match the bit rate selected in the boot loader and
kernel.</P
><P
>If the serial console is connected to a Hayes-style modem
slower than 9600<SPAN
CLASS="ABBREV"
>bps</SPAN
> then configure the serial
console with the same speed as the modem. Modems faster than
9600<SPAN
CLASS="ABBREV"
>bps</SPAN
> will generally automatically
synchronize to the speed of the serial port.</P
><P
>The selected bit rate must also be supported by the serial
port's <SPAN
CLASS="ACRONYM"
>UART</SPAN
> semiconductor chip. Early
<SPAN
CLASS="ACRONYM"
>UART</SPAN
>s without on-chip receive buffers could
only reliably receive at up to 14400<SPAN
CLASS="ABBREV"
>bps</SPAN
>, this
includes models 8250A, 82510, 16450 and 16550 (with no
<I
CLASS="WORDASWORD"
>A</I
>). Recent <SPAN
CLASS="ACRONYM"
>UART</SPAN
>s with
receive buffers will work at all serial console bit rates, this
includes models 16550A, 16552, 16650, 16654, 16750, 16850 and
16950.</P
><P
>Unless you have good reason, use the popular bit rate of
9600 bits per second. This is the default bit rate of a great
many devices.</P
><P
>The speeds that are supported by the kernel, the three
common boot loaders, and all <SPAN
CLASS="PRODUCTNAME"
><SPAN
CLASS="ACRONYM"
>IBM</SPAN
>
<SPAN
CLASS="ACRONYM"
>PC</SPAN
>s</SPAN
> capable of running
<SPAN
CLASS="SYSTEMITEM"
>Linux</SPAN
> are: 2400, 4800,
9600 and 19200 bits per second. This is a depressingly small
selection: not slow enough to support a call over an
international phone circuit and not fast enough to upload large
files. You may need to choose a speed that will result in a
less robust software configuration.</P
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-BPS"
></A
><P
><B
>Figure 2-2. Syntax for serial bits per second rate, in extended
Backus-Naur form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;speed&#62;</I
></TT
>&nbsp;::=&nbsp;&nbsp;<TT
CLASS="REPLACEABLE"
><I
>&#60;digits&#62;</I
></TT
><br>
<TT
CLASS="REPLACEABLE"
><I
>&#60;digits&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="REPLACEABLE"
><I
>&#60;digit&#62;</I
></TT
>&nbsp;|&nbsp;<TT
CLASS="REPLACEABLE"
><I
>&#60;digit&#62;</I
></TT
><TT
CLASS="REPLACEABLE"
><I
>&#60;digits&#62;</I
></TT
><br>
<TT
CLASS="REPLACEABLE"
><I
>&#60;digit&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="LITERAL"
>0</TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>1</TT
>&nbsp;|&nbsp;&#8230;&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>9</TT
></P
></DIV
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>&#60;parity&#62;</I
></TT
></DT
><DD
><P
>Number of parity bits and the interpretation of a parity
bit if one is present.</P
><P
>Allowed values are <TT
CLASS="LITERAL"
>n</TT
> for no parity bit,
<TT
CLASS="LITERAL"
>e</TT
> for one bit of even parity and
<TT
CLASS="LITERAL"
>o</TT
> for one bit of odd parity.</P
><P
>Using no parity bit and eight data bits is
recommended.</P
><P
>If parity is used then even parity is the common
choice.</P
><P
>Parity is a simple form of error detection. Modern modems
have much better error detection and correction. As a result
the parity bit guards only the data on the cable between the
modem and the serial port. If this cable has a low error rate,
and it should, then the parity bit is not required.</P
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-PARITY"
></A
><P
><B
>Figure 2-3. Syntax for serial parity, in extended Backus-Naur
form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;parity&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="LITERAL"
>n</TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>e</TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>o</TT
></P
></DIV
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>&#60;data&#62;</I
></TT
></DT
><DD
><P
>The number of data bits per character.</P
><P
>Allowed values are <TT
CLASS="LITERAL"
>7</TT
> bits or
<TT
CLASS="LITERAL"
>8</TT
> bits, as Linux uses the
<SPAN
CLASS="ACRONYM"
>ASCII</SPAN
> character set which requires at least
seven bits.</P
><P
>Eight data bits are recommended. This allows the link to
easily be used for file transfers and allows non-English text to
be presented.</P
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-DATA"
></A
><P
><B
>Figure 2-4. Syntax for serial data bits, in extended Backus-Naur
form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;data&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="LITERAL"
>7</TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>8</TT
></P
></DIV
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>&#60;stop&#62;</I
></TT
></DT
><DD
><P
>The number of stop bit-times.<A
NAME="AEN563"
HREF="#FTN.AEN563"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
></P
><P
>Allowed values are <TT
CLASS="LITERAL"
>1</TT
> or
<TT
CLASS="LITERAL"
>2</TT
>.</P
><P
>One stop bit-time is recommended.</P
><P
>If the <SPAN
CLASS="ACRONYM"
>RS-232</SPAN
> cable is very long then
two stop bit-times may be needed.</P
><P
>You may occassionally see 1.5 stop bit-times. The intent
is to gain 4% more data throughput when a link is too long for
one stop bit-time but is too short to require two stop
bit-times. 1.5 stop bit-times is now rare enough to be a hazard
to use.</P
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-STOP"
></A
><P
><B
>Figure 2-5. Syntax for serial stop bits, in extended Backus-Naur
form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;stop&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="LITERAL"
>1</TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>2</TT
></P
></DIV
></DD
><DT
><TT
CLASS="REPLACEABLE"
><I
>&#60;flow_control&#62;</I
></TT
></DT
><DD
><P
>The type of flow control to use.</P
><P
>The Linux kernel allows no flow control and
<SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow
control.</P
><P
>No flow control is the default, this is indicated by
omitting &#60;flow_control&#62;.</P
><P
><SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow control
is recommended, especially if login access is also provided to
the serial port. This is indicated by a &#60;flow_control&#62; of
<TT
CLASS="LITERAL"
>r</TT
>.</P
><P
><SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow control
regulates the flow of chatacters. The computer does not send
characters until Clear To Send is asserted by the modem. If the
computer is has enough buffering to recieve characters from the
modem the computer asserts Ready to Send. Thus neither the
computer nor the modem's buffers are filled to
overflowing.</P
><DIV
CLASS="CAUTION"
><P
></P
><TABLE
CLASS="CAUTION"
WIDTH="90%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/caution.gif"
HSPACE="5"
ALT="Caution"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>The kernel's
<SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow control is
currently buggy. Machines can take a significant time to write
console messages if flow control is enabled but
<SPAN
CLASS="ACRONYM"
>CTS</SPAN
> will never be asserted (as occurs when
there is no call present on a modem or no session on a null
modem cable or cable to a terminal server). As a result of the
large number of kernel messages when the kernel is started a
machine configured with the kernel's
<SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow control can
take many minutes to reboot.</P
><P
>The kernel's
<SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow control
cannot be recommended at this time. The
<I
CLASS="CITETITLE"
>HOWTO</I
>'s author has a kernel patch
available which he is seeking to have included in the
mainstream kernel source code.</P
><P
>The <SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow
control in user-space applications does not share the kernel's
bugs and <SPAN
CLASS="ACRONYM"
>CTS</SPAN
>/<SPAN
CLASS="ACRONYM"
>RTS</SPAN
> flow
control is still recommended for
<SPAN
CLASS="APPLICATION"
>getty</SPAN
>.</P
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-FLOW"
></A
><P
><B
>Figure 2-6. Syntax for serial flow control, in extended Backus-Naur
form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;flow_control&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="REPLACEABLE"
><I
>&#60;nil&#62;</I
></TT
>&nbsp;|&nbsp;<TT
CLASS="LITERAL"
>r</TT
></P
></DIV
></DD
></DL
></DIV
><P
>At present the <SPAN
CLASS="ACRONYM"
>RS-232</SPAN
> status lines are
ignored by the kernel. A kernel message will be printed even if
Data Carrier Detect and Data Set Ready are not asserted. This
leads to the kernel messages being sent to a modem which is idle
and in command mode.</P
><P
>The console's slack interpretation of <SPAN
CLASS="ACRONYM"
>CTS</SPAN
>,
<SPAN
CLASS="ACRONYM"
>DSR</SPAN
> and <SPAN
CLASS="ACRONYM"
>DCD</SPAN
> makes it
impossible to connect a serial console to an
<SPAN
CLASS="ACRONYM"
>RS-232</SPAN
> multi-drop circuit. Multi-drop circuits
have more than two computers on the circuit; they are traditionally
four-wire, satelite or wireless services.</P
><P
>The Linux kernel uses the syntax in <A
HREF="preparation-setspeed.html#PREPARATION-SETSPEED-MODESYNTAX"
>Figure 2-7</A
> to describe the serial
parameters. Many boot loaders use a variation of the syntax used
by the Linux kernel.</P
><DIV
CLASS="FIGURE"
><A
NAME="PREPARATION-SETSPEED-MODESYNTAX"
></A
><P
><B
>Figure 2-7. Syntax for kernel serial parameters, in extended
Backus-Naur form</B
></P
><P
CLASS="LITERALLAYOUT"
><TT
CLASS="REPLACEABLE"
><I
>&#60;mode&#62;</I
></TT
>&nbsp;::=&nbsp;<TT
CLASS="REPLACEABLE"
><I
>&#60;speed&#62;</I
></TT
><TT
CLASS="REPLACEABLE"
><I
>&#60;parity&#62;</I
></TT
><TT
CLASS="REPLACEABLE"
><I
>&#60;data&#62;</I
></TT
><TT
CLASS="REPLACEABLE"
><I
>&#60;flow_control&#62;</I
></TT
></P
></DIV
><P
>Note that <TT
CLASS="REPLACEABLE"
><I
>&#60;mode&#62;</I
></TT
> does not
include <TT
CLASS="REPLACEABLE"
><I
>&#60;stop&#62;</I
></TT
>. The kernel
assumes the number of stop bits to be one. This shortcoming needs
to be considered when deploying long <SPAN
CLASS="ACRONYM"
>RS-232</SPAN
>
cables.</P
><P
>Most boot loaders default to <TT
CLASS="LITERAL"
>9600n8</TT
>. A
common default found on older terminals is
<TT
CLASS="LITERAL"
>9600e7</TT
>.</P
><P
>Use <TT
CLASS="LITERAL"
>9600n8</TT
> if possible, as this is the
default for most Linux software and modern devices.</P
><P
>This <I
CLASS="CITETITLE"
>HOWTO</I
> always configures the
serial speed and parameters, even where not strictly necessary.
This is so that people configuring parameters other than the
recommended and common default value <TT
CLASS="LITERAL"
>9600n8</TT
>
will know what to alter.</P
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN472"
HREF="preparation-setspeed.html#AEN472"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>There is no good reason for this
difference. Feel free to submit a patch to the linux-kernel
mailing list to correct this oddity.</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN563"
HREF="preparation-setspeed.html#AEN563"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>A <I
CLASS="WORDASWORD"
>bit-time</I
> is the time taken to
transmit one bit. The distinction between
<I
CLASS="WORDASWORD"
>bit-times</I
> of signal and
<I
CLASS="WORDASWORD"
>bits</I
> of data is apparent when you
consider that 1.5 bit-times of signal is possible but that 1.5
bits of data is impossible.</P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="preparation-setport.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="preparation-modem.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Select a serial port</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="preparation.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Configure the modem or the null-modem cable</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>