Nand flash driver for bcm47xx wnr3500lv2

Hello,

I have spent some time making the WNR5300LV2 work with @a.limousin.

Since the DD-WRT version is (partialy) working I started from there. The Idea was to use the DD-WRT's 3.10 Kernel withing the build of the last OpenWRT.

Once the external kernel build succeed, the nand support has been tested by loading the system with an initrd in order to have common tools: ash, network support. On this first step the nandflash driver has been tested.

Some configuration after, OpenWRT did boot the nand over the squashfs generated, on this step I have been able to check the full support for Network, Wifi, LED.

To go further, I needed to have a the ability to store the configuration. I patched the kernel 3.10 with overlayfs and rename the MTD partition accordingly in order to have the overlay partition configure at startup.

At this point the system was stable but the write partition still was on tmpfs. The nandflash driver do not manage the OOB metadata require to have a jffs2 partition on the NAND for the overlayfs.

Since then I have been looking the brcmnand_47xx.c driver, that was not working for read.
I finally found something that make the driver working:

diff --git a/src/linux/universal/linux-3.10/drivers/mtd/bcm947xx/nand/brcmnand_47xx.c b/src/linux/universal/linux-3.10/drivers/mtd/bcm947xx/nand/brcmnand_47xx.c
index 996dbf0..7538051 100644
--- a/src/linux/universal/linux-3.10/drivers/mtd/bcm947xx/nand/brcmnand_47xx.c
+++ b/src/linux/universal/linux-3.10/drivers/mtd/bcm947xx/nand/brcmnand_47xx.c
@@ -783,7 +785,7 @@ brcmnand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_c
 
        ret = brcmnand_do_read_ops(mtd, from, &chip->ops);
 
-       *retlen = ops.retlen;
+       *retlen = chip->ops.retlen;
 
        brcmnand_release_device(mtd);

After that I have been able to create a partition on the brcmnand driver in order to have the rootfs_data with OOB and jffs2.

For now I am stuck with this issue : JFFS2 driver writes some information on the OOB, like the magic bitmask: 0x19 0x85, but they do not appear on the nand data itself. Unfortunately the mount_root binary is looking for the magic bitmask on the data.

In order to try a bit further, I tweaked the mount_root binary to accept 0xFFFFFFFF data as JFFS2, This has given some result for testing but it is not stable as the JFFS2 gets CRC errors, and sometime goes on infinite loop and the board reboot.

[   14.870000] jffs2: error: (807) jffs2_do_read_inode_internal: CRC failed for read_inode of inode 120 at physical 0
[   14.880000] jffs2: Returned error for crccheck of ino #120. Expect badness...

I am missing some knowledge on OOB NAND driver and JFFS2. The firmware from netgear has a JFFS2 partition when I boot from it, so there must be something missing somewhere.

This is a small summary, I can give more details, just ask.

Regards,