OpenWrt Forum Archive

Topic: mtdblock0 read-only on wrt54g v2

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

Hi,

I followed the information on http://wiki.openwrt.org/doc/techref/bootloader/cfe?s[]=cfe to create a custom cfe with boot_wait=on by default and  reset_gpio=6.  I had to use a hex editor to make the changes as I couldn't find nvserial (link is broken).

I am not able to flash the modified .bin file because the mtdblock0 device is read-only.  Does anyone know how to get around that in the current kernel?  The url mentions this and provides a kernel patch, but it doesn't apply to the 2.6 kernel source.  It looks like the mtd driver was moved and re-written since 2.4.x

Does anyone know how to get the device to be writable?

root@OpenWrt:~# cat /sys/block/mtdblock0/ro
1

From dmesg:

Creating 4 MTD partitions on "Physically mapped flash":                         
0x000000000000-0x000000040000 : "cfe"                                           
0x000000040000-0x0000003f0000 : "linux"                                         
0x00000011a400-0x0000003f0000 : "rootfs"                                       
[...]


root@OpenWrt:/sys/devices/virtual/mtd/mtd0# mtd unlock cfe
Could not open mtd device: cfe

root@OpenWrt:/tmp# mtd write -f /tmp/cfe-new.bin cfe
Could not open mtd device: cfe
Can't open device for writing!

Recompiling kernel with writable cfe partition.

Yes thats what the instructions say, but like I said the patch won't apply.. so how do I recompile it with a writable cfe?

I see there is a CONFIG_CFE configuration option but its already set to CONFIG_CFE=y and its probably something unrelated smile

https://dev.openwrt.org/browser/trunk/t … xx-flash.c

static struct mtd_partition bcm47xx_parts[] = {
    { name: "cfe",  offset: 0, size: 0, /* mask_flags: MTD_WRITEABLE, */ },
    { name: "linux", offset: 0, size: 0, },
    { name: "rootfs", offset: 0, size: 0, },
    { name: "nvram", offset: 0, size: 0, },
    { name: NULL, }, /* Used to create custom partitons with the function get_router() */
    { name: NULL, },
};

I'm not sure if this is the one.

That worked, thanks!

I was able to flash the modified cfe and it boots fine.  Dumping the default config shows my changes are there like boot_wait=on, however holding down the reset button during power-on doesn't load these defaults.  It doesn't seem to do anything at all as far as I can tell so not sure whats going on there..

Were you able to use the reset button to default the NVRAM before your changes?  How long did you hold down the reset button?  My CFE box takes 10 seconds.

-John

No, I had issues with it even before the change.  I think I only ever got it to reset once.  I tried pushing the reset and plugging in the power while still holding it, I tried pushing it once the power light starts to blink.  Even if I push it when the dmz light comes on openwrt never enters safe mode, so I assume there's something wrong with the button on a hardware level.

Is there some command line utility that can detect the button push and tell me if its working or not?

The discussion might have continued from here.