Hopefully someone here can help...
ER-X-SFP booted initramfs image can't flash 4.x nor 5.4 snapshot image due to PEB errors in NAND partition, dmesg output:
UBI: auto-attach mtd5
[ 6.713554] ubi0: attaching mtd5
[ 7.168325] ubi0 error: ubi_attach: bad image sequence number 2018561425 in PEB 352, expected 940586124
[ 7.187046] Erase counter header dump:
[ 7.194507] magic 0x55424923
[ 7.201966] version 1
[ 7.207870] ec 13
[ 7.213947] vid_hdr_offset 2048
[ 7.220370] data_offset 4096
[ 7.226787] image_seq 2018561425
[ 7.234248] hdr_crc 0x2ec7c84c
[ 7.241705] erase counter header hexdump:
[ 7.249845] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd5, error -22
[ 7.263919] UBI error: cannot attach mtd5
Problem is, it does perform ubiformat, notices PEB errors, and writes firmware image to mtd5, but upon reboot it ends in an kernel panic that it can't mount root partition.
Seems like a problem in NAND driver or ubiformat/ubiattach that can't perform error correction handling properly. Ubiquiti recovery image works fine, it ignores the PEB errors and is able to attach mtd partition...
Here's output from sysupgrade using latest snapshot:
Wed Apr 14 15:55:28 UTC 2021 upgrade: Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3
- watchdog -
killall: telnetd: no process killed
Wed Apr 14 15:55:29 UTC 2021 upgrade: Sending TERM to remaining processes ... logd hostapd wpa_supplicant odhcpd ntpd netifd dnsmasq ubusd urngd
Wed Apr 14 15:55:32 UTC 2021 upgrade: Sending KILL to remaining processes ...
[ 602.761607] sh (3018): drop_caches: 3
Wed Apr 14 15:55:33 UTC 2021 upgrade: Switching to ramdisk...
Wed Apr 14 15:55:35 UTC 2021 upgrade: Performing system upgrade...
[ 604.792667] ubi0: attaching mtd5
[ 605.248805] ubi0 error: ubi_attach: bad image sequence number 2018561425 in PEB 352, expected 940586124
[ 605.267523] Erase counter header dump:
[ 605.274983] magic 0x55424923
[ 605.282442] version 1
[ 605.288346] ec 13
[ 605.294420] vid_hdr_offset 2048
[ 605.300847] data_offset 4096
[ 605.307266] image_seq 2018561425
[ 605.314783] hdr_crc 0x2ec7c84c
[ 605.322247] erase counter header hexdump:
[ 605.330403] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd5, error -22
ubiattach: error!: cannot attach mtd5
error 22 (Invalid argument)
1+0 records in
1+0 records out
Unlocking kernel1 ...
Writing from <stdin> to kernel1 ...
[ 607.173582] ubi0: attaching mtd5
[ 607.629015] ubi0 error: ubi_attach: bad image sequence number 2018561425 in PEB 352, expected 940586124
[ 607.647731] Erase counter header dump:
[ 607.655187] magic 0x55424923
[ 607.662645] version 1
[ 607.668548] ec 13
[ 607.674621] vid_hdr_offset 2048
[ 607.681049] data_offset 4096
[ 607.687491] image_seq 2018561425
[ 607.694949] hdr_crc 0x2ec7c84c
[ 607.702408] erase counter header hexdump:
[ 607.710551] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd5, error -22
ubiattach: error!: cannot attach mtd5
error 22 (Invalid argument)
ubiformat: mtd5 (nand), size 259784704 bytes (247.7 MiB), 1982 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 1981 -- 100 % complete
ubiformat: 1981 eraseblocks have valid erase counter, mean value is 12
ubiformat: 1 bad eraseblocks found, numbers: 1748
ubiforma[ 644.990090] ubi0: attaching mtd5 % complete
ubiformat: formatting eraseblock 1981 -- 100 % complete
[ 645.449307] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 26241.0
[ 645.464183] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 352:2048, read only 0 bytes, retry
[ 645.487247] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 26241.0
[ 645.502110] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 352:2048, read only 0 bytes, retry
[ 645.525171] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 26241.0
[ 645.540070] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 352:2048, read only 0 bytes, retry
[ 645.563128] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 26241.0
[ 645.577969] ubi0 error: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 352:2048, read 0 bytes
[ 645.598408] CPU: 1 PID: 3635 Comm: ubiattach Not tainted 5.4.110 #0
[ 645.610864] Stack : 8ff7e800 8007d738 80700000 806fa5e8 80760000 806fa5b0 806f9524 8ec85c74
[ 645.627484] 80ab0000 8fe99fc8 80746d63 8068b274 00000001 00000001 8ec85c18 34c52616
[ 645.644100] 00000000 00000000 80af0000 00000000 00000030 00000135 20646574 2e342e35
[ 645.660716] 00000000 00000020 00000000 00092188 80000000 80760000 00000000 00000160
[ 645.677333] 02c00800 00000000 00000800 00000000 00000002 8035c910 00000004 80ab0004
[ 645.693951] ...
[ 645.698806] Call Trace:
[ 645.703684] [<8000b64c>] show_stack+0x30/0x100
[ 645.712523] [<805ca2e4>] dump_stack+0xa4/0xdc
[ 645.721186] [<803ba4b0>] ubi_io_read+0x274/0x3a0
[ 645.730366] [<803bab2c>] ubi_io_read_vid_hdr+0x6c/0x2b4
[ 645.740760] [<803c062c>] ubi_attach+0x488/0x1594
[ 645.749939] [<803b3e08>] ubi_attach_mtd_dev+0x5e4/0xb88
[ 645.760328] [<803b52c8>] ctrl_cdev_ioctl+0x16c/0x1c4
[ 645.770201] [<80191350>] do_vfs_ioctl+0xb8/0x7c0
[ 645.779379] [<80191aa8>] ksys_ioctl+0x50/0xb4
[ 645.788047] [<80014558>] syscall_common+0x34/0x58
[ 645.797658] UBI assert failed in ubi_io_read at 190 (pid 3635)
[ 645.809277] CPU: 1 PID: 3635 Comm: ubiattach Not tainted 5.4.110 #0
[ 645.821731] Stack : 8ff7e800 8007d738 80700000 806fa5e8 80760000 806fa5b0 806f9524 8ec85c74
[ 645.838348] 80ab0000 8fe99fc8 80746d63 8068b274 00000001 00000001 8ec85c18 34c52616
[ 645.854967] 00000000 00000000 80af0000 00000000 00000030 00000148 20646574 2e342e35
[ 645.871582] 00000000 00000020 00000000 000c593d 80000000 80760000 00000000 00000160
[ 645.888198] 02c00800 00000000 00000800 00000000 00000002 8035c910 00000004 80ab0004
[ 645.904814] ...
[ 645.909668] Call Trace:
[ 645.914528] [<8000b64c>] show_stack+0x30/0x100
[ 645.923361] [<805ca2e4>] dump_stack+0xa4/0xdc
[ 645.932024] [<803ba4e8>] ubi_io_read+0x2ac/0x3a0
[ 645.941204] [<803bab2c>] ubi_io_read_vid_hdr+0x6c/0x2b4
[ 645.951603] [<803c062c>] ubi_attach+0x488/0x1594
[ 645.960786] [<803b3e08>] ubi_attach_mtd_dev+0x5e4/0xb88
[ 645.971178] [<803b52c8>] ctrl_cdev_ioctl+0x16c/0x1c4
[ 645.981049] [<80191350>] do_vfs_ioctl+0xb8/0x7c0
[ 645.990226] [<80191aa8>] ksys_ioctl+0x50/0xb4
[ 645.998888] [<80014558>] syscall_common+0x34/0x58
[ 646.008609] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd5, error -5
ubiattach: error!: cannot attach mtd5
error 5 (I/O error)
libubi: error!: "/dev/" is not a character device
ubimkvol: error!: error while probing "/dev/"
error 22 (Invalid argument)
cannot create rootfs volume
libubi: error!: "/dev/" is not a character device
ubiupdatevol: error!: e[ 646.088023] reboot: Restarting system
rror while probing "/dev/"
error 22 (Invalid argument)
tar: write error: Broken pipe
sysupgrade successful
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource busy