TomNisbet / TommyPROM

Simple Arduino-based EEPROM programmer
https://tomnisbet.github.io/TommyPROM/
143 stars 29 forks source link

Suggested enhancement #12

Closed aemiller51 closed 4 years ago

aemiller51 commented 4 years ago

Thanks for the EEPROM programmer design and code Tom. After a couple of hours debugging my vero board implementation it seems to be working quite nicely.

Sometimes I only need to write a few bytes to an EEPROM, usually to fix a bug in a subroutine, so I wrote a new command POKE, PSSSS BB BB BB.. up to BLOCK_SIZE bytes. I mostly copied existing code from the fillBlock Command but I am struggling with how to test for the end of the command line. Using *_while ((byteString != 0) && (byteCtr < 32))_** cuts off the last argument.

I increased the size of the CLI command line buffer to accomodate this (132 characters) and added a switch to the CLI processing routine.

void pokeBytes(char *& byteString) { uint32_t val; uint32_t start; int byteCtr;

enum { BLOCK_SIZE = 32 }; byte data[BLOCK_SIZE];

//first value returned is the starting address start = getHex32(byteString, 0);

val = getHex32(byteString, 0); byteCtr = 0;

while ((*byteString != 0) && (byteCtr < BLOCK_SIZE)) { data[byteCtr++] = val; val = getHex32(byteString, 0); }

if (!prom.writeData(data, byteCtr, start)) { cmdStatus.error("Write failed"); return; }

delay(100); for (int ix = 0; ix < byteCtr ; ix++) { byte val = prom.readData(start + ix); if (val != data[ix]) { cmdStatus.error("Verify failed"); cmdStatus.setValueHex(0, "addr", start + ix); cmdStatus.setValueHex(1, "read", val); cmdStatus.setValueHex(2, "expected", data[ix]); return; } } cmdStatus.info("Poke successful"); }

F 000 050 FF

D 00 050

00000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00050: ff .

P0000 01 4f 12 06 4c 24 20 0f 00 0c 08 60 72 42 30 38

POKEing bytes into memory

INFO: Poke successful

D 000 050

00000: 01 4f 12 06 4c 24 20 0f 00 0c 08 60 72 42 30 ff .O..L$ . ...`rB0. 00010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00040: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ........ ........ 00050: ff

TomNisbet commented 4 years ago

@aemiller51 - very good! I'm trying to get another project (breadboard computer) posted right now, but I'll revisit this when that is wrapped up - probably next week.

For that project, I developed an eXamine command that allowed interactive listing and modification of single addresses. The interface is like the old 8-bit ROM monitors. You enter an address and are prompted with the current value at the address. If you type 2 hex characters, they are stored and it moves to the next address. A return just skips to the next address, and any other character ends the command. It looks like this:

X0000 0000 FF: 01 0001 FF: 4f 0002 FF: 0003 FF: 06 0004 FF: .

The result would be that the bytes at 0000, 0001, and 0003 are modified.

The downside to this is that it doesn't work well with the Arduino Serial Monitor window because that requires a before any characters are sent to the target. On the other hand, it is really convenient when used with a real terminal. I like your command because it can be used in any terminal environment.

Maybe I'll port them both in and we can take a look.

Thanks for the addition.

TomNisbet commented 4 years ago

I put this on the back-burner and forgot all about it. Checking in a change today that implements the Poke command. Utilized the default value option of getHex32 to fix the problem of the last argument being dropped. Thanks to @aemiller51 for a very useful enhancement to the code!