r24132 (https://dev.openwrt.org/ticket/8308) introduced the -n flag for mtd, which is supposed to bypass the erase step. It appears that the logic used to do this is backwards, and that erasing will actually be bypassed unless -n is given. Lots and lots of things will break.
(no_erase) needs to change to (!no_erase). The indentation in the original patch was also wrong (it used spaces in a file that uses tabs), and since a new |if| block was introduced, its contents ought to be reindented too. Index: package/mtd/src/mtd.c =================================================================== --- package/mtd/src/mtd.c (revision 24133) +++ package/mtd/src/mtd.c (working copy) @@ -519,35 +519,34 @@ } /* need to erase the next block before writing data to it */ - if(no_erase) - { - while (w + buflen > e) { - if (!quiet) - fprintf(stderr, "\b\b\b[e]"); + 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; + 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]"); @@ -651,7 +650,7 @@ force = 0; buflen = 0; quiet = 0; - no_erase = 0; + no_erase = 0; while ((ch = getopt(argc, argv, #ifdef FIS_SUPPORT @@ -665,9 +664,9 @@ case 'r': boot = 1; break; - case 'n': - no_erase = 1; - break; + case 'n': + no_erase = 1; + break; case 'j': jffs2file = optarg; break; _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel