- while (w + buflen > e) {
- if (!quiet)
- fprintf(stderr, "\b\b\b[e]");
-
-
- if (mtd_erase_block(fd, e) < 0) {
- if (next) {
- if (w < e) {
- write(fd, buf + offset, e - w);
- offset = e - w;
+ if(!no_erase)
+ {
+ while (w + buflen > e) {
+ if (!quiet)
+ fprintf(stderr, "\b\b\b[e]");
+
+
+ if (mtd_erase_block(fd, e) < 0) {
+ if (next) {
+ if (w < e) {
+ write(fd, buf + offset, e - w);
+ offset = e - w;
+ }
+ w = 0;
+ e = 0;
+ close(fd);
+ mtd = next;
+ fprintf(stderr, "\b\b\b \n");
+ goto resume;
+ } else {
+ fprintf(stderr, "Failed to erase block\n");
+ exit(1);