Restore whole mtd file on the lede

hello, everybody.
i meet some question.
on the ddwrt-nxt, i was backup whole mtd file:

dd if=/dev/mtd0 of=/tmp/mtd0.bin  256kb
dd if=/dev/mtd1 of=/tmp/mtd1.bin   64kb
dd if=/dev/mtd2 of=/tmp/mtd2.bin   64kb
dd if=/dev/mtd3 of=/tmp/mtd3.bin  4.00Mb
dd if=/dev/mtd4 of=/tmp/mtd4.bin  124Mb

and this is my patiction info

root@dd-wrt-nxt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00010000 "boot"  256kb
mtd1: 00010000 00010000 "embedd" 64kb
mtd2: 00010000 00010000 "nvram"  64kb
mtd3: 00400000 00020000 "kernel" 4.00Mb
mtd4: 07c00000 00020000 "ubi"   124Mb


root@dd-wrt-nxt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
rootfs                  101.8M     60.0K     97.0M   0% /
/dev/root                 5.3M      5.3M         0 100% /rom
tmpfs                   252.0M    256.0K    251.7M   0% /tmp
/dev/ubi0_1             101.8M     60.0K     97.0M   0% /overlay
overlayfs:/overlay      101.8M     60.0K     97.0M   0% /
tmpfs                   512.0K         0    512.0K   0% /dev

===================================================
Now , i was installled ddwrt,

How can do , restore the All partitions , on the openwrt system, but the system has a different partition structure
flash is NAND 128M
I know use this way
mtd -r write [your partitions]

**CURRENT partition structure **

root@DD-WRT:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00010000 "boot"
mtd1: 00010000 00010000 "nvram_cfe"
mtd2: 00010000 00010000 "nvram"
mtd3: 03000000 00020000 "linux"
mtd4: 02e60000 00020000 "rootfs"
mtd5: 03000000 00020000 "linux2"
mtd6: 02e60000 00020000 "rootfs2"
mtd7: 01f00000 00020000 "ddwrt"

This looks like a ddwrt question. Ddwrt has no relationship to OpenWrt nee LEDE.

In general with a NAND device you should be working at the ubi layer and not accessing mtd blocks directly, because they may have bad sectors. When another sector goes bad or you try to copy to a different chip that has its bad sectors in different places, it won't work.

3 Likes

this is my TTL log

[    2.901826] Creating 2 MTD partitions on "brcmnand":
[    2.906810] 0x000000000000-0x000000400000 : "kernel"
[    2.912689] 0x000000400000-0x000008000000 : "ubi"


[    2.918923] UBI: auto-attach mtd4
[    2.922256] UBI: attaching mtd4 to ubi0
[    3.438819] UBI warning: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 625:2048, read only 2048 bytes, retry
[    3.451118] UBI warning: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 625:2048, read only 2048 bytes, retry
[    3.463412] UBI warning: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 625:2048, read only 2048 bytes, retry
[    3.475702] UBI error: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 625:2048, read 2048 bytes


[    3.638522] UBI error: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 626:2048, read 2048 bytes

[    4.837209]  r7:00000000 r6:00000000 r5:c004685c r4:c7833e20
[    4.837215] UBI warning: ubi_eba_copy_leb: error -74 while reading data from PEB 626


[    7.879036] UBIFS error (pid 302): ubifs_recover_leb: LEB 15 scanning failed
[    7.886165] UBIFS: background thread "ubifs_bgt0_1" stops
failed to mount -t ubifs /dev/ubi0_1 /tmp/overlay: Bad message
switching to overlay
switching to jffs2 failed - fallback to ramoverlay
procd: - early -
Failed to connect to ubus
procd: - ubus -
procd: - init -
Please press Enter to activate this console.
[   10.790590] wl0: Broadcom BCM4360 802.11 Wireless Controller 6.37.14.86 (r456083)

when is recovery backup files,
overlay, can not mount, and overlayfs, read only,
mount ubi0, to root dir faild.
how to rescue it. Thank you very much

Dear Wangzhen,
Is your device WXR1900DHPD? Could you share me your backup file? I can try to do on my device, if succeed, I will share my exp to you. Thank you very much ^^