On 02/25/2012 07:13 AM, Bastian Bittorf wrote:
Remembering the old days, where we had floppy-drives?
Now we have MTD. sad but true, in case of any error during
sysupgrade regarding mtd, there are no further checks
and we are f*cked:
###
Performing system upgrade...
Unlocking linux ...
Writing from<stdin> to linux ... [e]MTD do_erase_oneblock():
software
timeout
This has frustrated me too. I don't know what the root
cause is, but what I have seen is that the mtd utility
needs to retry sometimes, and that [e] condition
is a temporary "Out of memory" error. At least, on ar71xx.
Here's what I did:
Index: src/mtd.c
===================================================================
--- src/mtd.c (revision 30710)
+++ src/mtd.c (working copy)
@@ -462,16 +462,21 @@
if (!quiet)
fprintf(stderr, "\b\b\b[w]");
- if ((result = write(fd, buf + offset, buflen)) < buflen) {
- if (result < 0) {
- fprintf(stderr, "Error writing image.\n");
- exit(1);
- } else {
- fprintf(stderr, "Insufficient space.\n");
- exit(1);
- }
- }
- w += buflen;
+ int try;
+ for (try = 0; try < 3; try++) {
+ if ((result = write(fd, buf + offset, buflen)) < buflen) {
+ if (result < 0) {
+ fprintf(stderr, "Error writing image: %s (try %d of 3).\n",
strerror(errno), try + 1);
+ if (try < 2) continue;
+ exit(1);
+ } else {
+ fprintf(stderr, "Insufficient space.\n");
+ exit(1);
+ }
+ }
+ w += buflen;
+ break;
+ }
I have seen this fail once, twice, and then still succeed. But this
doesn't solve the root cause, and I think I'm still seeing complete
failures here on occasion. This just significantly mitigates it.
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel