HP KVM Adapter Hack

12/07/2015

Programming the AT89C51RD2 on an HP VKM Adapter

A while ago a co-worker gifted me with a couple of these adapters for an HP KVM device.

He pointed out they contained a really nice Atmel version of the 8051 microcontroller, the AT89C51RD2

He also explained the chip contained a factory installed bootloader.

Seemed like an interesting challenge to see what I could do with them.

Here's what it looked like...

And inside...

A search of the web quickly turned up this very helpful document http://ecee.colorado.edu/~mcclurel/AT89C51RC2_FLIP_Programming_Guide.pdf

I had to hunt around the Atmel site to find the FLIP application here I chose the 2.4.6 version for Windows.

If you look closely at the board there's a bunch of numbered test points all over it.

I traced out any of these that had direct connections to the pins on the AT89C51.

Here's what I came up with for starters:

  • VCC Pin#38 (also on several of the caps on board)

  • VSS Pin#16 (GND also on several caps on board)

  • RXD Pin#5 (TP24)

  • TXD Pin#7 (TP23)

  • PSEN Pin#26 (TP21)

  • RST Pin#4 (Reset TP25)

  • EA (Hardwired on board to VCC)

  • P1.5 Pin#1 (TP35 for test LED)

  • P1.6 Pin#2 (TP34 for test LED)

This was enough to get me started. Next problem was how to generate a test program.
Turns out I had a solution to that all along. For my Z80 project I used SDCC to compile C programs.
This compiler also supports the 8051 chip and my device is compatible with that instruction set.
So I compiled a simple LED blink program but I was concerned that if my attempt didn't work I would not really know if it was code did not get installed properly or there was simply an unforeseen error in my program.

To my rescue came EdSim51DI a free 8051 simulator that would accept the .HEX file output from SDCC.
With the simulator I was able to watch the bits on P1 increment and was now confident I could verify success. So I moved forward. Following the instructions from the document, I wired up the appropriate pushbuttons and connected the RXD & TXD signals to my trusty USB-TTL serial adapter.

One of the tricky parts was getting the chip into bootloader mode. The instructions stated:

1. Configure /EA to be a logic high

2. Press and hold the reset button

3. Press and hold a pushbutton that connects /PSEN to ground

4. Release the reset pushbutton(while still holding the /PSEN pushbutton)

5. Release the /PSEN pushbutton. The processor should not be in bootloader mode.

This sequence had to be timed with the connection sequence of the FLIP application.

At first I saw a lot of "Timeout Error" messages from the FLIP program but after a few tries I got the hang of it

and the program displayed the device signature and other chip info as well as enabling the programming buttons.

After a successful chip erase I uploaded my program and had a blinking LED practically on the first try!

Resources and Tools:

AT89C51RC2 FLIP Programming Guide

SDCC - Small Device C Compiler

Atmel FLIP programmer software

EdSim51DI the 8051 simulator

I added a connector for the essential signals.

Bottom of the board showing wires to the testpoints and a couple of connections made directly to the chip.

Later this bit of circuit board made starting the bootloader a lot easier. I simply "rolled" my finger across the two buttons.

The LCD Demo setup

Flip connection dialog

My friend the timeout message.....

Successful connection showing device info and enabled start button

Download Link Details:

8051_Sample_Code.zip An assortment of sample programs includes using the UART, driving an LCD and an RC Servo.

AT89C51_programming_note.pdf Another helpful document.

flip-2_4_6.zip Atmel Flip flash programming tool.