Hello,
A simple patch to use read_flash() when flash chip probe is probed.
Unfortunatelly, I cannot test it... If anyone can do the job for me...
Make good use of it ;-)
Stephan.
Signed-off-by: Stephan Guilloux stephan.guilloux@free.fr Index: flashrom-factorize-read/trunk/flashrom.c =================================================================== --- flashrom-factorize-read/trunk/flashrom.c (révision 546) +++ flashrom-factorize-read/trunk/flashrom.c (copie de travail) @@ -251,6 +251,12 @@ FILE *image; unsigned long size = flash->total_size * 1024; unsigned char *buf = calloc(size, sizeof(char)); + + if (! filename) { + printf("Error: No filename specified.\n"); + return 1; + } + if ((image = fopen(filename, "w")) == NULL) { perror(filename); exit(1); @@ -602,35 +608,10 @@ printf("Run flashrom -L to view the hardware supported in this flashrom version.\n"); exit(1); } - if (!filename) { - printf("Error: No filename specified.\n"); - exit(1); - } - size = flashes[0]->total_size * 1024; - buf = (uint8_t *) calloc(size, sizeof(char)); - - if ((image = fopen(filename, "w")) == NULL) { - perror(filename); - exit(1); - } - printf("Force reading flash... "); - if (!flashes[0]->read) { - printf("FAILED!\n"); - fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n"); + if (read_flash(flashes[0], filename, exclude_start_position, exclude_end_position)) { return 1; - } else - flashes[0]->read(flashes[0], buf); - - if (exclude_end_position - exclude_start_position > 0) - memset(buf + exclude_start_position, 0, - exclude_end_position - - exclude_start_position); - - numbytes = fwrite(buf, 1, size, image); - fclose(image); - printf("%s.\n", numbytes == size ? "done" : "FAILED"); - free(buf); - return numbytes != size; + } + return 0; } // FIXME: flash writes stay enabled! exit(1);
On 26.05.2009 01:10, Stephan GUILLOUX wrote:
A simple patch to use read_flash() when flash chip probe is probed.
Unfortunatelly, I cannot test it... If anyone can do the job for me...
Signed-off-by: Stephan Guilloux stephan.guilloux@free.fr
I recreated your patch from scratch to verify it and our results match.
Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Thanks, committed with some cosetic changes in r563.
Regards, Carl-Daniel