* Covardly copy the nanddump() function from the mtd-utils to fix dump functionality

- The new function works like the old rf_extract one, no parameters has
  changed.
- Now a complete dump/restore will be possible.
- Check for badblocks while copying data
- Shows information about the partition

* Better use of query_error_message() for debugging
This commit is contained in:
pancake committed 2007-06-02 02:23:58 +02:00
1 parent 1515b7c7c1
commit f299486ef9
9 files changed
+826 -36

No files matched your search

+23 -16
View File
@@ -20,6 +20,7 @@
#include "main.h"
#include "hash.h"
#include "hexdump.h"
#include <usb.h>
#include <stdio.h>
#include <string.h>
@@ -32,6 +33,26 @@ void check_nolo_order_failed()
exit(1);
}
void query_error_message()
{
/* query error message */
int len = 0;
char nolomsg[2048];
memset(nolomsg, '\0', 2048);
usb_control_msg(dev, 192, 5, 0, 0, nolomsg, 2048, 2000);
nolomsg[2047] = '\0';
printf("\nNOLO says:\n");
if (nolomsg[0] == '\0') {
printf(" (.. silence ..)\n");
} else {
dump_bytes((unsigned char *)nolomsg, 128);
do {
printf(" - %s\n", nolomsg+len);
len+=strlen(nolomsg+len)+1;
} while(nolomsg[len]!='\0');
}
}
void check_nolo_order()
{
int i, xlo = 0;
@@ -100,6 +121,7 @@ void flash_image(char *filename, char *piece, char *version)
//dump_bytes(fquery, 27+vlen);
if (usb_control_msg(dev, CMD_WRITE, request, 0, 0, (char *)fquery, 27+vlen, 2000) <0) {
query_error_message();
perror("flash_image.header");
exit(1);
}
@@ -124,22 +146,7 @@ void flash_image(char *filename, char *piece, char *version)
printf("WARNING: Oops wrong read %d vs %d \n", bread, bsize);
bread = usb_bulk_write(dev, 2, buf, bsize, 5000);
if (bread == 64) {
/* query error message */
int len = 0;
char nolomsg[2048];
memset(nolomsg, '\0', 2048);
usb_control_msg(dev, 192, 5, 0, 0, nolomsg, 2048, 2000);
nolomsg[2047] = '\0';
printf("\nNOLO says:\n");
if (nolomsg[0] == '\0') {
printf(" (.. silence ..)\n");
} else {
dump_bytes(nolomsg, 128);
do {
printf(" - %s\n", nolomsg+len);
len+=strlen(nolomsg+len)+1;
} while(nolomsg[len]!='\0');
}
query_error_message();
fclose(fd);
return;
}