Netgear WNR3500L v2 - 92.7 MB NAND JFFS2 user space - WORKING !!!

Discussion in 'Tomato Firmware' started by VinTheGodfather, Dec 24, 2016.

  1. VinTheGodfather

    VinTheGodfather Network Newbie Member

    Hello to everybody, I want to wish all of you a Merry Christmas that fullfill your hearts of peace and love !!!

    This is my first post on this beautiful and very usefull forum, but I'm following it from weeks ago trying to understand how I can realize my project with these routers (I recently bought 2 pcs. without read very carefully about the features of mod firmwares availables for it).
    In the beginning I thought that every open source compatible router can access to every function offered from mod firmwares, but very quickly I've understand that this isn't true at all !
    After studying over this and other forums (and trying it) I understand that Advanced Tomato is the best mod available for this model of router (lot of thanks to Shibby20 and Jacky444 for it), but also the Tomato mod from Toastman (thanks to you too) is very similar and powerfull (but GUI less attractive).
    Well, my problem with all that mods (I've tried also DD-WRT) is that I need to use a third party software for VPN (Softether VPN) but I can't due to the problem with the NAND management found during the firmware development, reason for the deletion of the NAND JFFS2 feature from all those mods. Yes I can buy and leave forever a USB pen drive (actually at least 8 GB in the market) connected to the router for load only 5.5 MB of software, but I was very upset about the availability of the memory space and the problems using it.
    Continuing my studies I've tried to load latest stock firmware from Netgear (V1.2.0.34_40.0.75) and with all my surprise I see (using USB-serial cable attached to router's serial jumper) that it load an MTD partion called "brcmnand" with JFFS2 filesystem and 95 MB available space mounted on /tmp/media/nand folder !
    So I tried to build and modify the advanced tomato source code for reach the same result but I can't.
    As I understand the problem is that in the linux version used for tomato mod version RT-N (src-rt folder) is not present the configuration option MTD_BRCMNAND due to the lack of the driver located in linux\linux-2.6\drivers\mtd\47xxnand folder, which is present in the stock firmware source code and also in the tomato mod versions RT-AC (src-rt-6.x folder).
    I've tried to compile RT-AC version using
    Code:
    make e MIPS32=r2 WNR3500LV2=1 NAND=y
    but the firmware brick the router on start, also I've tried to replace all the mtd driver folder from RT-AC to RT-N version but compile return errors.
    If someone are interested in this feature and want to help me with that problem it will be greatly appreciated.
    Sorry for the long post and for my english but I wanted to well explain the situation and english is not my primary language. Thanks !!!

    Vin

    P.S.: Another solution for my situation is adding the Softether VPN software to the firmware but I still can't understand how to do it in a simple way.

    EDIT 29th December, 2016:

    Hello to everybody,

    Finally I did it !!!!

    Now the JFFS is working fine and give you 92.7 MB free space:

    [​IMG]
    [​IMG]
    [​IMG]

    Try it !! ;)

    Advanced Tomato v.3.4-138 WNR3500Lv2 JFFS-VPN

    Vin
     
    Last edited: Dec 29, 2016
  2. VinTheGodfather

    VinTheGodfather Network Newbie Member

    deleted
     
    Last edited: Dec 29, 2016
  3. VinTheGodfather

    VinTheGodfather Network Newbie Member

  4. slodki

    slodki LI Guru Member

    Merged, recompiled and flashed.

    Booting:
    Code:
    Jan  1 01:00:11 rt user.warn kernel: Found a Samsung NAND flash with 2048B pages or 128KB blocks; total size 128MB
    Jan  1 01:00:11 rt user.warn kernel: Boot partition size = 524288(0x80000)
    Jan  1 01:00:11 rt user.warn kernel: lookup_nflash_rootfs_offset: offset = 0x500000
    Jan  1 01:00:11 rt user.notice kernel: nflash: squash filesystem with lzma found at block 49
    Jan  1 01:00:11 rt user.notice kernel: Creating 16 MTD partitions on "nflash":
    Jan  1 01:00:11 rt user.notice kernel: 0x00000000-0x00080000 : "boot"
    Jan  1 01:00:11 rt user.notice kernel: 0x00080000-0x00200000 : "nvram"
    Jan  1 01:00:11 rt user.notice kernel: 0x00200000-0x00240000 : "board_data"
    Jan  1 01:00:11 rt user.notice kernel: 0x00240000-0x00280000 : "POT1"
    Jan  1 01:00:11 rt user.notice kernel: 0x00280000-0x002c0000 : "POT2"
    Jan  1 01:00:11 rt user.notice kernel: 0x002c0000-0x00300000 : "T_Meter1"
    Jan  1 01:00:11 rt user.notice kernel: 0x00300000-0x00340000 : "T_Meter2"
    Jan  1 01:00:12 rt user.notice kernel: 0x00340000-0x00380000 : "ML1"
    Jan  1 01:00:12 rt user.notice kernel: 0x00380000-0x003c0000 : "ML2"
    Jan  1 01:00:12 rt user.notice kernel: 0x003c0000-0x00400000 : "ML3"
    Jan  1 01:00:12 rt user.notice kernel: 0x00400000-0x00440000 : "ML4"
    Jan  1 01:00:12 rt user.notice kernel: 0x00440000-0x00480000 : "ML5"
    Jan  1 01:00:12 rt user.notice kernel: 0x00480000-0x004c0000 : "ML6"
    Jan  1 01:00:12 rt user.notice kernel: 0x004c0000-0x00500000 : "ML7"
    Jan  1 01:00:12 rt user.notice kernel: 0x00500000-0x02000000 : "linux"
    Jan  1 01:00:12 rt user.notice kernel: 0x0062d16c-0x02000000 : "rootfs"
    Jan  1 01:00:12 rt user.debug kernel: Bad block table found at page 65472, version 0x01
    Jan  1 01:00:12 rt user.debug kernel: Bad block table found at page 65408, version 0x01
    Jan  1 01:00:12 rt user.debug kernel: nand_read_bbt: Bad block at 0x020a0000
    Jan  1 01:00:12 rt user.warn kernel: nand_read_bbt: Bad block at 0x020a0000
    Jan  1 01:00:12 rt user.debug kernel: nand_read_bbt: Bad block at 0x029c0000
    Jan  1 01:00:12 rt user.warn kernel: nand_read_bbt: Bad block at 0x029c0000
    Jan  1 01:00:12 rt user.debug kernel: nand_read_bbt: Bad block at 0x04740000
    Jan  1 01:00:12 rt user.warn kernel: nand_read_bbt: Bad block at 0x04740000
    Jan  1 01:00:12 rt user.notice kernel: Creating 1 MTD partitions on "brcmnand":
    Jan  1 01:00:12 rt user.notice kernel: 0x02000000-0x07f00000 : "brcmnand"
    Jan  1 01:00:12 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x020a0000: (block 261) 0x03
    Jan  1 01:00:12 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x029c0000: (block 334) 0x03
    Jan  1 01:00:12 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x04740000: (block 570) 0x03
    
    When trying to format from GUI:
    Code:
    Feb 17 17:00:35 rt user.info init[1]: notice[jffs]: Stopped
    Feb 17 17:00:39 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x020a0000: (block 261) 0x03
    Feb 17 17:00:39 rt user.warn kernel: nand_erase: attempt to erase a bad block at page 0x00004140
    Feb 17 17:00:40 rt user.info init[1]: notice[jffs]: Error formatting JFFS. Check the logs to see if they contain more details about this error.
    
    Format was not successful. But after enabling from GUI jffs was mounted:
    Code:
    Feb 17 17:04:25 rt user.info init[1]: notice[jffs]: Stopped
    Feb 17 17:04:30 rt user.info kernel: JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
    Feb 17 17:04:30 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x020a0000: (block 261) 0x03
    Feb 17 17:04:30 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x029c0000: (block 334) 0x03
    Feb 17 17:04:31 rt user.warn kernel: brcmnand_isbad_bbt(): bbt info for offs 0x04740000: (block 570) 0x03
    Feb 17 17:04:43 rt user.info init[1]: notice[jffs]: Loaded
    
    And there was about 40.68 MB of files on mounted jffs:
    Code:
    ls -la /jffs/cp.d/
    drwxr-xr-x   11 root     root             0 Nov 23  2012 .
    drwxr-xr-x    4 root     root             0 Jan  1  1970 ..
    -rw-r--r--    1 1000     1000           787 Nov  8  2012 4hm.cer
    drwxr-xr-x    2 1000     1000             0 Nov 23  2012 bundle
    -rw-r--r--    1 1000     1000         40624 Nov  8  2012 cacerts
    -rw-r--r--    1 root     root           381 Nov 23  2012 config.properties
    -rw-r--r--    1 1000     1000           382 Nov  8  2012 config.properties.orig
    -rw-r--r--    1 1000     1000           156 Nov  8  2012 cp.clients
    drwxr-xr-x    2 1000     1000             0 Nov 23  2012 cpinst
    -rwxr-xr-x    1 1000     1000        208713 Nov  8  2012 execsrv
    drwxr-xr-x    2 1000     1000             0 Nov 23  2012 fc.conf
    -rw-r--r--    1 1000     1000        493190 Nov  8  2012 felix.jar
    lrwxrwxrwx    1 root     root            30 Nov 23  2012 fluid-core.conf -> ./fc.conf/fluid-core.conf.repo
    drwxr-xr-x    4 1000     1000             0 Nov 23  2012 j2re-image-shark
    -rw-r--r--    1 1000     1000          1358 Nov  8  2012 keystore.sun
    drwxr-xr-x    5 1000     1000             0 Nov 23  2012 licenses
    -rw-r--r--    1 root     root         62176 Nov 23  2012 messages
    drwxr-xr-x   20 root     root             0 Nov 23  2012 osgi-config
    drwxr-xr-x    9 1000     1000             0 Nov 23  2012 pkgdb
    drwxr-xr-x    2 1000     1000             0 Nov 23  2012 pkgman
    -rwxr-xr-x    1 root     root          1752 Nov 23  2012 startcore
    drwxr-xr-x    2 root     root             0 Nov 23  2012 vns
    
    I think the files are from Netgear original firmware (used years ago).

    Why are the bad blocks reported? Is this real NAND failure? There was never any problems with firmware/nvram storage so far.

    Why formatting jffs is trying to erase block at page 0x00004140? Does it mean format is trying to erase boot partition?

    What does it mean "Bad block table found at page"?

    It's nice feature. Have you any problems with jffs on 3500Lv2 so far?

    Tom
     
  5. koitsu

    koitsu Network Guru Member

    @slodki NAND flash has support for what's called a BBT (bad block table), because NAND pages have limited erase/write cycles. When one begins to experience problems, the NAND controller and driver (read: this is not managed by Tomato; this is purely something Broadcom provides) add a BBT entry (there can be multiples) so that said page shouldn't be accessed/used any longer (though the way this is implemented varies per controller and driver; there may be bugs, but these are Broadcom's responsibility, TOmato cannot fix them). Think of it like "bad sectors" on a classic mechanical HDD, though the implementation is quite different. The NAND driver reports existence of BBT entries on boot, and apparently if/when an application attempts to access said page. You can Google "NAND flash BBT" and read more about the capability if you wish.

    I can't help with the actual problem (re: why JFFS2 formatting fails -- it looks to me like it's trying to write to the NAND page which is in the BBT), but the NAND driver is what's reporting the complaint.

    There is no way to user-manage the BBT. The only way to "repair" the problem is to replace/RMA the router.

    This is just one of several reasons why I have for years advocated people not use JFFS2 on their flash, but instead use a USB flash/pen drive (the WNR3500Lv2 has a USB port). Leave your NAND alone -- leave as much space available for wear levelling as possible. If the USB drive goes bad, it's easily replaceable -- NAND is not.
     
    Mercjoe and AndreDVJ like this.
  6. slodki

    slodki LI Guru Member

    I analyzed the source of the driver, mtd and tomato. You're right, error brcmnand_isbad_bbt(): bbt info for offs appear every time the faulty block is accessed/checked by the driver. I don't know why they are logged with priority "warn" instead of "info" - they do not require any user attention. It was confusing.

    So my router is not defective. It is not Broadcom nor Linux bug, but bug in tomato firmware. Managing bad blocks is user space task, implemented in mtd utils (and jffs2 of course). But tomato implementation ignores bbt data and tries to erase all blocks even marked as bad already, raising an error in driver.

    Fix was published by @RMerlin in 2012, but was commented out by @shibby20 in 2013 when he merged RT-N and RT-AC trees. So my fix is trivial and now JFFS2 on WNR3500Lv2 is working without any errors.

    I've compiled pached versions of the latest shibby 138 and advanced tomato firmwares, both VPN and AIO versions and they are ready for download.

    I don't understand why you advocate people not use JFFS2? NAND is ideal tool to store static data in router memory. Frequent firmware flashing (each upgrade writes >20MB to NAND) are more harmful for the chip then storing some important small files. Tomato doesn't touch original Netgear partition in NAND, so about 1/3 of the 128MB NAND is still used in hidden partition on all 3500Lv2 with tomato. Why should I buy next pendrive if I have many MBs unused in the router already? USB in 3500Lv2 can be used for more interesting tasks IMHO.

    Thank you @VinTheGodfather for finding right mtd driver for my router! You can cherry pick my fix to your branch to have complete solution in one place. After my testing I think it's ready to merge into next tomato releases.
     
    Strykerraven and txnative like this.
  7. Strykerraven

    Strykerraven New Member Member

    Hmm interesting, Never really compiled firmware before but been wanting to and now I'm thinking about it even more haha. I might try out your builds later but do have stuff I want to do myself.

    I do use a CIFS mount already and will continue to do so but jffs has proven itself many times over on my WRT54GL (used still today as a repeater to my wnr3500lv2). On that its a meager 64KB. JFFS2 would be great for when CIFS is down which is rare for me but it would be even better for users without USB drives etc to expand their routers capabilities. I will definitely watch your repo, Thanks =)
     
    Last edited: Mar 10, 2017
  8. stretch

    stretch Connected Client Member

    @VinTheGodfather how would I apply the patch to a custom rolled firmware to allow jffs.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice