Friday, 8 December 2017

Arduino EEPROM Programmer

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

I saw this kit advertised on Tindie (Simple EEPROM Programmer shield for Arduino Mega) and thought it looked interesting.
I have an upcoming project where I will need to program some EEPROMs in place in a system. I hadn't looked into the programming algorithm, so this seemed like a good way to start.
The kit arrived, very nicely presented with a clear double sided instruction sheet and a nicely laid out board with all the tracks on the back and a copper pour ground plane. I notice things like that. I like things like that.
Assembly was straightforward. I chose to fit an IC socket (I had already stolen the ZIF socket supplied with the kit for something else), as I wasn't planning to change the IC in it very often.
All that was needed was to plug it into an Arduino Mega. The firmware is available from the author's blog. We've all had fun in the past with Arduino code that doesn't build and needs specific old versions of certain libraries, but I am pleased to say it built and programmed fine.
It uses a serial protocol, over a 9600 8N1 connection. The commands are detailed in the code, but basically V shows a version string, Raaaa reads from address 0xaaaa, and Waaaa:dd writes data 0xdd to address 0xaaaa (can be multiple bytes e.g. Waaaa:dddddd).
You can drive this from the serial monitor, but there are two provided front ends, a command line version and a desktop app.
Testing this with a couple of Atmel AT28C64B EEPROMs that I am currently using a lot to test a Commodore 64 cartridge. Yes, I have put labels on the chips, the etched labels can be tricky to read at some angles. No, of course my eyesight isn't getting worse, of course I'm not getting old.
I was able to read in data from the chip fine, but writing didn't seem to work. I checked with the author and he was using the same chips as me, and they were working fine for him. I checked the chips I was using in my usual programmer, and they were programming fine. It was then I noticed the lines about "Software Data Protection".
Checking the AT28C64B datasheet, it seems there is a sequence of instructions that can be sent to the chip to lock it to disable future writes, and to unlock it again. My Minipro programmer was unlocking at the start, programming and then locking again. A sensible precaution against accidental writes.
I tried removing the SDP (Software Data Protection, not the Social Democratic Party) and was then able to successfully program using the Arduino based programmer. There was no code present in there to do SDP which explains why it wasn't working on chips I had already used with my EPROM programmer. I had tried a chip fresh from the tube, but stupidly checked that it was working first by programming it on my EPROM programmer, which locked it. As there wasn't any provision for SDP in the code, so I tried enabling it using write instructions, W1555:AA, W0AAA:55 etc. but that didn't seem to work.
Checking the datasheet, they specified a series of events, so I took the V0.01 code and built a V0.02 with SDP enable and disable built in, trying to follow this sequence. This didn't work either, I tried a few ways around it, but thought it may be timing related. The exiting code has an overly generous 10mS write pulse, which is actually the maximum the chip can support. The datasheet says the chip can work with a pulse as small as 50nS. I tried a 1uS pulse (using the Arduino delayMicroseconds function), and that worked. I left these are separate commands, as they probably only apply to Atmel chips. P to protect the chip, U to unprotect.
The sequence above show testing writing is working, enabling SDP and writing more. Those writes didn't appear. Enabling SDP and repeating and the writes are now retained. Note the first byte is overwritten with 00 during the lock / unlock operation. Some data needs to be written to any address to complete the lock / unlock process. A future improvement may be to read that byte before lock / unlock and write it back afterwards with the original value. There is also a function to erase the whole chip, but that requires a 12V pulse which is not easily available in this case.
So, I bought this kit to learn more about programming EEPROMs, and it certainly worked. I sent my updates to the author, and he has already incorporated them into the official V0.02 release (available on his blog).