1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

NVRAM won't erase Buffalo WHR3-G54

Discussion in 'Tomato Firmware' started by ghostknife, May 9, 2012.

  1. ghostknife

    ghostknife Addicted to LI Member

    Hi,
    I've got this WHR3-G54 that I use as an AP and something's gone wrong somewhere. I was running the last version of TomatoUSB and a while ago I tried to upgrade to Toastman release and it failed several times so I gave up. Now I just tried with the latest release and the upgrade worked but now it looks like I can't erase the NVRAM, none of the settings reset and the message below is always there.

    Now I've just been back and forth with bunch of different TomatoUSB and Toastman firmware and re-loads, tried reset via the GUI, the reset button and Telnet. They all appear to work but I still have minimal free NVRAM. I guess it's working but finding this weird thought I'd post for ideas.

    # mtd-erase -d nvram
    Erasing 0x0 - 0xffff
    "nvram" successfully erased.

    Total / Free NVRAM: 32.00 KB / 832 (2.54%)
    [The NVRAM free space is very low. It is strongly recommended to erase all data in NVRAM memory, and reconfigure the router manually in order to clean up all unused and obsolete entries.]
     
  2. Planiwa

    Planiwa LI Guru Member

    Most people do not understand 2 important concepts:

    1. The nvram command never reports on the actual, flashed NVRAM. Ditto for the Tomato GUI.
    2. The Tomato GUI usually does not tell you (or the system log) what significant changes it makes.

    There are ways to read the actual flashed NVRAM.

    I can tell you, but first, for your device, please post the result of:

    Code:
    cat /proc/mtd
    ls -l /dev/mtd*
    
    Like this:

    Code:
      nvsize
    Analysis of NVRAM flash partition
     
    131072 NVRAM partition size (mostly unusable!).
     98304 Unusable initial portion of partition.
     32748 Total usable NVRAM space (after 20-byte header).
     25809 Actually used NVRAM space.
      6939 Free NVRAM space (approx).
       984 Used NVRAM variables.
     
    From nvram command (not from flashed NVRAM), includes uncommitted settings:
    984 entries, 25688 bytes used, 7080 bytes free.
    
     
  3. Planiwa

    Planiwa LI Guru Member

    OK, here is nvsize:

    Code:
    head /proc/mtd /proc/partitions ; echo
     
    case $(uname -r) in
    2.4*) NVRAMF=/dev/mtd/4;;
    2.6*) NVRAMF=/dev/mtd4;;
    *) echo unknown OS release; exit;;
    esac
     
    echo "Analysis of NVRAM flash partition"
    echo
    PS="$(<$NVRAMF wc -c)"
    FF="$(<$NVRAMF tr -c 'F' '\n' |grep -n F|sed 1q)"; FF=$((${FF%:F}-1)) # Bytes before start of 20-byte "FLSH" header.
    printf "%6s %s\n" "$PS" "NVRAM partition size (bytes) (mostly unusable!)."
    printf "%6s %s\n" "$FF" "Unusable initial portion of partition."
    printf "%6s %s\n" "$(( PS -FF -20 ))" "Total defined usable NVRAM space (after 20-byte header)."
    U="$(( $(<$NVRAMF tr -d '\377'|tr -s '\0'|wc -c) -20 ))"
    printf "%6s %s\n" "$U" "Actually used NVRAM space."
    printf "%6s %s\n" "$(( PS -FF -20 -U ))" "Free NVRAM space (approx)." # (There are <8 \0 pads, then 0xFF to end.)
    V="$(( $(<$NVRAMF tr -d '\377'|dd bs=20 skip=1 2>/dev/null|tr -d '\n'|tr -s '\0' '\n'|wc -l) ))"
    printf "%6s %s\n" $V "Used NVRAM variables."
    echo
    echo "From nvram command (not from flashed NVRAM), includes uncommitted settings:"
    nvram show|tail -1
    
     
  4. ghostknife

    ghostknife Addicted to LI Member

    Thanks for your reply, I went back to an old Victek release because I realised that the thing has [wl0_corerev=5] and wasn't sure if that was affecting something with the wrong drivers being used, of course that doesn't report anything on NVRAM so I don't know that now. Some settings seem to reset and some don't when I try, seems random but anyway it's working, maybe it has a hardware fault
    Heres the output:

    Tomato v1.25.8025 .2-RAF STD
    BusyBox v1.14.2 (2009-07-13 21:56:20 CEST) built-in shell (ash)
    Enter 'help' for a list of built-in commands.

    # cat /proc/mtd
    dev: size erasesize name
    mtd0: 00040000 00010000 "pmon"
    mtd1: 003b0000 00010000 "linux"
    mtd2: 0023d62c 00010000 "rootfs"
    mtd3: 000d0000 00010000 "jffs2"
    mtd4: 00010000 00010000 "nvram"

    # ls -l /dev/mtd*
    /dev/mtd:
    crw-rw-rw- 1 root root 90, 0 Jan 1 1970 0
    crw-rw-rw- 1 root root 90, 1 Jan 1 1970 0ro
    crw-rw-rw- 1 root root 90, 2 Jan 1 1970 1
    crw-rw-rw- 1 root root 90, 3 Jan 1 1970 1ro
    crw-rw-rw- 1 root root 90, 4 Jan 1 1970 2
    crw-rw-rw- 1 root root 90, 5 Jan 1 1970 2ro
    crw-rw-rw- 1 root root 90, 6 Jan 1 1970 3
    crw-rw-rw- 1 root root 90, 7 Jan 1 1970 3ro
    crw-rw-rw- 1 root root 90, 8 Jan 1 1970 4
    crw-rw-rw- 1 root root 90, 9 Jan 1 1970 4ro

    /dev/mtdblock:
    brw-rw-rw- 1 root root 31, 0 Jan 1 1970 0
    brw-rw-rw- 1 root root 31, 1 Jan 1 1970 1
    brw-rw-rw- 1 root root 31, 2 Jan 1 1970 2
    brw-rw-rw- 1 root root 31, 3 Jan 1 1970 3
    brw-rw-rw- 1 root root 31, 4 Jan 1 1970 4
     
  5. Planiwa

    Planiwa LI Guru Member

    Ah, yes:
    Code:
    nvram find model_name
    wl revinfo
    
    Did you try the script that I offered (nvsize)?
    What does it tell you?

    Are you saying that after you erase NVRAM and then reflash FW and then erase NVRAM ... then you have low free NVRAM space?
     
  6. ghostknife

    ghostknife Addicted to LI Member

    Well yes when I flashed it with Toastman I'm saying exactly that, flash FW & erase NVRAM and it was saying I was running low as above.

    I don't know how to run that nvsize script, not sure what I'm supposed to do with it
     
  7. Planiwa

    Planiwa LI Guru Member

    copy paste to a command line prompt, will do.
    or maybe copy-paste to Tools>System.
     
  8. ghostknife

    ghostknife Addicted to LI Member

    Analysis of NVRAM flash partition

    65536 NVRAM partition size (bytes) (mostly unusable!).
    32768 Unusable initial portion of partition.
    32748 Total defined usable NVRAM space (after 20-byte header).
    32086 Actually used NVRAM space.
    662 Free NVRAM space (approx).
    1849 Used NVRAM variables.

    From nvram command (not from flashed NVRAM), includes uncommitted settings:
    1849 entries, 32109 bytes used, 659 bytes free.
     
  9. Planiwa

    Planiwa LI Guru Member

    So the two agree.

    You could do an "nvram show" and examine the list of 1849 entries for obvious superfluity.

    One could do:
    mtd-erase -d nvram

    and verify that it's gone:
    wc /dev/mtd4

    one might try to figure out what is meant by:
    nvram defaults --yes
    nvram defaults --initcheck

    or flash a minimal build, which should have under 600 entries and make it easier to see the superfluities.
     

Share This Page