Topic: how to restore art partition?

Hello,
I think I managed to break art partition on my linksys wrt160nl: the wifi is not working anymore neither with openWrt, dd-wrt nor oem firmware and md5sum of the file obtained from dumping art partition with dd is different than of the one I saved as a backup when first installed openWrt. Now as I have the mentioned backup I thought it would be easy to bring wifi back to life with mtd by copying the backup file to /tmp on the router and then issuing

root@OpenWrt:/tmp# mtd -r write art.backup art

however I only got the following error message immediately:

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

:/

If anyone could tell me how to do this in a proper way I would be very grateful :)

Thx!

Re: how to restore art partition?

You need to (re)compile the kernel and remove the write protection from the mtd partition:

--- target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (revision 26848)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (working copy)
@@ -60,7 +60,6 @@
         .name        = "ART",
         .offset        = 0x7f0000,
         .size        = 0x010000,
-        .mask_flags    = MTD_WRITEABLE,
     }, {
         .name        = "firmware",
         .offset        = 0x040000,

Oh and by the way - its "ART", not "art".

Re: how to restore art partition?

ah, I see... Thanks for your help!!

Re: how to restore art partition?

Hi again,
I've applied the suggested change to 10.03.1-rc4, built it and installed on my router, yet the problem still persists:

root@OpenWrt:/tmp# mtd -r write art.backup art
Could not open mtd device: art
Can't open device for writing!
root@OpenWrt:/tmp# mtd -r write art.backup ART
Could not open mtd device: ART
Can't open device for writing!
root@OpenWrt:/tmp# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00130000 00010000 "kernel"
mtd2: 00670000 00010000 "rootfs"
mtd3: 00450000 00010000 "rootfs_data"
mtd4: 00010000 00010000 "nvram"
mtd5: 00010000 00010000 "art"
mtd6: 007a0000 00010000 "firmware"
root@OpenWrt:/tmp# mtd -r write art.backup mtd5
Could not open mtd device: mtd5
Can't open device for writing!

I'd be grateful for any hints regarding this...

Thanks!

Re: how to restore art partition?

to be precise my changes look like this:

morgwai@darkstorm:~/openWrt/backfire$ svn diff
Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c
===================================================================
--- target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (revision 24045)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (working copy)
@@ -54,12 +54,10 @@
         .name        = "nvram",
         .offset        = 0x7e0000,
         .size        = 0x010000,
-        .mask_flags    = MTD_WRITEABLE,
     } , {
         .name        = "ART",
         .offset        = 0x7f0000,
         .size        = 0x010000,
-        .mask_flags    = MTD_WRITEABLE,
     } , {
         .name        = "firmware",
         .offset        = 0x040000,
Index: feeds.conf.default
===================================================================
--- feeds.conf.default    (revision 24045)
+++ feeds.conf.default    (working copy)
@@ -1,5 +1,5 @@
 src-svn packages svn://svn.openwrt.org/openwrt/packages
-src-svn xwrt http://x-wrt.googlecode.com/svn/branches/backfire_10.03/package
+#src-svn xwrt http://x-wrt.googlecode.com/svn/branches/backfire_10.03/package
 src-svn luci http://svn.luci.subsignal.org/luci/tags/0.9.0/contrib/package
 #src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone
 #src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl

Re: how to restore art partition?

BUMP

any ideas anyone?

Re: how to restore art partition?

Try this: dd bs=65536 if=art.backup of=/dev/mtdblock5

Re: how to restore art partition?

root@OpenWrt:/tmp# dd bs=65536 if=art.backup of=/dev/mtdblock5
dd: writing '/dev/mtdblock5': Operation not permitted
1+0 records in
0+0 records out

sad

Re: how to restore art partition?

Did you run make target/linux/clean when recompiling the kernel with the above changes?

Re: how to restore art partition?

I did not, as I fetched the clean sources with svn. However to be sure I did it now and recompiled and the effect was the same...

Re: how to restore art partition?

Hi, just in case, may you try this ?

mtd unlock mtd5
mtd -f write art.backup art  (or: dd bs=65536 if=art.backup of=/dev/mtdblock5 as suggested)

Note: "unlock" is not always implemented in mtd utility.

12

Re: how to restore art partition?

mtd write art.backup mtd5

Re: how to restore art partition?

root@OpenWrt:/tmp# mtd unlock art
Could not open mtd device: art
Could not open mtd device: art
root@OpenWrt:/tmp# mtd unlock ART
Could not open mtd device: ART
Could not open mtd device: ART
root@OpenWrt:/tmp# mtd unlock mtd5
Could not open mtd device: mtd5
Could not open mtd device: mtd5
root@OpenWrt:/tmp# mtd write -r art.backup art
Could not open mtd device: art
Can't open device for writing!
root@OpenWrt:/tmp# mtd write -r art.backup ART
Could not open mtd device: ART
Can't open device for writing!
root@OpenWrt:/tmp# mtd write -r art.backup mtd5
Could not open mtd device: mtd5
Can't open device for writing!
root@OpenWrt:/tmp# dd bs=65536 if=art.backup of=/dev/mtdblock5 
dd: writing '/dev/mtdblock5': Operation not permitted
1+0 records in
0+0 records out

sad

14

Re: how to restore art partition?

OpenWrt / problem with ath9k eeprom on WRT160NL
OpenWrt / WRT160NL flashing and kernel panic

Re: how to restore art partition?

This gets unclear... time to relocate to the wiki:
http://wiki.openwrt.org/doc/howto/generic.backup

there are two section. "obtain backup" and "put it back"

Re: how to restore art partition?

Thanks for help everybody! Sadly, I still can't flash my art partition however sad I applied changes from the patch from the forum thread kindly provided by fyi, but I still get the same effect (Could not open mtd device: mtd5 Can't open device for writing!). My changes look like the following now:

