The Linux Serial HOWTO

by Greg Hankins, gregh@cc.gatech.edu v1.6, 23 June 1994

This document describes how to set up serial communications devices on a Linux box.

Contents

1 Introduction 3 1.1 Other sources of information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.2 New versions of this document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Supported serial hardware 4

3 What are the names of the serial ports? 4

3.1 Major and minor device numbers of serial devices in /dev . . . . . . . . . . . . . . . . . . . . 5 3.1.1 Creating devices in /dev . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.2 Notes for multiport boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

4 What is getty ps? 6 4.1 Installing getty ps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

5 What is setserial?  7

6 How do I dial out with my modem? 7

6.1 Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

6.1.1 Notes on internal modems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 6.2 Talking to your modem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.3 Dial out modem configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

7 How do I dial in and out with my modem? 9 7.1 Dial in and out modem configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 7.2 Example modem setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 7.3 Setting up uugetty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

7.4 Customizing uugetty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

8 How do I set up a terminal connected to my PC? 12 8.1 Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 8.2 Setting up getty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

9 Can I use more than 2 serial devices? 14 9.1 Choosing serial device interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 9.2 Setting serial device addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

10 Can Linux configure the serial devices automagically? 15 10.1 Notes for multiport boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

11 How do I set up my serial ports for higher speeds? 16

12 Noteworthy communications programs and utilities 16

13 More serial tips 16 13.1 kermit and zmodem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 13.2 Setting terminal types automagically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 13.3 Color ls on serial connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 13.4 Printing to a printer connected to a terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

14 Linux FTP sites 17

15 What are locks? 18

16 What are UARTs? How do they affect performance? 18

17 Troubleshooting 19 17.1 I keep getting “line NNN of inittab invalid” . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 17.2 When I try to dial out, it says “/dev/cuaN : Device or resource busy” . . . . . . . . . . . . . 19 17.3 I keep getting “Id SN respawning too fast: disabled for 5 minutes” . . . . . . . . . . . . . . . 19 17.4 I have a modem/terminal connected, but root can’t login on it. . . . . . . . . . . . . . . . . 20 17.5 I have my terminal connected to my PC, but after I type in a login name, it just locks up… 20 17.6 At high speeds, my modem looses data! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 17.7 On startup, Linux doesn’t report the serial devices the way I have them configured! . . . . . 20 17.8 rz and or sz don’t work when I call my Linux box on my modem. . . . . . . . . . . . . . . . 21 17.9 My screen is printing funny looking characters! . . . . . . . . . . . . . . . . . . . . . . . . . . 21 17.10getty or uugetty still doesn’t work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

17.10.1 Alternate versions of getty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

18 Contributions 21

1 Introduction

This is the Linux Serial HOWTO. All about how to set up modems and terminals under Linux.

1.1 Other sources of information

   • man pages for: init(1), getty(1m), login(1), gettydefs(4), setserial(8)

• Your modem manual

• “Managing UUCP and Usenet” by Tom O’Reilly and Grace Todino, O’Reilly and Associates, Inc. ISBN: 0-937175-93-5

• UUCP HOWTO: for information on setting up UUCP

• Printing HOWTO: deals with setting up a serial printer

• NET-2 HOWTO: everything about SLIP, CSLIP, PPP, etc

• Term HOWTO: everything you wanted to know about term

1.2 New versions of this document

New versions of the Linux Serial HOWTO will be periodically posted to comp.os.linux.announce and news.answers. They will also be uploaded to various Linux FTP sites, including sunsite.unc.edu:/pub/Linux/docs/HOWTO. The Serial HOWTO is also available at the following URL:

http://sunsite.unc.edu/mdw/HOWTO/Serial-HOWTO.html for WWW clients such as mosaic.

1.3 Feedback

Please send me any comments, suggestions, or additional material. I’m always eager to hear about what you think about the HOWTO. I’m also always on the lookout for improvements! Tell me exactly what you don’t understand, or what could be clearer. You can reach me at gregh@cc.gatech.edu. If you find any wrong information, please contact me ASAP.

1.4 Disclaimer

Your milage may vary. The answers given may not work for all systems and all setup combinations.

2 Supported serial hardware

Linux supports, (ie is known to work with):

• standard PC serial boards

• standard PC internal modems Multiport serial boards:

• Usenet Serial Board II

• Boca 4-port (BB-1004)

• Boca 8-port (BB-1008)

• Boca 16-port (BB-2016)

• AST FourPort boards and clones

• Accent Async boards

• Bell Technologies HUB6

• STB-4COM In general, Linux will support any serial board which uses a 8250, 16450, 16550, or 16550A (or compatible) UART, or an internal modem which emulates one of the above UARTs. Linux does not currently support any intelligent serial boards, but will likely do so sometime in the future. Special note on the BB-1004 and BB-1008, they do not support DCD and RI lines, and thus are not usable for dialin modems. They will work fine for all other purposes.

3 What are the names of the serial ports?

