NetBSD Serial Port Primer

General Information

Other sources of information


General Information


This document is intended as a supplement to the documentation that came with your hardware. It briefly outlines some of the issues related to connecting the serial ports of some of the supported platforms. Many of the supported platforms require or optionally allow use of a serial console, and some confusion may arise over how to wire the connectors.

Briefly, most computers are DTE (Data Terminal Equipment), and most modems and dumb terminals are DCE (Data Communication Equipment). To connect a DTE to a DTE (such as to use a PC as a PPP server or a terminal), you need to insert a "null modem" cable, which swaps the transmit and receive data and handshaking lines.

There are various handshaking, or "modem" lines that are specified in the serial protocols. These allow DTE and DCE equipment to pace the flow of information (such as if the receiving equipment isn't ready to get more data, it tells the transmitting equipment to wait until it's ready). For a more detailed and accurate description, you should read one of the references above.

See your port's FAQ, or a hardware reference to determine how to enable serial console on your hardware (if supported). On many platforms, you only need to remove the keyboard and mouse. On others, you need to remove the framebuffer. On yet others, you need to set up the bootrom or PROM to explicitly use a serial console. The most common setting is 9600 bps, 8 bits, no parity, and one stop bit. Handshaking requirements vary from platform to platform.

Keep in mind, that if your system's bootROM, Firmware, or whatever supports serial consoles, NetBSD is smart enough to know about this. That means, you most likely should not enable a separate ttys(5) in /etc/ttys. You may, however, need to edit the console entry to ensure that it has the correct terminal type (for example, change 'sun' to 'vt100').

On some platforms, a constant stream of zeros is equivalent to a serial BREAK. For example, on sparc systems, this tells the system to drop into the bootrom prompt. Keep this in mind if you find out that disconnecting a serial cable causes your system to stop responding.

Connector types and pinouts (top)

There are three common connector types: DB25, DB9, and MiniDIN8. The pin numbering convention is as follows (female connectors are reversed):

MiniDIN8 (male)

   8 7 6
  5   4 3
    2 1

DB25 (male)

  1                         13
 _______________________________
 \  . . . . . . . . . . . . .  /
  \  . . . . . . . . . . . .  /
   ---------------------------
   14                       25

DB9 (male)

   1         5
 _______________
 \  . . . . .  /
  \  . . . .  /
   -----------
    6       9

RJ-11 (male)

 _!=!_
| | | |
-------
1 2 3 4

Serial port pinouts for various platforms (top)

Unfortunately, not everyone follows a standard set of pin numbers for their serial lines. In particular, the vendors using MiniDIN8 connectors screw everything up. If you're willing to do without the handshaking lines, any MiniDIN8 cable should work on any system (i.e. TxD, RxD, and GND are all in the same location). Be wary of Macintosh "modem" cables, as some vendors wire them differently (trying to allow for DTR, DSR, and DCD signaling) -- you should check their wiring with a multimeter before making any assumptions.

signal
name
standard
DB9
standard
DB25
mac
MiniDIN8
next68k
MiniDIN8
sgi
MiniDIN8
sparc
MiniDIN8
hp300
DB9
dir full name comment
TxD 3 2 3 3 3 3 2 out Transmit Data data
RxD 2 3 5 5 5 5 3 in Receive Data data
RTS 7 4 - 6 6 6 4 out Request To Send handhsake
CTS 8 5 - 8 2 2 5 in Clear To Send handshake
DTR 4 20 - 1 1 1 1 out Data Terminal Ready status
DSR 6 6 - - - - 6 in Data Set Ready status
RI 9 22 - - - - 9 in Ring Indicator status
DCD 1 8 - 2 7 7 8 in Data Carrier Detect status
RTxC - 17 - 7 - 8 - in Receive Clock
HSKo - - 1 - - - - out Output Handshake mac-specific (usually RTS)
HSKi - - 2 - - - - in Input Handshake mac-specific (usually CTS)
TxD+ - - 6 - - - - out RS-422 Transmit Data (+)
RxD+ - - 8 - - - - in RS-422 Receive Data (+)
GPi - - 7 - - - - in General Purpose Input may be used for RI or handshaking
GND 5 7 4 4 4,8 4 7 n/a Signal Ground
- - 1 - - - - - n/a Protective Ground cable shield (do not use for Signal Ground)

