💾 Archived View for tilde.club › ~nightheron › tech › terminal-netbsd.gmi captured on 2024-12-17 at 11:09:28. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Hooking Up an Old Serial Terminal to a NetBSD Machine over USB

I recently purchased an old Wyse WY-55 dumb terminal on a whim, and I've been experimenting with different things I can do with it. I wanted to try hooking up the terminal to a NetBSD machine. I figured it would be pretty simple since NetBSD is among the most "Unix-y" of the modern Unix-likes, and it should still have good support for these types of serial terminals. As it turns out, the process *is* simple. The main complicating factor was that the computer I run NetBSD on does not have a serial port, so I had to use a USB serial adapter. Figuring out how to get NetBSD to communicate via the USB adapter wasn't very hard either, but I figured I would still document the process in case someone finds it interesting or useful.

Required components

The FTDI-based USB serial adapter is nothing special; I just bought one of the first ones I found. NetBSD has a fine FTDI driver, so the adapter worked out-of-the-box for me.

The null-modem cable allows two devices with serial connections to talk to one another directly without a modem in between. The cable I bought also adapts the 9-pin connection on the RS-232 adapter to the 25-pin serial connection on the terminal.

The main thing to make sure of is that you actually have a null-modem cable. A null-modem cable has the transmit pin on one end wired to the receive pin on the other end, and vice versa. The handshake lines may also be crossed. See here:

Null modem (gemipedia)

Some reviews said the pins on the Cables To Go null-modem cable were wired incorrectly. However, I believe those users were either trying to use a null-modem cable for something it is not designed to do, or they were misunderstanding the pinouts of the DE-9 and DB-25 connectors. In my experience, the Cables To Go null-modem cable *is* correct and it works for its intended purpose, but do your own research.

The USB serial adapter plugs in to the computer USB port and to the null-modem cable. Then the null-modem cable plugs into the "modem" port on the terminal.

Terminal setup

Here are the settings I used on my WY-55. You may be able to get things to work with other settings, but here is what I used:

Display settings

General settings

Comm settings

Ports settings

There are many more settings than this, but the above are the ones I specifically set. Certainly not all of them are necessary. I'm still reading the WY-55 manual and experimenting to figure out what everything does.

Finding the device node that NetBSD uses to talk to the serial adapter

I knew that NetBSD would use a device node to talk to the terminal, but I wasn't sure which one. When unsure of what device node gets used to communicate with a device, it's often a good idea to check the system messages. After plugging in the USB serial adapter and running `dmesg`, I saw the following log:

uftdi0 at uhub3 port 3 configuration 1 interface 0
uftdi0: FTDI (0x0403) USB Serial Converter (0x6001), rev 2.00/6.00, addr 1
ucom0 at uftdi0 portno 0

The first thing to note is that NetBSD recognized the device immediately and correctly attached it with the USB FTDI driver. Also notice that it says something about `ucom0`. At this point I searched the /dev directory for any device with `ucom` in it but did not find any. However, I figured there might be information in the man pages, so I ran `man 4 ucom`.

The ucom man page says that it is associated with two device files:

/dev/dtyU? and /dev/ttyU?. The ttyU? devices are used for dial-in, and dtyU? devices are used for dial-out. The dial-out device file was the one I needed to start a connection with the terminal.

Connecting to the terminal

Once one knows what device file to dial-out to the terminal with, connecting to the terminal is quite simple (a very similar process should work on the other BSDs also). I opened /etc/ttys and added the following line:

dtyU0   "/usr/libexec/getty std.9600"	vt100	on

The /etc/ttys file is read by init(8). For each device listed that has the `on` flag, init will run the specified command.

The first column says what device file to use. In this case, it's dtyU0, the "zeroth" dial-out device file that the USB serial adpater is associated with (the device file I found reading the man pages). The second column is the command to run. The `getty` command will initialize the terminal and show a login prompt. The `std.9600` argument sets the baud rate to 9600, which is what I have my terminal set at. The third column is the terminal type. I have it set to vt100 (and the WY-55 is in vt100 emulation mode) for simplicity. Then the last entries are flags. The `on` flag tells init to run the command. You can also have a `secure` flag here. That will allow root login on this terminal. I didn't want to enable that in this case.

After saving my changes, I ran the following command to restart init and have it re-read the /etc/ttys file:

kill -HUP 1

Voila! A login prompt on the WY-55 terminal!

From there, I could use the serial terminal as intended.

Obligatory neofetch picture

Another nice thing is that on restart, if the USB serial adapter is connected, init(8) will initialize the terminal and send a login prompt to it as part of its normal process, now that there is an entry for the device in the /etc/ttys file. If I want to turn that off, I can just set the flag for the device to "off" in /etc/ttys.

Back to tech articles

Back to gemlog

Back home