]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
.
authorhadaq <hadaq>
Mon, 31 Aug 2009 17:45:26 +0000 (17:45 +0000)
committerhadaq <hadaq>
Mon, 31 Aug 2009 17:45:26 +0000 (17:45 +0000)
trbrich/trbflash.c

index 0265703eb9710cf7190af7f261ee045b5094e39f..3a3101419973c1ffbbdeec7e7daf8da7ee46f4ef 100644 (file)
@@ -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 <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;