

Everyone and their granny has designed a box to connect Sun keyboards to PCs. I liked none of them. The keyboards last a lifetime, so might as well make an adaptor that will outlast the aging AT and PS/2 keyboard connectors, right?
So this is a project to connect Sun keyboards to any computer with USB support.
This page is still in the making, expect updates to reflect the state of work.
![[A Sun Type 5 keyboard]](images/hardware_suntype5.jpg)
vi editing
(although Control-[ is much handier for the truly
initiated); there are Alt, AltGr and two
Meta keys; a Compose key; monitor/volume control
keys and a power button. You can find no less than 26 function keys;
13 are labeled Help, Copy, et cetera, twelve are
where PC users would expect them, and there's a blank key where the
Escape key would be on a PC keyboard. These come in really
handy for shortcuts and editing. The keyboard also features a socket
for Sun serial mice, and offer provision for a left handed mouse. Did
I mention they're great for touch-typing?
Technically speaking, they're simple serial devices, talking to the machine at 1200 bps through an 8-pin mini-DIN plug. No hardware handshaking or anything. The mouse's serial signal is repeated to the computer using one pin. Simple!
![[Keyspan's USA-19Qi USB PDA Adaptor]](images/hardware_usa19qi.jpg)
The remarkable feature of this chip is that it's completely field-programmable. You can download new firmwares to it every time it boots, making it behave differently. Stick a bigger serial EEPROM in there, and you have a semipermanent firmware. The USB chip still responds to upgrade commands, so you can reprogram its EEPROM anytime you like.
![[USA-19Qi, the
full monty]](images/hardware_usa19qi_inside.jpg)
There are two modifications to be implemented here:
Besides, the Sun keyboard needs 5V power and uses a second data in pin for the mouse. And I really want to be able to revert the dongle to its originally intended use whenever I feel like it. Perhaps some day I'll manage to cram both Sun keyboard support and a basic RS-232 firmware in the machine's EEPROM.
We can't just add a new EEPROM to the device. If a 24LC00 is installed, no additional EEPROMs can be added. We need to replace the chip somehow.
First step: get the adaptor to work as a serial port. D'oh! My kernel is missing the firmware. Downloaded new, non-GPL (eek) firmware from Keyspan, and installed it. No luck yet, as the device is a new model unsupported by my 2.4.18 driver (Model USA-19Qi).
I set out to patch the kernel. Managed to get the device detected and the driver loaded dynamically. Good. Now try to find out why the baud rate divisor is so absolutely wrong. D'oh number 2! Keyspan's addenda to the Linux driver add full support for my device. I take solace in the fact that my own kernel patch was almost identical to Keyspan's (apart from that ‘minor’ problem with the baud divisor).
I finally get my trusty Palm IIIx to talk to the serial port. Fire
up a getty and login to Vennëa from the Palm (I
always liked that). At this point, I have an incredibly messy desk,
full of other serial devices used for testing, including a 1989
Microsoft Mouse (don't knock it, they made good hardware then ― maybe
they should've been Microhard), my GPS receiver, mobile phone, et
cetera. Look at the photo to see exactly what ‘messy’ means.
![[Project day 1]](images/hardware_suntype5_day1.jpg)
Quiz: how many CPUs on the desk? Including Vennëa's tower case (not visible in the photo), I count eight: a Dragonball EZ in the Palm; some reasonably strong microcontroller or small CPU in the Anykey keyboard (it even has 2 kbytes of RAM); the AN2131 chip in the Keyspan dongle; a PIC 16Cxx microcontroller in the mouse (nice! A mouse with hack value); an 80186 in the GPS; and some otherwordly weirdness in the Nokia phone. Plus Vennëa's Duron and the RISC CPU on the DVD decoder card. I have more CPU's on my desk than IBM once thought would exist in the entire world!
Ok, the break is over. Get the 8051 compiler out and start learning how to program the beastie. Lots of frustration later (it's difficult to debug with only one LED and so many, many failure points), I get the LED on the dongle to blink at changing, funky rates. Yay!
USB time. Do more reading on the EZ-USB part of the AN2131. Code some. More reading. Give up, read the EZ-HID project's Sun keyboard firmware. Compile it, install it. No joy. Go through the code. Realise that the firmware won't register the HID device unless a Sun keyboard is installed. Okay, how about if I comment out this and this and this line? Compile, download ― and the kernel detects an ‘Acme USB Widgets’ USB keyboard and mouse. Then proceeds to spray the host with random scancodes, bringing my X server down, then rebooting (!). This is almost a trojan!
![[I2C EEPROM]](images/hardware_usa19qi_eeprom.jpg)
Now comes the hard part: hardware changes. Attaching the keyboard cable seems a very scary prospect. The EZ-USB chip is 10 by 10 mm, with 11 pins on each side. And space between them. Better spend some time reading about SMT soldering.
And what do I do about the I2C EEPROM? It's far too small for me to solder. Thankfully, Usenet has some help on the matter. I decide to order ordinary DIP EEPROMs because, with 2.54 mm between pin centres, it's easier to solder. All I need is four wires from the old IC to the new one, which I decide I'll glue somewhere. Plenty of headroom in the translucent box of the Keyspan. I decide not to desolder the 24LC00 if I can help it, but to disable it by cutting its data (SDA) and clock (SCL) pins with an X-Acto knife, then very carefully soldering the finest insulated wire I can find to the 24LC64's corresponding pins (and also Vcc and Vss to provide power to the part).
I'm beginning to wish for a watchmaker's loupe. At least I have a ‘Helping Hands’ stand, a little, heavy stand which can hold PCBs and cables for you while you do soldering work on them. It even has a passable magnifying glass. I'll also need tweezers and soldering wick for easier desoldering. Oh, and the finest soldering iron tip I can find. Scary!