There are the 4 serial devices corresponding to COM1 - COM4:

     /dev/cua0, /dev/ttyS0 (COM1) address 0x3f8 IRQ 4
     /dev/cua1, /dev/ttyS1 (COM2) address 0x2f8 IRQ 3
     /dev/cua2, /dev/ttyS2 (COM3) address 0x3e8 IRQ 4
     /dev/cua3, /dev/ttyS3 (COM4) address 0x2e8 IRQ 3

The /dev/ttySN devices are for incoming connections and /dev/cuaN devices for outgoing connections. N is the serial port number. In this document, I refer to COM1 as ttyS0, COM2 as ttyS1, COM3 as ttyS2, and COM4 as ttyS3. If I am refering to a specific device in /dev, I will always prepend /dev to avoid confusing you.

On some installations, two extra devices will be created, /dev/modem for your modem and /dev/mouse for your mouse. Both of these are symbolic links to the appropriate /dev/cuaN device which you specified during the installation (unless you have a bus mouse, then /dev/mouse will point to the bus mouse device).

There has been some discussion on the merits of /dev/mouse and /dev/modem. I strongly discourage the use of these links. In particular, if you are planning on using your modem for dialin you will run into problems because the lock files will not work correctly if you use /dev/modem. Also, Taylor UUCP does not support symlinks either.

3.1 Major and minor device numbers of serial devices in /dev

     /dev/ttyS0 major 4, minor 64    /dev/cua0 major 5, minor 64
     /dev/ttyS1 major 4, minor 65    /dev/cua1 major 5, minor 65
     /dev/ttyS2 major 4, minor 66    /dev/cua2 major 5, minor 66
     /dev/ttyS3 major 4, minor 67    /dev/cua3 major 5, minor 67

Note that all distributions come with these devices already made correctly.

3.1.1 Creating devices in /dev

If you don’t have a device, you will have to create it with the mknod command.

Example, suppose you needed to create devices for ttyS0:

     linux# mknod -m 666 /dev/cua0 c 5 64
     linux# mknod -m 666 /dev/ttyS0 c 4 64

You can also get the MAKEDEV script, available on the usual FTP sites. This simplifies the making of devices. For example, if you needed to make the devices for ttyS0 you would type:

     linux# cd /dev
     linux# MAKEDEV ttyS0

This handles the devices creation for the incoming and outgoing devices.

3.1.2 Notes for multiport boards

The devices your multiport board uses depends on what kind of board you have. These are listed in detail in the rc.serial which comes with the setserial program. You will need to create these devices for sure! Either use the mknod command, or get the MAKEDEV script. Devices for mulitport boards are made by adding 64 + the port number. So, if you wanted to create devices for ttyS17, you would type:

     linux# mknod -m 666 /dev/cua17 c 5 81
     linux# mknod -m 666 /dev/ttyS17 c 4 81

Note that “64 + 17 = 81” Using the MAKEDEV script, you would type:

     linux# cd /dev
     linux# /dev/MAKEDEV ttyS17

4 What is getty ps?

This is just another version of getty, which is a program that handles some of the login process when you log in to a UNIX box. It was written by Paul Sutcliffe, Jr. <paul@devon.lns.pa.us>. Kris Gleason <gleasokr@boulder.colorado.edu> currently maintains it. 2.0.7e is the latest version, and supercedes any older versions. Most Linux distributions come with getty ps installed as the default getty. Thus, I will mainly focus on using the getty ps package in this document, but you are free to use any getty you like. You should check to make sure you do indeed have getty ps as the default getty. At your Linux prompt, type:

     linux# strings /etc/getty | grep RINGBACK

If grep returns “RINGBACK” then you have the right getty. If you do not have this version of getty, I highly recommend that you get it. It can be found on the standard Linux FTP sites. (Kris has promised me to implement a version feature in the next release, to avoid doing this grep sillyness.)

4.1 Installing getty ps

Get the package from a Linux FTP site, and install according to the instructions.

Be sure that the new getty ps works correctly before you remove all the other versions! I recommend changing one of your virtual console lines from:

     c2:23456:respawn:/etc/getty tty2

to:

     c2:23456:respawn:/etc/getty_ps tty2 VC console

Put this line in your /etc/gettydefs:

     VC# B9600 SANE CLOCAL # B9600 SANE -ISTRIP CLOCAL #@S @L login: #VC

and restart init:

     linux# kill -HUP 1

If you can log in on a console with getty ps, it’s working. Move getty ps to getty or link it. Be sure to update your /etc/inittab to correctly invoke the new getty. The entries need to be in the form of:

     id:runlevel:action:/etc/{uu}getty [options] line [speed [term [lined]]]

getty ps also uses syslogd to log messages. See the man pages for syslogd(1) and syslog.conf(5) for setting up syslogd, if you don’t have it running already. Messages are logged with priority LOG AUTH, errors use LOG ERR, and debugging uses LOG DEBUG. If you don’t want to use syslogd you can edit tune.h in the getty ps source files to use a log file for messages and debugging instead, but you’ll have to recompile the whole thing.

