OpenWrt Forum Archive

Topic: mtd erase nvram bug?

The content of this topic has been archived on 26 Feb 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I have a wrt54GS v3 router with the latest openwrt whiterussian snapshot installed. The problem is when I do a mtd erase nvram;reboot. The router goes into failsafe mode. Is there a problem with my router or is it the firmware.

Erasing nvram is BAD. I seen routers which do not recreate all needed NVRAM variables. Normally CFE/PMON, the bootloader, will recreate the default set of variables. But this is not right, on some models it does not recreate all needed vars. To recreate all default vars, I always flash the original firmware.

May be we will adress this in OpenWrt HEAD, when we abstract from nvram use.

How about building a collection of nvram from default firmwares for various models to flash to the nvram?

I realized this too, when I installed openwrt (rc3) and erased my nvram on a WRT54g-v1.0
The longer story is, that nothing bad happened, but I think I found a bug in the
kernel's 'diag.o' module:

On a wrt54g-v1.0 the boardrev and types after (and before the erase) are:

boardtype=bcm94710dev
boardnum=42

The kernel's diag-modules says: diag boardtype: 0000041a

Now the kernel-source says:

buf=nvram_get("boardrev");
    if (((board_type & 0xf00) == 0x400) && strcmp(buf,"0x10")) {
     ...whatever - let's call it case-#1
   } else {
     ...something else - let's call it case #2
   }

So when 'boardrev' isn't set - it choses case-#2.
Doesn't seem a good choice, as the 'diag' module NEVER finishes loading:

root@OpenWrt:~# lsmod
Module                  Size  Used by    Tainted: P 
nfs                    90168   0 (unused)
lockd                  64060   0 [nfs]
sunrpc                 81464   0 [nfs lockd]
wlcompat               14688   0 (unused)
wl                    423640   0 (unused)
et                     32064   0 (unused)
diag                    2560   1 (initializing)
root@OpenWrt:~#

And as a consequence my red DIAG-led never goes out.
It permanently stays on... - simply because there is no /proc/sys/diag :-(
and by that /etc/init.d/S99done can't reset the LED.

Setting manually boardrev to '0x10'  changes things a bit:

the module indeed finishes loading, and creates the proc-entry,
but /etc/init.d/S99done still won't reset the LED, because it seems
like the proc-driver doesn't work at all... hmmm

Anyways - I can live with this .... simply because I'm too lazy
to debug the gpio-stuff for now - but if somebody has a quick shot - let me know.

wbx wrote:

Erasing nvram is BAD.

on all models (linksys, asus, ...) or just the wrt54g(s) ?

bacause i erased the nvram on my new asus 500g deluxe ....

(Last edited by trebiani on 10 Oct 2005, 11:29)

The discussion might have continued from here.