diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/flash.c | 40 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/main.h | 4 | ||||
-rw-r--r-- | src/qmode.c | 4 |
4 files changed, 29 insertions, 21 deletions
diff --git a/src/flash.c b/src/flash.c index a201a81..503fa40 100644 --- a/src/flash.c +++ b/src/flash.c @@ -23,6 +23,8 @@ #include <string.h> #include <stdlib.h> +#include "image.h" + /*void check_nolo_order_failed() { fprintf(stderr, "\nERROR: Provide xloader before the secondary. NOLO disagrees anything else.\n"); @@ -73,9 +75,9 @@ void query_error_message() check_nolo_order_failed(); }*/ -void flash_image(const char *filename, const char *piece, const char *device, const char *hwrevs, const char *version) +void flash_image(struct image * image) { - FILE *fd; +// FILE *fd; int vlen = 0; int request; /*/ n800 flash queries have a variable size */ @@ -83,17 +85,19 @@ void flash_image(const char *filename, const char *piece, const char *device, co unsigned long long size, off; unsigned char bsize[4], tmp; unsigned char nolofiller[128]; - ushort hash = 0; //do_hash_file(filename, piece); + const char * piece = image_type_to_string(image->type); + const char * version = image->version; + ushort hash = image->hash; - if (piece == NULL) { +// if (piece == NULL) { //exit(1); - piece = fpid_file(filename); +// piece = fpid_file(filename); if (piece == NULL) { printf("Unknown piece type\n"); return; } - printf("Piece type: %s\n", piece); - } +// printf("Piece type: %s\n", piece); +// } /* if (piece != NULL) { if (!strcmp(piece, "fiasco")) { @@ -105,11 +109,11 @@ void flash_image(const char *filename, const char *piece, const char *device, co if (version) vlen = strlen(version)+1; - fd = fopen(filename, "rb"); - if (fd == NULL) { - printf("Cannot open file\n"); - exit(1); - } +// fd = fopen(filename, "rb"); +// if (fd == NULL) { +// printf("Cannot open file\n"); +// exit(1); +// } /* cook flash query */ memset(fquery, '\x00', 27); // reset buffer memcpy(fquery, "\x2e\x19\x01\x01", 4); // header @@ -119,7 +123,8 @@ void flash_image(const char *filename, const char *piece, const char *device, co memcpy(fquery+7, piece, strlen(piece)); // XXX ??!?? printf("| hash: 0x%hhx%hhx ", fquery[5], fquery[6]); - size = get_file_size(filename); +// size = get_file_size(filename); + size = image->size; bsize[0] = (size & 0xff000000) >> 24; bsize[1] = (size & 0x00ff0000) >> 16; bsize[2] = (size & 0x0000ff00) >> 8; @@ -157,25 +162,26 @@ void flash_image(const char *filename, const char *piece, const char *device, co char buf[BSIZE]; int bread, bsize = size-off; if (bsize>BSIZE) bsize = BSIZE; - bread = fread(buf, bsize, 1, fd); +// bread = fread(buf, bsize, 1, fd); + bread = image_read(image, buf, bsize); if (bread != 1) 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(); - fclose(fd); +// fclose(fd); return; } progressbar(off, size); if (bread<0) { printf("\n"); perror(" -ee- "); - fclose(fd); +// fclose(fd); return; } fflush(stdout); } - fclose(fd); +// fclose(fd); /*/ EOF */ usb_bulk_write(dev, 2, (char *)nolofiller, 0, 1000); progressbar(1, 1); @@ -584,7 +584,7 @@ int main(int argc, char **argv) for(c=0;c<pcs_n;c++) { printf("Flashing %s (%s)\n", pcs[c].type, pcs[c].name); - flash_image(pcs[c].name, pcs[c].type, pcs[c].device, pcs[c].hwrevs, pcs[c].version); +// flash_image(pcs[c].name, pcs[c].type, pcs[c].device, pcs[c].hwrevs, pcs[c].version); } } @@ -16,10 +16,12 @@ extern char strbuf[1024]; // Forward declaration for use in function arguments. //struct devices; +struct image; int queue_mode(); int reverse_extract_pieces(char *dir); -void flash_image(const char *filename, const char *piece, const char *device, const char *hwrevs, const char *version); +//void flash_image(const char *filename, const char *piece, const char *device, const char *hwrevs, const char *version); +void flash_image(struct image * image); int fiasco_read_image(char *file); //void check_nolo_order(); extern struct usb_dev_handle *dev; diff --git a/src/qmode.c b/src/qmode.c index 64ee94a..c725995 100644 --- a/src/qmode.c +++ b/src/qmode.c @@ -52,12 +52,12 @@ void process_message(char *msg) if (c!=0) { arg[0]='\0'; arg = arg +1; - if (!strcmp(str, "flash")) { +/* if (!strcmp(str, "flash")) { const char *type = fpid_file(arg); if (type == NULL) { squeue_push2(p, "error", "Unknown piece format", 1); } else flash_image(arg, type, NULL, NULL, NULL); - } else + } else*/ if (!strcmp(str, "reset")) { if (reboot_board() == 0) { squeue_push2(p,"info", "Device reboots", 1); |