morgwai@darkstorm:~/openWrt/backfire$ svn diff
Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c
===================================================================
--- target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (revision 24045)
+++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-wrt160nl.c    (working copy)
@@ -54,12 +54,10 @@
         .name        = "nvram",
         .offset        = 0x7e0000,
         .size        = 0x010000,
-        .mask_flags    = MTD_WRITEABLE,
     } , {
         .name        = "ART",
         .offset        = 0x7f0000,
         .size        = 0x010000,
-        .mask_flags    = MTD_WRITEABLE,
     } , {
         .name        = "firmware",
         .offset        = 0x040000,
Index: target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c
===================================================================
--- target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c    (revision 24045)
+++ target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c    (working copy)
@@ -143,12 +143,12 @@
     trx_parts[3].name = "nvram";
     trx_parts[3].offset = master->size - 2 * master->erasesize;
     trx_parts[3].size = master->erasesize;
-    trx_parts[3].mask_flags = MTD_WRITEABLE;
+    trx_parts[3].mask_flags = 0;
 
     trx_parts[4].name = "art";
     trx_parts[4].offset = master->size - master->erasesize;
     trx_parts[4].size = master->erasesize;
-    trx_parts[4].mask_flags = MTD_WRITEABLE;
+    trx_parts[4].mask_flags = 0;
 
     trx_parts[5].name = "firmware";
     trx_parts[5].offset = 4 * master->erasesize;
Index: feeds.conf.default
===================================================================
--- feeds.conf.default    (revision 24045)
+++ feeds.conf.default    (working copy)
@@ -1,5 +1,5 @@
 src-svn packages svn://svn.openwrt.org/openwrt/packages
-src-svn xwrt http://x-wrt.googlecode.com/svn/branches/backfire_10.03/package
+#src-svn xwrt http://x-wrt.googlecode.com/svn/branches/backfire_10.03/package
 src-svn luci http://svn.luci.subsignal.org/luci/tags/0.9.0/contrib/package
 #src-svn phone svn://svn.openwrt.org/openwrt/feeds/phone
 #src-svn efl svn://svn.openwrt.org/openwrt/feeds/efl

Does anybody have idea what other changes I have to apply to be able to write to art partition?

Thanks!

17

Re: how to restore art partition?

Make distclean before compilation.

Access U-Boot though serial console.

Re: how to restore art partition?

dirclean did the job, I was able to fix my art partition and my wifi works again big_smile thanks for help, everybody!!!

the patch that really did the job was the one from the thread provided by fyi:

Index: target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c
===================================================================
--- target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c    (revision 24045)
+++ target/linux/ar71xx/files/drivers/mtd/wrt160nl_part.c    (working copy)
@@ -143,12 +143,12 @@
     trx_parts[3].name = "nvram";
     trx_parts[3].offset = master->size - 2 * master->erasesize;
     trx_parts[3].size = master->erasesize;
-    trx_parts[3].mask_flags = MTD_WRITEABLE;
+    trx_parts[3].mask_flags = 0;
 
     trx_parts[4].name = "art";
     trx_parts[4].offset = master->size - master->erasesize;
     trx_parts[4].size = master->erasesize;
-    trx_parts[4].mask_flags = MTD_WRITEABLE;
+    trx_parts[4].mask_flags = 0;
 
     trx_parts[5].name = "firmware";
     trx_parts[5].offset = 4 * master->erasesize;

after this mtd unlock was unnecessary. I'll fix the wiki in a moment.

19

Re: how to restore art partition?

Just about to suggest you installing DD-WRT. Even U-Boot/RedBoot can be wiped off. Let alone ART.