diff options
author | Ollie Lho <ollie@sis.com.tw> | 2004-12-08 20:10:01 +0000 |
---|---|---|
committer | Ollie Lho <ollie@sis.com.tw> | 2004-12-08 20:10:01 +0000 |
commit | efa28589b1c2c402e62c8d5b1e32e5e45b164c2d (patch) | |
tree | 745e579906240cfce9f3f6bca9b1d5e63630289e /flash_rom.c | |
parent | 1b8b66000f6c8f18193cd93fff1e852faaa9715f (diff) | |
download | ast2050-flashrom-efa28589b1c2c402e62c8d5b1e32e5e45b164c2d.zip ast2050-flashrom-efa28589b1c2c402e62c8d5b1e32e5e45b164c2d.tar.gz |
Add -E option for chip erase, remove duplicated code
Corresponding to flashrom svn r30 and coreboot v2 svn r1815.
Diffstat (limited to 'flash_rom.c')
-rw-r--r-- | flash_rom.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/flash_rom.c b/flash_rom.c index bf338cc..35a9f50 100644 --- a/flash_rom.c +++ b/flash_rom.c @@ -194,7 +194,8 @@ int main(int argc, char *argv[]) FILE *image; struct flashchip *flash; int opt; - int read_it = 0, write_it = 0, verify_it = 0, verbose = 0; + int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0, + verbose = 0; char *filename = NULL; @@ -211,7 +212,7 @@ int main(int argc, char *argv[]) setbuf(stdout, NULL); - while ((opt = getopt(argc, argv, "rwvVc:s:e:")) != EOF) { + while ((opt = getopt(argc, argv, "rwvVEc:s:e:")) != EOF) { switch (opt) { case 'r': read_it = 1; @@ -228,6 +229,9 @@ int main(int argc, char *argv[]) case 'V': verbose = 1; break; + case 'E': + erase_it = 1; + break; case 's': tempstr = strdup(optarg); sscanf(tempstr,"%x",&exclude_start_position); @@ -266,14 +270,18 @@ int main(int argc, char *argv[]) } printf("Part is %s\n", flash->name); - if (!filename) { + if (!filename && !erase_it) { printf("OK, only ENABLING flash write, but NOT FLASHING\n"); return 0; } size = flash->total_size * 1024; buf = (char *) calloc(size, sizeof(char)); - if (read_it) { + if (erase_it) { + printf("Erasing flash chip\n"); + flash->erase(flash); + exit(0); + } else if (read_it) { if ((image = fopen(filename, "w")) == NULL) { perror(filename); exit(1); |