/* Read ManId */
trbcmd = 0x9f << 24;
- if (sendCommand(trb_address, trbcmd, 3) == -1) {
+ if (sendCommand(trb_address, trbcmd, 2) == -1) {
return -1;
}
unsigned int id;
int accepted = -1;
for (id = 0; id < NUM_MAN_IDS; id++) {
- if (trbBuffer[i + 1] == manId[id]) {
+ if ((trbBuffer[i + 1] & 0x00ffffff) == manId[id]) {
accepted = 0;
break;
}
{
unsigned int block;
int status;
- int success = 0;
+ int errorCtr = 0;
unsigned int i;
unsigned int page;
int bytesWritten = size;
}
fprintf(stderr, "Block: 0 1 2 3 4 5 6 7 8 9 A B C D E F");
- success = 0;
+ errorCtr = 0;
for (block = 0; (block < NUM_BLOCKS) && (bytesWritten > 0); block++) {
int error = 0;
if (block % 16 == 0) {
for (c = 0; c < bytes; c++) {
if (pageBuffer[endPoint][c] != imageBuffer[page * PAGE_SIZE + c]) {
error = -1;
+ errorCtr++;
fprintf(logFile,
- "Error > program: verify failed for page #%d, byte #%d "
- "of EndPoint 0x%04x\n",
- page, c, pageBufferAddress[endPoint]);
-
+ "verify failed page #%d, byte #%d "
+ "(exp: 0x%02x rec: 0x%02x), EndPoint: 0x%04x\n",
+ page, c,
+ imageBuffer[page * PAGE_SIZE + c],
+ pageBuffer[endPoint][c],
+ pageBufferAddress[endPoint]);
}
}
}
fprintf(stderr, "@ ");
} else {
fprintf(stderr, "X ");
- success = -1;
}
}
- if (success == 0) {
+ if (errorCtr == 0) {
fprintf(stderr, "\n\nSuccess\n\n");
} else {
- fprintf(stderr, "\n\nErrors have occured, see logFile %s for details\n\n",
- logFileName);
+ fprintf(stderr,
+ "\n\n%d Errors have occured, see logFile %s for details\n\n",
+ errorCtr, logFileName);
}
- return success;
+ return errorCtr == 0 ? 0 : -1;
}
printf("Options:\n");
printf(" -h give this help\n");
printf("\nCommands:\n");
- printf(" program <trbaddress> <binFile> -> \n");
- printf(" verify <trbaddress> <binFile> -> \n");
- printf(" backup <trbaddress> <rawFile> -> \n");
- printf(" restore <trbaddress> <rawFile> -> \n");
+ printf(" program <trbaddress> <bit-file> -> \n");
+ printf(" verify <trbaddress> <bit-file> -> \n");
+ printf(" backup <trbaddress> <raw-file> -> \n");
+ printf(" restore <trbaddress> <raw-file> -> \n");
printf(" dumppage <trbaddress> pagenumber -> \n");
}
int main(int argc, char ** argv)
{
- /*
- uint32_t page[PAGE_SIZE];
- sigset_t blockSet;
- */
unsigned int i;
trb_debug = 0;