Note: Macintosh (mac68k and macppc) systems use the RS-422 protocol which has balanced pairs (positive and negative lines) for transmit and receive. To connect a balanced RS-422 line to a single-ended RS-232 line, tie the positive receive data line (RxD+) to signal ground, and leave the positive transmit data line (TxD+) floating. How you wire HSKo and HSKi depend on application, though usually HSKo is used as RTS and HSKi is used as CTS. Additionally, some cable manufacturers try to tie DCD, DTR, and DSR signals to various of the MiniDIN8 lines. See Interfacing a Mac Serial Port to RS-232 Lab Equipment for more information. Beware of truly ancient Apple cables, as the original Mac 128k and 512k models used DB9 connectors with non-standard pinouts.

Note: Some sparc systems use MiniDIN8 connectors for serial, although others have DB25 connectors. The MiniDIN8 pinout is listed here. Some of the DB25-based systems have a breakout cable (A/B) that supports two serial ports. See the FAQ for the pinouts of this cable (the first set of serial lines are in standard DB25 locations -- you don't need an adapter).

Note: All next68k systems have two MiniDIN8 serial ports. The NEXTSTEP System Administrator's manual has several examples of serial cables for NeXT systems. See the online version, or the Radical System Solutions: NeXT Serial / Modem Cables page for more information.

Note: All hp300 systems which use a 98562 System Interface Board have a non-standard DB9 pinout. This is what's listed here. All Series 400 models have a DB25 breakout cable that supports three serial ports. See the FAQ for the pinouts of this cable (the first set of serial lines are in standard DB25 locations -- you don't need an adapter). Additionally, the 948642A card supports four serial ports using RJ-11 jacks. Everything else uses standard DB9 or DB25 connectors.

Common cables with modem signaling (top)

Null modem DB25 to DB25 cable

DB25                   DB25
----                   ----
1 GND  --------------- 1 GND
2 TxD  --------------- 3 RxD
3 RxD  --------------- 2 TxD
4 RTS  --------------- 5 CTS
5 CTS  --------------- 4 RTS
7 GND  --------------- 7 GND
6 DSR  ---+
          +----------- 20 DTR
8 DCD  ---+
                 +---- 6 DSR
20 DTR ----------+
                 +---- 8 DCD

Null modem DB25 to DB9

DB25        DB9
----        ---
1 GND  ---  1 GND
2 TxD  ---  2 RxD
3 RxD  ---  3 TxD
4 RTS  ---  8 CTS
5 CTS  ---  7 RTS
7 GND  ---  5 GND
6 DSR  ---  4 DTR
20 DTR ---  6 DSR

Modem MiniDIN8 to DB25 (Macintosh, non-null modem)

Note that RxD+ is shorted to ground, and that TxD+ and GPi are floating. You should have the short as close to the DB25 as possible, instead of near the MiniDIN8. If possible have the RxD+ and RxD- as a twisted pair.
MiniDIN8           DB25
--------          ----
1 HSKo ----------- 4 RTS
2 HSKi ----------- 5 CTS
3 TxD- ----------- 2 TxD
5 RxD- ----------- 3 RxD
4 GND  ---+
          +------- 7 GND
8 RxD+ ---+
6 TxD+ ---x
7 GPi  ---x

Null modem MiniDIN8 to MiniDIN8 (Macintosh "printer" cable)

MiniDIN8   MiniDIN8
--------   --------
1 HSKo --- 2 HSKi
2 HSKi --- 1 HSKo
3 TxD- --- 5 RxD-
4 GND  --- 4 GND
5 RxD- --- 3 TxD-
6 TxD+ --- 8 RxD+
7 GPi  --- 7 GPi
8 RxD+ --- 6 TxD+

Up to NetBSD Hardware Documentation
Home page
Documentation top level

(Contact us) $NetBSD: serial.html,v 1.19 2005/09/28 17:24:21 mishka Exp $
Copyright © 1994-2005 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.
NetBSD® is a registered trademark of The NetBSD Foundation, Inc.