Once you have installed getty ps, and are certain it is working, you can remove any other versions of getty

you have. Be sure to check in /bin, /etc, /usr/bin, /usr/etc, /usr/man/man1, and /usr/man/cat1 for

any thing called getty - there are old versions lurking everywhere. Also, you can safely remove the old config file /etc/gettytab - you only need /etc/gettydefs. From this point on, all references to getty will refer to getty ps. References to uugetty will refer to the uugetty that comes with the getty ps package.

5 What is setserial?

setserial is a program which allows you to look at and change various attributes of a serial device, including its port, its IRQ, and other serial port options. It was initially written Rick Sladkey, and was heavily modified by Ted T’so <tytso@athena,mit.edu>, who also maintains it. The newest version is 2.10, and can be found on the Linux FTP sites. You can find out what version you have by running setserial with no arguments.

On boot, only the ttyS{0-3} ports are configured, using the default IRQ of 4 and 3. So, if you have any other serial ports provided by other boards (such as an AST Fourport), or if ttyS{0-3} have a non-standard IRQ, you must use this program in order to configure those serial ports. For the full listing of options, consult the man page.

6 How do I dial out with my modem?

6.1 Hardware requirements

First, make sure you have the right cable. Your modem requires a straight through cable, with no pins crossed. Any computer store should have these. Make sure you get the correct gender. Your DB25 serial port on your PC is always male. Do not confuse it with the parallel port, which is the female DB25. Hook up your modem to one of your serial ports. Consult your modem manual on how to do this.

6.1.1 Notes on internal modems

For an internal modem, you will not need a cable. An internal modem does not need a serial port, it has one built in. All you need to do is configure it to use an interrupt that is not being used, and configure the I/O address. Consult your modem manual if you get stuck. Also, see section 9 if you need help on choosing interrupts or addresses.

Due to a bit of stupidity on IBM’s part, you may encounter problems if you want your internal modem to be on ttyS3. If Linux does not detect your internal modem on ttyS3, you can use setserial and the modem will work fine. Internal modems on ttyS{0-2} should not have any problems being detected.

6.2 Talking to your modem

Make sure that nothing is using the serial port you hooked your modem to. Check to see if there is a getty watching it. If there is a getty process running on that port, check your /etc/inittab file for entries using that serial port. Comment the line out (with a “#”) and restart init. Do not comment any lines that contain a ttyN device, only ones containing ttySN devices. ttyN devices are your virtual consoles.

Use kermit to test the setup. For example, say your modem was on ttyS3, and it could handle 2400 bps. You would do the following:

     linux# kermit
     C-Kermit 5A(188), 23 Nov 92, POSIX
     Type ? or HELP for help
     C-Kermit>set line /dev/cua3
     C-Kermit>set speed 2400
     /dev/cua3, 2400 bps
     C-Kermit>c
     Connecting to /dev/cua3, speed 2400.
     The escape character is Ctrl-\ (ASCII 28, FS)
     Type the escape character followed by C to get back,
     or followed by ? to see other options.
     AT
     OK
     <ctrl>-\-C
     (Back at linux)
     C-Kermit>quit
     linux#

If your modem responds to AT commands, you can assume your modem is working correctly on the Linux side. Try dialing another modem. If you don’t like kermit, try one of the more advanced comm programs. Check out section 12 about comm programs if you need some pointers.

6.3 Dial out modem configuration

For dial out use only, you can configure your modem however you want.

I like to see result codes, so I set Q0 - result codes are reported. To set this on my modem, I would have to preceed the register name with an AT command. Using kermit or some comm program, connect to your modem and do the following:

     ATQ0

If your modem says OK back to you, then the register is set. Do this for each register you want to set.

I also like to see what I’m typing, so I set E1 - command echo on. If your modem has data compression capabilities, you probably want to enable them. You may want to enable RTS/CTS handshaking. Note that you will also have to enable the hardware handshaking on the serial port itself, too. This is best done on startup (say in rc.local or rc.serial) by saying:

     stty crtscts < /dev/cua3

Make sure you put in the correct serial port for your setup. Consult your modem manual for more help, and a full listing of options. If your modem supports a stored profile, be sure to write the configuration to the modem.

7 How do I dial in and out with my modem?

Get your modem to dial out correctly.

7.1 Dial in and out modem configuration

For dialin and dialout use, you have to set up your modem a certain way (again, using the AT command on your modem):

     E1       command echo ON
     Q0       result codes are reported
     V1       verbose ON
     S0=0     never answer (uugetty handles this with the WAITFOR option)

If you don’t set these correctly, your INIT string in your config file may fail, hosing the whole process. But, more on config files below...

     &C1     DCD is on after connect only

If DCD is always on, getty will always think there is a connection, and may try to log people in.

Other things you should set:

     &S0     DSR is always on
     &D3     DTR on/off resets modem
     enable your data compression (setting depend on modem manufacturer,
                                   consult your modem manual)
     autobaud                     (same applies here)
     enabling RTS/CTS             (here too)

If your modem does not support a stored profile, you can set these through the INIT string in your config file. See below.

7. How do I dial in and out with my modem? 10

7.2 Example modem setup

Here is my modem setup, for a Telebit T1600. Most things should work for any Hayes compatible modem though. Don’t worry if there are some things in my setup that aren’t on yours.

T1600 - Version LA1.00  - Active Configuration
 B1  E1  L2  M0  P   Q0  V1  X12  Y0
&C1 &D3 &G0 &J0 &L0 &Q0 &R3 &S1 &T4 &X0
S000=0   S001=0   S002=43  S003=13  S004=10  S005=8   S006=2   S007=40
S008=2   S009=6   S010=14  S011=70  S012=50  S018=0   S025=5   S026=1
S038=0   S041=0   S045=0   S046=0   S047=4   S048=0   S050=0   S051:254
S056=17  S057=19  S058:2   S059=0   S060=0   S061:0   S062=15  S063=0
S064:1   S068:3   S069=0   S090=0   S093=8   S094=1   S100=0   S102=0
S104=0   S105=1   S111:30  S112=1   S180:3   S181=1   S183=25  S190=1
S253=10  S254=255 S255=255

7.3 Setting up uugetty

Replace the stock getty with getty ps as described in section 4. Update /etc/gettydefs to include entries for modems (note that the entries point to each other, these are not for fixed speed):

# Modem entries
38400# B38400 CS8 # B38400 SANE -ISTRIP HUPCL #@S @L @B login: #19200
19200# B19200 CS8 # B19200 SANE -ISTRIP HUPCL #@S @L @B login: #9600
9600# B9600 CS8 # B9600 SANE -ISTRIP HUPCL #@S @L @B login: #2400
2400# B2400 CS8 # B2400 SANE -ISTRIP HUPCL #@S @L @B login: #1200
1200# B1200 CS8 # B1200 SANE -ISTRIP HUPCL #@S @L @B login: #300
300# B300 CS8 # B300 SANE -ISTRIP HUPCL #@S @L @B login: #38400

If you have a 9600 bps or faster modem with flow control, you can lock your serial port speed and let the modem handle the translation to other bps rates. Then, instead of the step down series of lines listed below, /etc/gettydefs only needs to contain one line for the modem:

# 38400 fixed speed
38400# B38400 CS8 # B38400 SANE -ISTRIP HUPCL #@S login: #38400
# 19200 fixed speed
19200# B19200 CS8 # B19200 SANE -ISTRIP HUPCL #@S login: #19200

If you have your modem set up to do RTS/CTS hardware flow control, you can add CRTSCTS to the entries. (Be sure you enable RTS/CTS on the serial port!).

Next, make sure that you have an outgoing and incoming device for the serial port your modem is on. If you have your modem on ttyS3 you will need the /dev/cua3, and /dev/ttyS3 devices. If you don’t have the correct devices, see section 3.1.1 on how to create devices, and create the devices.

7.4 Customizing uugetty

There are lots of parameters you can tweak for each port you have. These are implemented in seperate config files for each port. The file /etc/conf.uugetty will be used by all instances of uugetty, and /etc/conf.uugetty.ttySN will only be used by that one port. Sample default config files can be found with the getty ps source files, which come with most Linux distributions. Due to space concerns, they are not listed here. Note that if you are using older versions of getty (older than 2.0.7e) then the default files

will be in /etc/default/uugetty.ttySN . My /etc/conf.uugetty.ttyS3 looks like this:
     # sample uugetty configuration file for a Hayes compatible modem to allow
     # incoming modem connections
     #
     # alternate lockfile to check... if this lockfile exists, then uugetty is
     # restarted so that the modem is re-initialized
     ALTLOCK=cua3
     ALTLINE=cua3
     # line to initialize
     INITLINE=cua3
     # timeout to disconnect if idle...
     TIMEOUT=60
     # modem initialization string...
     #
     # format: <expect> <send> ... (chat sequence)
     INIT="" \d+++\dAT\r OK\r\n ATH0\r OK\r\n AT\sE1\sQ0\sATS0=0\r OK\r\n
     WAITFOR=RING
     CONNECT="" ATA\r CONNECT\s\A
     # this line sets the time to delay before sending the login banner
     DELAY=1
     #DEBUG=010

Add the following line to your /etc/inittab, so that uugetty is run on your serial port:

     S3:456:respawn:/etc/uugetty ttyS3 38400
     (^port without ``tty''      ^port ^-- put your highest modem speed here)

Restart init:

linux# kill -HUP 1

Now Linux will be watching your serial port for connections. Notice that we use uugetty for modems. This is because it does things like checking lock files.

Dial in from another site and log in to you Linux system. Rejoice.

getty and uugetty have a lot more options, see the man page for getty(1m) for a full description. Among other things there is a scheduling feature, and a ringback feature. RTFM :-).

