Close

Project log #4 Transfer protocol

A project log for eeprog

An ATmega328-powered programmer for 28C64 EEPROM

tobias-erikssonTobias Eriksson 01/25/2017 at 09:480 Comments

It's already been well of a year since I last made an update, but I promise the project is not abandoned! Fellow hacker @Erik Bartmann pointed out to me (thank you!) that I had an error in my revision A schematic. It turns out it made the entire circuit very unstable, which means I'll have to make a new revision of the schematic and order new boards. However, I'll leave the details of the schematic update to the next project log.

Last time I worked on the project, I started prototyping a simple graphical user interface in Java. The data itself is sent over a serial interface, so I have the need of a simple transfer protocol. I could use something like XMODEM, but I think it's more fun to make something myself.

I figured I wanted some sort of message passing protocol, so I sketched the following data structure:

The first three data fields make up the header. The magic word is used to identify the start of a message (this is set to 0xBEEF). With this message structure, a message can be at most 262 bytes long, with a maximum payload of 256 bytes. The Message ID is used to decode the payload. After the payload there is a CRC-16 checksum, used to validate the data before potentially writing to the EEPROM. The checksum is calculated on the header and the payload together.

The structure of the payload data depends on the message. With some messages the payload may even be zero-sized. Here's a table of the messages so far (there may be more coming):

Message ID (hex)
Name
DirectionDescription
0x00--Reserved (not used)
0x01EraseTo deviceErase the entire EEPROM
0x02EraseAckTo clientAcknowledge the erase
0x03-0x0F--Reserved (not used)
0x10WriteBlockTo deviceWrite a 64 byte data block to the EEPROM
0x11WriteBlockAckTo clientAcknowledge the block write
0x12-0x1F--Reserved (not used)
0x20ReadBlockTo deviceRead a 64 byte data block from the EEPROM
0x21ReadBlockAnswerTo clientRead response with 64 byte data
0x22-0xFE--Reserved (not used)
0xFF--Reserved (null message)

I'll omit the message details and leave that to the avid source code reader to find out :-)

Discussions