With the BRCM47xx image I have built (Linksys E3000), there are additional
writes following the completion of "mtd_replace_jffs2" which invalidate the
'trx_fixup' performed by 'mtd_replace_jffs2'.  Moving the 'trx_fixup' to 
somewhere
after all writes have completed fixes the problem.  I also noticed that 
'erasesize'
used to compute 'block_offset' in 'mtd_fixtrx' is used before it is computed by
'mtd_check_open'; moving the call to 'mtd_check_open' up a few lines fixes this.

Unlike 'mtd_fixtrx', 'trx_fixup' appears to assume that the TRX header is 
always at
offset 0; which may be the cause of the problem described in Ticket #8960.

If this patch is OK; I could submit a similar patch for backfire if someone 
wants it;
might be a day or two though.

Signed-off-by: Nathan Hintz <[email protected]>

Index: trunk/package/mtd/src/mtd.c
===================================================================
--- trunk/package/mtd/src/mtd.c (revision 29357)
+++ trunk/package/mtd/src/mtd.c (working copy)
@@ -473,6 +473,10 @@
                offset = 0;
        }
 
+       if (trx_fixup) {
+               trx_fixup(fd, mtd);
+       }
+
        if (!quiet)
                fprintf(stderr, "\b\b\b\b    ");
 
Index: trunk/package/mtd/src/jffs2.c
===================================================================
--- trunk/package/mtd/src/jffs2.c       (revision 29357)
+++ trunk/package/mtd/src/jffs2.c       (working copy)
@@ -244,9 +244,6 @@
        pad(erasesize);
        free(buf);
 
-       if (trx_fixup) {
-         trx_fixup(outfd, mtd);
-       }
        return (mtdofs - ofs);
 }
 
Index: trunk/package/mtd/src/trx.c
===================================================================
--- trunk/package/mtd/src/trx.c (revision 29357)
+++ trunk/package/mtd/src/trx.c (working copy)
@@ -154,15 +154,15 @@
        if (quiet < 2)
                fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", 
mtd, offset);
 
-       block_offset = offset & ~(erasesize - 1);
-       offset -= block_offset;
-
        fd = mtd_check_open(mtd);
        if(fd < 0) {
                fprintf(stderr, "Could not open mtd device: %s\n", mtd);
                exit(1);
        }
 
+       block_offset = offset & ~(erasesize - 1);
+       offset -= block_offset;
+
        if (block_offset + erasesize > mtdsize) {
                fprintf(stderr, "Offset too large, device size 0x%x\n", 
mtdsize);
                exit(1);
Index: trunk/package/mtd/Makefile
===================================================================
--- trunk/package/mtd/Makefile  (revision 29357)
+++ trunk/package/mtd/Makefile  (working copy)
@@ -9,7 +9,7 @@
 include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=mtd
-PKG_RELEASE:=17
+PKG_RELEASE:=18
 
 PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
 STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to