Wednesday, October 03, 2012

Using a DEC LK401 keyboard in Linux is easy

I just got my Stellaris Launchpad. When I examined the USB library in StellarisWare and the sample code, I saw it would be easy to create an adapter for using an old DEC or Sun keyboard as a USB keyboard. However, before I started on that project, I realized that Linux already has drivers in the kernel for Sun and DEC keyboards: sunkbd and lkkbd.

The lkkbd driver has very good documentation in the long comment at the start of the file. It gives you the pinout, tells you how to hook up the keyboard, and tells you about the DEC document which describes the LK201 keyboard. (The DEC document is unavailable at that link but can be downloaded here. It's a technical manual for a VAX graphics board set which uses these keyboards.)

The keyboard uses +12V power and communicates via RS-423 serial communication at 4800 baud. This is compatible with standard RS-232 serial ports in terms of both protocol and voltage level. All that needs to be done is to hook it up to a serial port and provide +12V power. The connector is a plug similar to a phone handset connector. It can fit into a standard RJ11 phone jack, but because it is narrower it can fit in two different ways, one of which would make wrong connections.

Ubuntu comes with an already compiled lkkbd kernel module. To enable, the keyboard, all that's needed is something  like:

sudo inputattach --daemon -lk /dev/ttyS0

This will load the module and make the keyboard usable, leaving inputattach running as a daemon. The last part of the command specifies the serial port; change it if necessary.

The LK401 is pretty good. The tactile feel is better than the LK201, and I can type quite fast with it. The driver is stable. It seems all keys except Select work. There are no X11 keysyms associated with F19 and F20. Most of the extra keys are reported as XF86Launch making them usable as programmable hotkeys.

4 comments:

Unknown said...

How did you supply the 12v?

Boris Gjenero said...

I used an ordinary 12V regulated power supply adapter that came with an external drive. The serial port couldn't supply enough power. Hooking up to the PC power supply would be more work, but would make sense for long term use.

Wilm said...

Are you still with us Boris?

I have a slichtly different setup physically (using a VT220 terminal with LK451 keyboard as Raspberry Pi console)

I think I might benefit from the lkkbd module however. Raspbian does not include it.

Do you have sources or the like?

Rgds,
Wilm

Boris Gjenero said...

lkkbd is part of the official Linux kernel source tree https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/input/keyboard/lkkbd.c?id=HEAD

Though, if you're using a VT220 terminal, then lkkbd is irrelevant. The terminal talks to the keyboard and converts key presses into appropriate serial input for your Raspberry Pi. You would only need lkkbd or something similar if you wanted to directly connect the keyboard to the Raspberry Pi, without the VT220 in between.