Serial Ports:
/dev/tty01 - com1
/dev/tty02 - com2
usermod -G dialer username
cu -l /dev/tty01 -s 9600
exit: ~^D or ~.
Find serial ports:
# dmesg | grep tty
diamond dmesg:
pccom0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pccom1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pccom2 at isa0 port 0x3e8/8 irq 5: ns16550a, 16 byte fifo
Try noting the value of the iflag setting with "stty -g /dev/tty00" while
it's working (or "stty -g" in the running session), and using that for the
values of "i0" and "i1" in a gettytab entry. E.g:
zterm|Mac running ZTerm:\
:sp#9600:i0#XXXX:i1#XXXX:
substituting the values found with "stty" for "XXXX". Now set "zterm" to
the term type in "/etc/ttys", send a SIGHUP, and see what happens.
Note that it's also possible to put descriptive settings in "gettytab", but
I'm not sure exactly how that goes, or what you'd need to put there. Another
thing, you probably want to set software handshaking if you have only a three-
wire cable (and also in the ZTerm). For what it's worth, this is how I set
software handshaking for a VT220:
vt.9600|vt420-9600:\
:sp#9600:i0#2f02:i1#2f02:
vt.19200|vt420-19200:\
:sp#19200:i0#2f02:i1#2f02:
vt.38400|vt420-38400:\
:sp#38400:i0#2f02:i1#2f02:
--------------------------------------------------------------------------------
minicom /dev/tty01 hack to allow login:
spc@diamond[~] $ stty -g
gfmt1:cflag=1cb00:iflag=101:lflag=4b:oflag=7:discard=f:dsusp=19:eof=4:eol=ff:eol
2=ff:erase=7f:intr=3:kill=15:lnext=16:min=1:quit=1c:reprint=12:start=11:status=f
f:stop=13:susp=1a:time=5:werase=17:ispeed=9600:ospeed=9600
spc@diamond[~] $ stty
speed 9600 baud;
lflags: -icanon -isig -iexten echoe echoke echoctl
iflags: -ixon -ixany -imaxbel ignbrk -brkint
cflags: cs8 -parenb clocal crtscts
time
5
values of "i0" and "i1" in a gettytab entry. E.g:
zterm|Mac running ZTerm:\
:sp#9600:i0#XXXX:i1#XXXX:
vt.9600|vt420-9600:\
:sp#9600:i0#2f02:i1#2f02:
--------------------------------------------------------------------------------
There are two parts to getting a functional serial console on an OpenBSD system.
First, you must have OpenBSD use your serial port as a console for status and
single user mode. This part is very platform dependent. Second, you must enable
the serial port to be used as an interactive terminal, so a user can log into it
when running multi-user. This part is fairly similar between platforms.
Terminal sessions are controlled by the /etc/ttys file. Before OpenBSD will give
you a "login:" prompt at a device, it has to be enabled in /etc/ttys, after all,
there are other uses for a serial port other than for a terminal. In platforms
which typically have an attached keyboard and screen as a console, the serial
terminal is typically disabled by default. We'll use the i386 platform as an
example. In this case, you must edit the line that reads:
/etc/ttys (http://www.openbsd.org/cgi-bin/man.cgi?query=ttys&sektion=5)
tty00 "/usr/libexec/getty std.9600" unknown off
-to-
tty00 "/usr/libexec/getty std.9600" vt100 on secure
Here, tty00 is the serial port we are using as a console. The "on" activates the
getty for that serial port so that a "login:" prompt will be presented, the
"secure" permits a root (uid 0) login at this console (which may or may not be
what you desire), and the "9600" is the terminal baud rate. Note that you can
use a serial console for install without doing this step, as the system is
running in single user mode, and not using getty for login.
On some platforms and some configurations, you must bring the system up in
single user mode to make this change if a serial console is all you have
available.
Note that you will not get a "login:" prompt on the serial port console until
you set it to "on" in /etc/ttys(5), and either reboot or send init(8) a HUP
signal using kill(1):
kill -1 1
kill -s HUP 1
as -1 is signal 1 (HUP) and 1 is process 1 (init).
--------------------------------------------------------------------------------
To direct the boot process to use the serial port as a console, create or edit
your /etc/boot.conf file to include the line:
set tty com0
to use the first serial port as your console. The default baud rate is 9600bps,
this can be changed with a /etc/boot.conf line using the stty option. This file
is put on your boot drive, which could also be your install floppy, or the
command can be entered at the boot> prompt from the OpenBSD second-stage boot
loader for a one-time (or first time) serial console usage.
Notes:
o OpenBSD numbers the serial ports starting at tty00, DOS/Windows labels
them starting at COM1. So, keep in mind tty02 is COM3, not COM2.
o Only the first serial port (com0) is supported for console on amd64
and i386.
--------------------------------------------------------------------------------
/etc/ttys
# name getty type status comments
#
console "/usr/libexec/getty Pc" vt220 off secure
ttyC0 "/usr/libexec/getty Pc" vt220 on secure
ttyC1 "/usr/libexec/getty Pc" vt220 on secure
ttyC2 "/usr/libexec/getty Pc" vt220 on secure
ttyC3 "/usr/libexec/getty Pc" vt220 on secure
ttyC4 "/usr/libexec/getty Pc" vt220 off secure
ttyC5 "/usr/libexec/getty Pc" vt220 on secure
ttyC6 "/usr/libexec/getty Pc" vt220 on secure
...
tty01 "/usr/libexec/getty std.9600" vt100 on secure
tty02 "/usr/libexec/getty std.9600" unknown off
tty03 "/usr/libexec/getty std.9600" unknown off
...
ttyp0 none network
ttyp1 none network
ttyp2 none network
ttyp3 none network
...
ttyCx are the virtual terminals accessible by either ALT+Fn or CTRL+ALT+Fn.
ALT+F1 will access ttyC0, and ALT+F2 will access ttyC1, etc... The 4th is
turned off for use with X (unsure)? tty01 thrutty0n are serial port consoles.
name
The name of the terminal device. The first field is the name of the
terminal special file as it is found in /dev.
getty
The second field of the file is the command to execute for the line,
usually getty(8), which initializes and opens the line, setting the
speed, waiting for a user name and executing the login(1) program.
It can be, however, any desired command, for example the start up for
a window system terminal emulator or some other daemon process, and
can contain multiple words if quoted. Other common entries include
xdm, which starts the X Window System, or none, meaning no program.
type
The third field is the type of terminal usually connected to that TTY
line, normally the one found in the termcap(5) database file. The
environment variable TERM is initialized with the value by either
getty(8) or login(1).
For virtual consoles, the correct type is vt220. Other common values
include network on pseudo-terminals, dialup for incoming modem ports,
and unknown when the terminal type a user will try to connect with
cannot be predetermined.
status
The remaining fields set flags in the ty_status entry (getttyent(3))
or specify a window system process that init(8) will maintain for the
terminal line. The following is a list of permitted flags for each TTY:
on Specify that init(8) should execute the command given
in the second field.
off The opposite of on.
secure If on is also specified, allows users with a UID of 0
to login on this line.
Additionally, the following flags modify the default behavior of the terminal
line. Some of these flags may not be supported by a terminal line driver. The
flag fields should not be quoted:
local - Treat the line as if it is locally connected.
rtscts - Use RTS/CTS hardware flow control, if possible.
mdmbuf - Use DTR/DCD flow control if possible.
softcar - Ignore hardware carrier on the line.
The string window= may be followed by a quoted command string which init(8) will
execute before starting the command specified by the second field.
Example /etc/ttys:
# root login on console at 1200 baud
console "/usr/libexec/getty std.1200" vt100 on secure
# dialup at 1200 baud, no root logins
ttyd0 "/usr/libexec/getty d1200" dialup on # 555-1234
# Mike's terminal: hp2621
ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on # 457 Evans
# John's terminal: vt100
ttyh1 "/usr/libexec/getty std.9600" vt100 on # 459 Evans
# terminal emulate/window system
ttyv0 "/usr/new/xterm -L :0" vs100 on window="/usr/new/Xvs1000"
# Network pseudo ttys -- don't enable getty
ttyp0 none network
ttyp1 none network off
--------------------------------------------------------------------------------
getty (/etc/ttys)
The description in man 8 getty:
The getty program is called by init(8) to open and initialize the tty
line, read a login name, and invoke login(1).
So, init reads /etc/ttys and starts a getty process on every terminal you've
told it to in that configuration file. Monitoring that terminal to see if anyone
tries to log in is getty's job. If someone does, getty will start the login
program to verify that user's login name and password. If those check out,
login will start up that user's login shell and place the user in their home
directory. Once the user has a shell, or command interpreter, they now have a
way of interacting with the operating system. It is now up to the shell to
interpret a user's input and ensure that any necessary processes are started.
When a user logs out of their login shell, init is called in to start another
getty process which will patiently monitor the terminal for another login
attempt.
--------------------------------------------------------------------------------
man init
Line status (on, off, secure, getty, or window information) may be changed in
the /etc/ttys file without a reboot by sending the signal SIGHUP to init with
the command ``kill -s HUP 1''. On receipt of this signal, init re-reads the ttys
file. When a line is turned off in ttys, init will send a SIGHUP signal to the
controlling process for the session associated with the line.For any lines that
were previously turned off in the ttys file and are now on, init executes a new
getty to enable a new login.If the getty or window field for a line is changed,
the change takes effect at the end of the current login session (e.g., the next
time init starts a process on the line).If a line is commented out or deleted
from ttys, init will not do anything at all to that line.However, it will
complain that the relationship between lines in the ttys file and records in the
utmp file is out of sync, so this practice is not recommended.
--------------------------------------------------------------------------------
man cu
tip [-nv] [-speed] [system-name]
cu [-ehot] [-a acu] [-l line] [-s speed] [-#] [phone-number]
DESCRIPTION
tip and cu establish a full-duplex connection to another machine,
giving the appearance of being logged in directly on the remote CPU.
It goes without saying that you must have a login on the machine (or
equivalent) to which you wish to connect. The preferred interface is
tip. The cu interface is included for those people attached to the
"call UNIX" command of Version 7 AT&T UNIX. This manual page describes
only tip.
The options are as follows:
-a acu Set the acu.
-e For cu, use even parity.
-h For cu, echo characters locally (half-duplex mode).
-l line For cu, specify the line to use. Either of the forms like
tty00 or /dev/tty00 are permitted.
-n No escape (disable tilde).
-o For cu, use odd parity.
-s speed For cu, set the speed of the connection. Defaults to 9600.
-t For cu, connect via a hard-wired connection to a host on a
dial-up line.
-v Set verbose mode.
For cu, if both -e and -o are given, then no parity is used. This is the
default behaviour.
If speed is specified it will override any baudrate specified in the
system description being used.
If neither speed nor system-name are specified, system-name will be set
to the value of the HOST environment variable.
If speed is specified but system-name is not, system-name will be set to
a value of 'tip' with speed appended. e.g. tip -1200 will set system-
name to 'tip1200'.
...
Typed characters are normally transmitted directly to the remote machine
(which does the echoing as well). A tilde (`~') appearing as the first
character of a line is an escape signal; the following are recognized:
~^D or ~. Drop the connection and exit (you may still be logged
in on the remote machine).
~! Escape to a shell (exiting the shell will return you to tip).
~# Send a BREAK to the remote system. For systems which
don't support the necessary ioctl() call the break is
simulated by a sequence of line speed changes and DEL
characters.
~? Get a summary of the tilde escapes.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------