8 How do I set up a terminal connected to my PC?

8.1 Hardware requirements

Make sure you have the right kind of cable. A null modem cable bought at a computer store will do it. But it must be a null modem cable! Make sure you are using your serial port, and not your parallel port.

At a minimum, you should have (for a DB25 connector):

RxD   Receive Data          2 - 3       TxD   Transmit Data
TxD   Transmit Data         3 - 2       RxD   Receive Data
GND   Signal Ground         7 - 7       GND   Signal Ground

If you want to have flow control and hardware handshaking, you must have a full null modem cable:

      Frame Ground          1 - 1             Frame Ground
RxD   Receive Data          2 - 3       TxD   Transmit Data
TxD   Transmit Data         3 - 2       RxD   Receive Data
RTS   Request To Send       4 - 5       CTS   Clear To Send
CTS   Clear To Send         5 - 4       RTS   Request To Send
DSR   Data Set Ready        6 - 20      DTR   Data Terminal Ready
GND   Signal Ground         7 - 7       GND   Signal Ground
DCD   Carrier Detect        8 - 20      DTR   Data Terminal Ready
DTR   Data Terminal Ready  20 - 6       DSR   Data Set Ready
DTR   Data Terminal Ready  20 - 8       DCD   Carrier Detect

If you have a DB9 connector on your port, try the following:

                          DB9   DB25
RxD   Receive Data          2 - 3       TxD   Transmit Data
TxD   Transmit Data         3 - 2       RxD   Receive Data
GND   Signal Ground         5 - 7       GND   Signal Ground

Alternatively, a DB9-DB25 null modem cable:

                                  DB9   DB25
        DCD   Carrier Detect        1 - 20      DTR   Data Terminal Ready
        RxD   Receive Data          2 - 2       TxD   Transmit Data
        TxD   Transmit Data         3 - 3       RxD   Receive Data
        DTR   Data Terminal Ready   4 - 6       DSR   Data Set Ready
        DTR   Data Terminal Ready   4 - 8       DCD   Carrier Detect
        GND   Signal Ground         5 - 7       GND   Signal Ground
        DSR   Data Set Ready        6 - 20      DTR   Data Terminal Ready
        RTS   Request To Send       7 - 5       CTS   Clear To Send
        CTS   Clear To Send         8 - 4       RTS   Request To Send
        (RI Ring Indicator          9 not needed)

If you are not using a full null modem cable, you might have to do the following trick: on your computer side of the connector, connect RTS and CTS together, and also connect DSR, DCD and DTR together. This way, when the computer wants a certain handshaking signal, it will get it (from itself).

Now that you have the right kind of cable, connect your terminal to your computer. If you can, tell you terminal to ignore modem control signals. Try using 9600 bps, 8 data bits, 1 stop bit, no parity bits for the terminal’s setup.

8.2 Setting up getty

Replace the stock getty with getty ps as described in section 4. Add an entry for getty to use for your

terminal in /etc/gettydefs:
     #9600 bps Dumb Terminal entry
     DT9600# B9600 CS8 CLOCAL # B9600 SANE -ISTRIP CLOCAL #S @L login: #DT9600

You can add HUPCL so the login is killed whenever you switch of the terminal (provided you use a proper null modem cable).

Edit your /etc/inittab file to run getty on the serial port (substituting in the correct information for your environment):

     S1:456:respawn:/etc/getty ttyS1 DT9600 vt100

Restart init:

     linux# kill -HUP 1

At this point, you should see a login prompt on your terminal. You may have to hit return a couple of times to get the terminal’s attention. Rejoice. Party. Log in on your terminal and PC. talk to yourself from accross the room.

9 Can I use more than 2 serial devices?

You don’t need to read this section, unless you want to use 3 or more serial devices... (assuming you don’t have a multiport board).

Providing you have another spare serial port, yes, you can.

The number of serial ports you can use is limited by the number of interrupts (IRQ) and port I/O addresses we have to use. Each serial devices must be assigned it’s own interrupt and address. A serial device can be a serial port, an internal modem, or a multiport serial board.

Multiport serial boards are specially designed to have multiple serial ports that share the same IRQ for all serial ports on the board. Linux gets data from them by using a different I/O address for each port on the card.

9.1 Choosing serial device interrupts

Your PC will normally come with ttyS0 and ttyS2 at IRQ 4, and ttyS1 and ttyS3 at IRQ 3. To use more than 2 serial devices, you will have to give up an interrupt to use. A good choice is to reassign an interrupt from your parallel port. Your PC normally comes with IRQ 5 and IRQ 7 set up as interrupts for your parallel ports, but few people use 2 parallel ports. You can reassign one of the interrupts to a serial device, and still happily use a parallel port. You will need the setserial program to do this. In addition, you have to play with the jumpers on your boards, check the docs for your board. Set the jumpers to the IRQ you want for each port.

