forked from Apple-2-HW/TommyPROM
Add some high-level commands to HardwareVerify sketch
This commit is contained in:
parent
6d9a958907
commit
ba77cc336b
@ -139,6 +139,145 @@ void printWord(word w)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void zapTest(uint32_t start)
|
||||||
|
{
|
||||||
|
byte testData[] =
|
||||||
|
{
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
|
||||||
|
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
|
||||||
|
0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe,
|
||||||
|
0x00, 0xff, 0x55, 0xaa, '0', '1', '2', '3'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!prom.writeData(testData, sizeof(testData), start))
|
||||||
|
{
|
||||||
|
Serial.println("Write failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(100);
|
||||||
|
for (unsigned ix = 0; ix < sizeof(testData); ix++)
|
||||||
|
{
|
||||||
|
byte val = prom.readData(start + ix);
|
||||||
|
if (val != testData[ix])
|
||||||
|
{
|
||||||
|
Serial.print(F("Verify failed, addr="));
|
||||||
|
Serial.print(start + ix, HEX);
|
||||||
|
Serial.print(F(", read="));
|
||||||
|
Serial.print(val, HEX);
|
||||||
|
Serial.print(F(", expected="));
|
||||||
|
Serial.println(testData[ix], HEX);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Serial.println("Write test successful");
|
||||||
|
}
|
||||||
|
|
||||||
|
void pokeBytes(char * pCursor)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
uint32_t start;
|
||||||
|
unsigned byteCtr = 0;
|
||||||
|
|
||||||
|
enum { BLOCK_SIZE = 32 };
|
||||||
|
byte data[BLOCK_SIZE];
|
||||||
|
|
||||||
|
//first value returned is the starting address
|
||||||
|
start = getHex32(pCursor, 0);
|
||||||
|
|
||||||
|
while (((val = getHex32(pCursor, 0xffff)) != 0xffff) && (byteCtr < BLOCK_SIZE))
|
||||||
|
{
|
||||||
|
data[byteCtr++] = byte(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (byteCtr > 0)
|
||||||
|
{
|
||||||
|
if (!prom.writeData(data, byteCtr, start))
|
||||||
|
{
|
||||||
|
Serial.println(F("Write failed"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.println(F("Missing address or data"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
for (unsigned ix = 0; ix < byteCtr ; ix++)
|
||||||
|
{
|
||||||
|
byte val = prom.readData(start + ix);
|
||||||
|
if (val != data[ix])
|
||||||
|
{
|
||||||
|
Serial.print(F("Verify failed, addr="));
|
||||||
|
Serial.print(start + ix, HEX);
|
||||||
|
Serial.print(F(", read="));
|
||||||
|
Serial.print(val, HEX);
|
||||||
|
Serial.print(F(", expected="));
|
||||||
|
Serial.println(data[ix], HEX);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Serial.println("Poke successful");
|
||||||
|
}
|
||||||
|
|
||||||
|
void dumpBlock(uint32_t start, uint32_t end)
|
||||||
|
{
|
||||||
|
char line[81];
|
||||||
|
// 01234567891 234567892 234567893 234567894 234567895 234567896 234567897 23456789
|
||||||
|
// 01234: 01 23 45 67 89 ab cf ef 01 23 45 67 89 ab cd ef 1.2.3.4. 5.6.7.8.
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
memset(line, ' ', sizeof(line));
|
||||||
|
|
||||||
|
char * pHex = line;
|
||||||
|
char * pChar = line + 59;
|
||||||
|
for (uint32_t addr = start; (addr <= end); addr++)
|
||||||
|
{
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
//print out the address at the beginning of the line
|
||||||
|
pHex = line;
|
||||||
|
pChar = line + 59;
|
||||||
|
*pHex++ = hex[(addr >> 16) & 0x0f];
|
||||||
|
*pHex++ = hex[(addr >> 12) & 0x0f];
|
||||||
|
*pHex++ = hex[(addr >> 8) & 0x0f];
|
||||||
|
*pHex++ = hex[(addr >> 4) & 0x0f];
|
||||||
|
*pHex++ = hex[(addr) & 0x0f];
|
||||||
|
*pHex++ = ':';
|
||||||
|
*pHex++ = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
byte data = prom.readData(addr);
|
||||||
|
*pHex++ = hex[data >> 4];
|
||||||
|
*pHex++ = hex[data & 0x0f];
|
||||||
|
*pHex++ = ' ';
|
||||||
|
*pChar++ = ((data < 32) | (data >= 127)) ? '.' : data;
|
||||||
|
|
||||||
|
if ((count & 3) == 3)
|
||||||
|
{
|
||||||
|
*pHex++ = ' ';
|
||||||
|
}
|
||||||
|
if ((count & 7) == 7)
|
||||||
|
{
|
||||||
|
*pChar++ = ' ';
|
||||||
|
}
|
||||||
|
if ((++count >= 16) || (addr == end))
|
||||||
|
{
|
||||||
|
*pChar = '\0';
|
||||||
|
Serial.println(line);
|
||||||
|
memset(line, ' ', sizeof(line));
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************
|
/************************************************
|
||||||
* MAIN
|
* MAIN
|
||||||
*************************************************/
|
*************************************************/
|
||||||
@ -164,11 +303,12 @@ static void commandLoop()
|
|||||||
byte b;
|
byte b;
|
||||||
uint32_t arg;
|
uint32_t arg;
|
||||||
const uint32_t noValue = uint32_t(-1);
|
const uint32_t noValue = uint32_t(-1);
|
||||||
char line[20];
|
char line[120];
|
||||||
char * cursor = line + 1;
|
char * cursor = line + 1;
|
||||||
unsigned long timeStart;
|
unsigned long timeStart;
|
||||||
unsigned long timeEnd;
|
unsigned long timeEnd;
|
||||||
bool cmdError = false;
|
bool cmdError = false;
|
||||||
|
bool unknownCmd = false;
|
||||||
|
|
||||||
Serial.print("\n#");
|
Serial.print("\n#");
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
@ -249,23 +389,51 @@ static void commandLoop()
|
|||||||
Serial.println(timeEnd - timeStart);
|
Serial.println(timeEnd - timeStart);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'p':
|
||||||
|
pokeBytes(line+1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
if ((arg = getHex32(cursor, noValue)) != noValue)
|
||||||
|
{
|
||||||
|
dumpBlock(arg, arg + 63);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cmdError = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'z':
|
||||||
|
if ((arg = getHex32(cursor, noValue)) != noValue)
|
||||||
|
{
|
||||||
|
zapTest(arg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cmdError = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cmdError = true;
|
unknownCmd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmdError) {
|
if (cmdError) {
|
||||||
|
Serial.println(F("Missing or invalid command argument"));
|
||||||
|
} else if (unknownCmd) {
|
||||||
Serial.print(F("Hardware Verifier - "));
|
Serial.print(F("Hardware Verifier - "));
|
||||||
Serial.println(prom.getName());
|
Serial.println(prom.getName());
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(F("Valid commands are:"));
|
Serial.println(F("Valid commands are:"));
|
||||||
Serial.println(F(" Axxxx - Set address bus to xxxx"));
|
Serial.println(F(" Axxxx - Set address bus to xxxx"));
|
||||||
Serial.println(F(" Dxx - Set Data bus to xx"));
|
Serial.println(F(" Dxx - Set Data bus to xx"));
|
||||||
Serial.println(F(" Cs - Set Chip enable to state (e=enable, d=disable)"));
|
Serial.println(F(" Cs - Set Chip enable to state (e=enable, d=disable)"));
|
||||||
Serial.println(F(" Os - Set Output enable to state (e=enable, d=disable)"));
|
Serial.println(F(" Os - Set Output enable to state (e=enable, d=disable)"));
|
||||||
Serial.println(F(" Ws - Set Write enable to state (e=enable, d=disable)"));
|
Serial.println(F(" Ws - Set Write enable to state (e=enable, d=disable)"));
|
||||||
Serial.println(F(" R - Read and print the value on the data bus"));
|
Serial.println(F(" R - Read and print the value on the data bus"));
|
||||||
Serial.println(F(" L - Send Lock sequence to enable device Software Data Protection"));
|
Serial.println(F(" L - Send Lock sequence to enable device Software Data Protection"));
|
||||||
Serial.println(F(" U - Send Unlock sequence to disable device Software Data Protection"));
|
Serial.println(F(" U - Send Unlock sequence to disable device Software Data Protection"));
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println(F(" Pxxxx dd dd... - Poke (write) values to EEPROM (up to 32 values)"));
|
||||||
|
Serial.println(F(" Sxxxx - Show (dump) bytes from EEPROM to terminal"));
|
||||||
|
Serial.println(F(" Zxxxx - Zap (burn) a 32 byte test pattern"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user