From: hadaq Date: Mon, 31 Aug 2009 17:45:26 +0000 (+0000) Subject: . X-Git-Tag: v6.0~386 X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=4b0c674a76ba50fe31f90986a8fae6c5e6f75fba;p=trbnettools.git . --- diff --git a/trbrich/trbflash.c b/trbrich/trbflash.c index 0265703..3a31014 100644 --- a/trbrich/trbflash.c +++ b/trbrich/trbflash.c @@ -400,7 +400,7 @@ static int checkManId(uint16_t trb_address) /* Read ManId */ trbcmd = 0x9f << 24; - if (sendCommand(trb_address, trbcmd, 3) == -1) { + if (sendCommand(trb_address, trbcmd, 2) == -1) { return -1; } @@ -420,7 +420,7 @@ static int checkManId(uint16_t trb_address) 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; } @@ -441,7 +441,7 @@ static int programImageBuffer(uint16_t trb_address, unsigned int size, { unsigned int block; int status; - int success = 0; + int errorCtr = 0; unsigned int i; unsigned int page; int bytesWritten = size; @@ -468,7 +468,7 @@ static int programImageBuffer(uint16_t trb_address, unsigned int 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) { @@ -569,11 +569,14 @@ static int programImageBuffer(uint16_t trb_address, unsigned int size, 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]); } } } @@ -585,17 +588,17 @@ static int programImageBuffer(uint16_t trb_address, unsigned int size, 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; } @@ -676,19 +679,15 @@ void usage(const char *progName) printf("Options:\n"); printf(" -h give this help\n"); printf("\nCommands:\n"); - printf(" program -> \n"); - printf(" verify -> \n"); - printf(" backup -> \n"); - printf(" restore -> \n"); + printf(" program -> \n"); + printf(" verify -> \n"); + printf(" backup -> \n"); + printf(" restore -> \n"); printf(" dumppage pagenumber -> \n"); } int main(int argc, char ** argv) { - /* - uint32_t page[PAGE_SIZE]; - sigset_t blockSet; - */ unsigned int i; trb_debug = 0;