You will need to set things up so that there is one, and only one interrupt for each serial device. Here is how I set mine up in /etc/rc.local - you should do it upon startup somewhere:

             /etc/setserial /dev/cua0 irq 3          # my mouse
             /etc/setserial /dev/cua1 irq 4          # my dumb terminal
             /etc/setserial /dev/cua2 irq 5          # my 2400 bps modem
             /etc/setserial /dev/cua3 irq 9          # my telebit modem

Standard IRQ assignments:

                   IRQ  0    Timer channel 0
                   IRQ  1    Keyboard
                   IRQ  2    Cascade for controller 2
                   IRQ  3    Serial port 2
                   IRQ  4    Serial port 1
                   IRQ  5    Parallel port 2
                   IRQ  6    Floppy diskette
                   IRQ  7    Parallel port 1
                   IRQ  8    Real-time clock
                   IRQ  9    Redirected to IRQ2
                   IRQ 10    not assigned
                   IRQ 11    not assigned
                   IRQ 12    not assigned

                   IRQ 13    Math coprocessor
                   IRQ 14    Hard disk controller
                   IRQ 15    not assigned

There is really no Right Thing to do when choosing interrupts. Just make sure it isn’t being used. 2, 3, 4, 5, or 7 is a good choice. “not assigned” means that currently nothing standard uses these IRQs. Also note that IRQ 2 is the same as IRQ 9. You can call it either 2 or 9, the serial driver is very understanding.

If you have a serial card with a 16-bit bus connector, you can also use IRQ 10, 11, 12 or 15.

Just make sure you don’t use IRQ 0, 1, 6, 8, 13 or 14! These are used by your mother board. You will make her very unhappy by taking her IRQs.

9.2 Setting serial device addresses

Next, you must set the port address. Check the manual on your board for the jumper settings. Like interrupts, there can only be one serial device at each address. Yours port will usually come configured as follows:

             /dev/cua0, /dev/ttyS0 address 0x3f8 ttyS0
             /dev/cua1, /dev/ttyS1 address 0x2f8 ttyS1
             /dev/cua2, /dev/ttyS2 address 0x3e8 ttyS2
             /dev/cua3, /dev/ttyS3 address 0x3e8 ttyS3

Choose which address you want each serial device to have and set the jumpers accordingly. I have my modem on ttyS3, and my mouse on ttyS0.

When you reboot, Linux should see your serial ports at the address you set them. The IRQ Linux sees may not correspond to the IRQ you set with the jumpers. Don’t worry about this. Linux does not do any IRQ detection when it boots, because IRQ detection is dicy and can be fooled. Use setserial to tell Linux what IRQ the port is using.

10 Can Linux configure the serial devices automagically?

Yes. To get Linux to detect and set up the serial devices automatically on startup, add the line:

     /etc/setserial /dev/cua0 auto_irq skip_test autoconfig

to your /etc/rc.local or /etc/rc.serial file. Do this for every serial port you want to auto configure. Be sure to give the correct location of where your setserial program lives, and give a device name that really does exist on your machine.

10.1 Notes for multiport boards

For board addresses, and IRQs, look at the rc.serial that comes with the setserial program. It has a lot of detail on multiport boards, including I/O addresses and device names.

11 How do I set up my serial ports for higher speeds?

Use setserial, with the spd hi flag to configure your serial port to use 57600 bps. Use spd vhi to use 115200 bps. Then, set your speed to 38400 bps. This is now the new speed you have set. There is no speed named 57600 or 115200.

Make sure you have 16550A UARTs :-).

12 Noteworthy communications programs and utilities

Once you get everything working, you may want to check out these more advanced programs, all are available on the usual FTP sites.

• Seyon - X based comm program

• xconn - X based comm program

• Minicom - friendly serial communication program

• Procomm - procommish comm program with zmodem

These programs offer more features that just kermit alone, including telephone directories, auto-dialing and so on.

• Another useful program is term. term multiplexes many connections over one serial line. It is somewhat similar to SLIP, and offers some SLIP functionality. These include rlogin, telnet, ftp, ncftp, finger, rdate, xmosaic and tredir. tredir is a special program which lets you redirect remote TCP/IP ports to your local machine. This allows for remote NNTP, and SMTP access. The good thing about term is that is runs entirely in user space, meaning it requires no kernel support, or sysadmin support (like SLIP does).

• screen is another multi-session program. This one behaves like the virtual consoles.

• callback is a program that will have your modem call you back immediately from where you just called.

• mgetty+fax handles FAX stuff, and provides an alternate getty

   • Other  things  can  be  found  on  sunsite.unc.edu:/pub/Linux/system/Serial

and sunsite.unc.edu:/pub/Linux/apps/comm. These are the directories where all the serial type things are kept.

13 More serial tips

Here are some serial tips you might find helpful...

13.1 kermit and zmodem

To use zmodem with kermit, add the following to your .kermrc:

     define rz !rz < /dev/cua3 > /dev/cua3
     define sz !sz \%0 > /dev/cua3 < /dev/cua3

Be sure to put in the device your modem is on. Then, to use it, just type rz or sz <filename> at the kermit prompt.

