X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=blobdiff_plain;f=package%2Fmtd%2Fsrc%2Fmtd.c;h=5ec79dce0f53ce1ab45ce36c0d432f7039bd336c;hp=b2d760e84f087dae03a42d8fc01c9bd390da0cee;hb=22130190cf11066e00519e1635b1f45882bae4ca;hpb=bc9aa2518d451ef74d150a515cedc26cebad0c2d diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c index b2d760e84f..5ec79dce0f 100644 --- a/package/mtd/src/mtd.c +++ b/package/mtd/src/mtd.c @@ -74,6 +74,7 @@ static char *imagefile = NULL; static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR; static int buflen = 0; int quiet; +int no_erase; int mtdsize = 0; int erasesize = 0; @@ -518,32 +519,35 @@ resume: } /* need to erase the next block before writing data to it */ - 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); } - 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); } - } - /* erase the chunk */ - e += erasesize; - } + /* erase the chunk */ + e += erasesize; + } + } if (!quiet) fprintf(stderr, "\b\b\b[w]"); @@ -595,6 +599,7 @@ static void usage(void) "Following options are available:\n" " -q quiet mode (once: no [w] on writing,\n" " twice: no status messages)\n" + " -n write without first erasing the blocks\n" " -r reboot after successful command\n" " -f force write without trx checks\n" " -e erase before executing the command\n" @@ -646,12 +651,13 @@ int main (int argc, char **argv) force = 0; buflen = 0; quiet = 0; + no_erase = 0; while ((ch = getopt(argc, argv, #ifdef FIS_SUPPORT "F:" #endif - "frqe:d:j:o:")) != -1) + "frnqe:d:j:o:")) != -1) switch (ch) { case 'f': force = 1; @@ -659,6 +665,9 @@ int main (int argc, char **argv) case 'r': boot = 1; break; + case 'n': + no_erase = 1; + break; case 'j': jffs2file = optarg; break;