OpenWrt Forum Archive

Topic: Flash firmware from mtd

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

I tried the Luci "Flash Firmware" menu option on my NSLU2 K809rc2, and got the message "Sorry, this function is not (yet) available for your platform."

I had seen that something like the following command might work (where k809rc1.bin is an 8mb NSLU2 squashfs image in /tmp):

$ mtd write k809rc1.bin linux && reboot

But got the following message:

Could not open mtd device: linux
Can't open device for writing!

Do I have the syntax of the command correct?  If not, what should I use; if so, what needs to be done to make this work on the NSLU2?

I don't know anything specific to the NSLU2, but I do know the partition names sometimes differ on openwrt.  Post a "cat /proc/mtd" for your router and see if one is named linux.  It may be named 'firmware' instead.

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 00020000 00020000 "SysConf"
mtd2: 00020000 00020000 "Loader"
mtd3: 00100000 00020000 "Kernel"
mtd4: 00660000 00020000 "rootfs"
mtd5: 003a0000 00020000 "rootfs_data"
mtd6: 00020000 00020000 "FIS directory"

dmesg has the following:
Creating 6 MTD partitions on "IXP4XX-Flash.0":
0x00000000-0x00040000 : "RedBoot"
0x00040000-0x00060000 : "SysConf"
0x00060000-0x00080000 : "Loader"
0x00080000-0x00180000 : "Kernel"
0x00180000-0x007e0000 : "rootfs"
0x00440000-0x007e0000 : "rootfs_data"
0x007e0000-0x00800000 : "FIS directory"

These correspond to mtd0 through mtd6.  mtd5, "rootfs_data", is included in mtd4, "rootfs".  The total flash, 8 megabytes, is written for a bin file such as I have.  I can flash normally using the sercom utility under windows, but it would eliminate a few steps if I could flash directly from the NSLU2 ram.  I had thought (knowing nothing), that "linux" in the mtd command was just a magic word meaning everything which needed to be flashed.

lizby wrote:

I had thought (knowing nothing), that "linux" in the mtd command was just a magic word meaning everything which needed to be flashed.

I don't think so...

root@router:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "cfe"
mtd1: 007a0000 00020000 "linux"
mtd2: 006e3c00 00020000 "rootfs"
mtd3: 00400000 00020000 "rootfs_data"
mtd4: 00020000 00020000 "nvram"

I see in the bin directory for my K809rc2 build that there is a file, openwrt-nslu2-zimage, which is 978.5kB (different from the 8mB .bin file which is used to flash the entire image).  In this thread -- http://forum.openwrt.org/viewtopic.php?id=12395 -- this is suggested:

> I think that zImage could be used for
>  mtd unlock mtd3
>  mtd write openwrt-nslu2-2.6-zImage mtd3

Would this work?  What about the rootfs partition?

I am looking to upgrade my NSLU2 to the new 8.09 release, but am getting a similar error regarding the absence of a "linux" mtd block.

So based on the output from the cat /proc/mtd does one use the "Kernel" tag vs. the "linux" tag for the mtd command found in all the docs?

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00020000 "RedBoot"
mtd1: 00020000 00020000 "SysConf"
mtd2: 00020000 00020000 "Loader"
mtd3: 00100000 00020000 "Kernel"
mtd4: 00660000 00020000 "rootfs"
mtd5: 00560000 00020000 "rootfs_data"
mtd6: 00020000 00020000 "FIS directory"

For example the docs all say to use this command...

mtd -r write firmware.bin linux

since I don't have a mtd block labeled linux should I use this command instead?

mtd -r write firmware.bin Kernel

(Last edited by gigageek on 23 Feb 2009, 03:38)

Rod Whitby said on the Nslu2 forum that this won't work.  It is necessary to flash the full 8MB .bin image by the normal method.  That works for me.

lizby wrote:

Rod Whitby said on the Nslu2 forum that this won't work.  It is necessary to flash the full 8MB .bin image by the normal method.  That works for me.

I guess that is what I am asking.  What is the normal method?

ok so I found the post you mentioned
http://www.nabble.com/zimage-for-NSLU2- … 95807.html

but since I was able to simply apply the "openwrt-kamikaze-7.09-nslu2.bin" through the original Linksys firmware it stands to reason that I should be able to use the 8.09 bin file for the NSLU2.  I just don't know how to make it work now that I am running OpenWRT 7.09.

Same problem on wr1043nd, FW is on mounted usbdrive

root@OpenWrt:/tmp# mtd -e linux -r write /mnt/hdd/wr1043nv1.bin linux
Could not open mtd device: linux
Can't open device for writing!
root@OpenWrt:/tmp#

The discussion might have continued from here.