13.2 Setting terminal types automagically

To set your terminal type automagically when you log in, look at /etc/ttytype. Put in the device, and corresponding terminal type, and your TERM variable will be set when you log in.

Say I have a vt100 terminal on ttyS1, I would put:

     vt100 ttyS1
in /etc/ttytype.
You can also get tset from sunsite.unc.edu:/pub/Linux/system/Terminal-management/. See the docs

that come with tset to learn how to use it. tset can establish terminal characteristics when you log in, and doesn’t depend on any defaults.

13.3 Color ls on serial connections

If ls is screwing up your terminal emulation with the color feature, turn it off. ls -o, ls --color, and ls --colour all use the color feature. Some installations have ls set to use color by default.

13.4 Printing to a printer connected to a terminal

There is a program called vtprint that will do this. It is available from ftp.sdsu.edu:/pub/vtprint. The following is from the README file that comes with the program:

vtprint is a program that allows users to print from a remote UNIX host to a printer attached to their local terminal or emulator, which makes it great for printing files at home, etc. (It only does text files, though.)

14 Linux FTP sites

     sunsite.unc.edu(152.2.22.81):/pub/Linux         (NC, USA)
     tsx-11.mit.edu(18.172.1.2):/pub/linux           (MA, USA)
     nic.funet.fi(128.214.6.100):/pub/OS/Linux       (Finland, Europe)

These FTP sites support annonymous FTP, which means login as ftp, and password as your email address,

ie logname@yourhost.yourdomain.

15 What are locks?

Locks are simply a file saying that a particular device is in use. They are kept in /usr/spool/uucp. Locks are named LCK..<name>, where <name> is either a device name, or a UUCP site name. Certain processes create these locks so that they can have exclusive access to devices, for instance if you dial out on your modem, a lock will appear telling other processes that someone is using the modem already. Locks mainly contain the PID of the process that has locked the device. Most programs look at the lock, and try to determine if that lock is still valid by checking the process table for the process that has locked the device. If the lock is found to be valid, the program should exit. If not, some programs remove the stale lock, and use the device, creating their own lock in the process.

16 What are UARTs? How do they affect performance?

UARTs (Universal Asyncronous Receiver Transmitter) are chips inside your communication devices (terminal, serial card). There is one on each end of a connection. Their purpose is to convert data (bytes) to bits, send each bit down the serial line, and then rebuild the data again on the other end. The UARTs are asyncronous devices, because the time interval between transmission of data is not fixed. UARTs deal with data in byte size pieces.

Say you have a terminal hooked up to your PC. When you type a character, the terminal presents it to it’s UART. The UART shifts that character (a byte) out onto the serial line one bit at at time, at a specific rate. Hence, we have the rates 110, 300, 1200, 2400, ... bits/sec (bps). This is simply a measure of how fast bits are being sent. On the other end, the receiving UART takes all the bits and rebuilds the character (byte).

There are several different types of UARTs. You have probably heard of dumb UARTs - the 8250 and 16450, and smart or FIFO UARTs - the 16550A. To understand their differences, first let’s examine what happens when a UART has sent or received a byte.

The UART itself can’t do anything with the data, it just sends and receives it. The CPU gets an interrupt every time a byte has been sent or received. The CPU then moves a received byte out of the UART’s register and into memory somewhere, or gives the UART another byte to send. The 8250 and 16450 UARTs only have a 1 byte buffer. That means, that every time 1 byte is sent or received, it interrupts the CPU. At low rates, this is OK. But, at high transfer rates, the CPU get so busy dealing with the UART, that is doesn’t have time to tend to other tasks. In some cases, the CPU does not get around to servicing the interrupt in time, and the byte is overwritten, because they are coming in so fast.

That’s where the 16550A UARTs come in. These chips come with 16 byte FIFOs. This means that it can receive or transmit up to 16 bytes before it has to interrupt the CPU. Not only can it wait, but the CPU then can transfer all 16 byte at a time. Although the interrupt threshold is seldom set at 16, this is still a significant advantage over the other UARTs, which only have the 1 byte buffer. The CPU receives less interrupts, and is free to do other things. Data is not lost, and everyone is happy.

In general, the 8250 and 16450 UARTs should be fine for speeds up to 19200 bps. After 19200, you might start seeing data loss, and a reduction in computing speed.

Keep in mind that these dumb UART types are not bad, they just aren’t good for high speeds. You should have no problem connecting a terminal, or a mouse to these UARTs. But, for a high speed modem, the 16550A is definately a must.

You can buy serial cards with the 16550A UARTs for a little more money, just ask your dealer what type of UART is on the card. Or if you want to upgrade your existing card, you can simply purchase 16550A chips and replace your existing 16450 UARTs. They are pin-to-pin compatible. Some cards come with socketed UARTs for this purpose, if not you can solder. Note, that you’ll probably save yourself a lot of trouble by just getting a new card :-).

17 Troubleshooting

17.1 I keep getting “line NNN of inittab invalid”

Make sure you are using the correct syntax for your version of init. The different init’s that are out there use different syntax in the /etc/inittab file. Make sure you are using the correct syntax for your version

of getty.

17.2 When I try to dial out, it says “/dev/cuaN : Device or resource busy”

This problem can arise when DCD is not set correctly. DCD should only be set when there is an actual connection (ie someone is dialed in), not when getty is watching the port. When getty sees DCD get set, it will lock the port and probably spawn login. Check to make sure that your modem is configured to only set DCD when there is a connection. DTR and RTS should be set whenever something is using, or watching the line, like getty, kermit, or some other comm program.

Another common cause of “device busy” errors, is that you set up your serial port with an interrupt already taken by something else. As each device initializes, it asks Linux for permission to use its hardware interrupt. Linux keeps track of which interrupt is assigned to whom, and if your interrupt is already taken, your device won’t be able to initialize properly. The device really doesn’t have much of any way to tell you that this happened, except that when you try to use it, it will return a “device-busy” error. Check the interrupts on all of your cards (serial, ethernet, etc.). Look for IRQ conflicts.

17.3 I keep getting “Id SN respawning too fast: disabled for 5 minutes”

Make sure your modem is configured correctly. Look at registers E and Q. This can occur when your modem is chatting with getty.

Make sure you are calling getty correctly from your /etc/inittab. Using the wrong syntax or device names will cause serious problems.

17.4 I have a modem/terminal connected, but root can’t login on it.

This is done on purpose for security reasons. Generally, you should only have root logins enabled on the console. It is considered dangerous to allow root logins on anything other than the console.

But, you asked... Edit /etc/login.defs, and find the line that says CONSOLE. Add the name of the serial device to it. Say I have my terminal on ttyS1. I would change the line:

     CONSOLE tty1:tty2:tty3:tty4:tty5:tty6:tty8

to

     CONSOLE tty1:tty2:tty3:tty4:tty5:tty6:tty8:ttyS1

17.5 I have my terminal connected to my PC, but after I type in a login name, it just locks up.

You probably don’t have CLOCAL in your /etc/gettydefs entry for the terminal, and you’re probably not using a full null modem cable. You need CLOCAL. CLOCAL tells Linux to ignore modem control signals. Here is what it should look like:

     #9600 baud Dumb Terminal entry
     DT9600# B9600 CS8 CLOCAL # B9600 SANE -ISTRIP CLOCAL #@S @L login: #DT9600

Next, kill -TERM the getty process so a new one will be spawned with the new entry.

17.6 At high speeds, my modem looses data!

If you are trying to run your modem at > 19200 bps, and you don’t have 16550A UARTs, you should upgrade them. See section 16 about UARTs.

17.7 On startup, Linux doesn’t report the serial devices the way I have them configured!

This is true. Linux does not do any IRQ detection on startup, it only does serial device detection. Thus, disregard what it says about the IRQ, because it’s just assuming the standard IRQs. This is done, because IRQ detection is unreliable, and can be fooled.

So, even though I have my ttyS2 set at IRQ 5, I still see

     Jan 23 22:25:28 misfits vmunix: tty02 at 0x03e8 (irq = 4) is a 16550A

You have to use setserial to tell Linux the IRQ you are using.

17.8 rz and or sz don’t work when I call my Linux box on my modem.

If Linux looks for /dev/modem when you try to transfer files, look at /etc/profile, and /etc/csh.cshrc. There are a bunch of aliases defined there on some distributions, most notably Slackware. These aliases mess up the zmodem programs. Take them out, or correct them.

17.9 My screen is printing funny looking characters!

This happens on virtual consoles when you send binary data to your screen, or sometimes on serial connections. You can try the reset command, but I’ve found that it doesn’t fix the problem. The sure fire way to fix this is to type echo ^v^[c. For the ASCII impaired, thats echo <ctrl>v<esc>c.

17.10 getty or uugetty still doesn’t work.

There is a DEBUG option that comes with getty ps. Edit your config file /etc/conf.{uu}getty.ttySN and add DEBUG=777. If you are running syslogd, debugging info will appear in your log files. If you aren’t

running syslogd info will appear in /tmp/getty:ttySN for debugging getty and /tmp/uugetty:ttySN

for uugetty. Look at the debugging info and see what is going on. Most likely, you will need to tune some of the parameters in your config file, and you may have to configure your modem differently, too.

17.10.1 Alternate versions of getty

You might like these better:

mgetty, a different version of getty, can also handle faxes. It can be found on the Linux FTP sites.

agetty, yet another version of getty. This version comes with most distributions. If not, it should be on the Linux FTP sites.

18 Contributions

There was no possible way to write this HOWTO alone. Although a lot of the HOWTO is my writing, I have often rewritten contributions to maintain continuity in the writing style and flow. Thanks to everyone who has contributed or commented, the list of people has gotten too long to list. Special thanks to Matt Welch, Ted T’so, and Kris Gleason.

END OF Serial-HOWTO