I’m currently working on implementing OpenWrt (version 21.02) on an MT7621A-based device with NAND flash storage. I’ve enabled the UBIFS file system in my configuration, but I’m encountering a persistent issue during the boot process.
The system gets stuck at the UBI attach stage and fails to proceed further. I’ve captured the boot log, which clearly indicates that the UBI attachment process is not completing successfully. Unfortunately, this prevents the system from fully booting into OpenWrt.
Here are some additional details about my setup:
Processor: MT7621A
Storage: NAND flash
OpenWrt Version: 21.02
File System: UBIFS (enabled)
Issue: Boot process halts at UBI attach phase
Below is the relevant portion of the boot log for reference:
[ 0.000000] Linux version 5.4.171 (root@ubuntu) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r0-9a09694)) #0 SMP Thu Apr 14 03:28:57 2022
[ 0.000000] SoC Type: MediaTek MT7621 ver:1 eco:3
[ 0.000000] printk: bootconsole [early0] enabled
[ 0.000000] CPU0 revision is: 0001992f (MIPS 1004Kc)
[ 0.000000] MIPS: machine is WMD-7621Ultra-12816
[ 0.000000] Initrd not found or empty - disabling initrd
[ 0.000000] VPE topology {2} total 2
[ 0.000000] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[ 0.000000] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[ 0.000000] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.
[ 0.000000] Zone ranges:
[ 0.000000] Normal [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] HighMem empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x000000000fffffff]
[ 0.000000] percpu: Embedded 14 pages/cpu s26736 r8192 d22416 u57344
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 64960
[ 0.000000] Kernel command line: console=ttyS0,57600 ubi.mtd=rootfs,2048 rootfstype=squashfs ubi.block=0,rootfs ro root=/dev/ubiblock0_0
[ 0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes, linear)
[ 0.000000] Writing ErrCtl register=0000db56
[ 0.000000] Readback ErrCtl register=0000db56
[ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[ 0.000000] Memory: 250192K/262144K available (6149K kernel code, 219K rwdata, 1340K rodata, 1300K init, 243K bss, 11952K reserved, 0K cma-reserved, 0K highmem)
[ 0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[ 0.000000] rcu: Hierarchical RCU implementation.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[ 0.000000] NR_IRQS: 256
[ 0.000000] random: get_random_bytes called from start_kernel+0x36c/0x584 with crng_init=0
[ 0.000000] CPU Clock: 880MHz
[ 0.000000] clocksource: GIC: mask: 0xffffffffffffffff max_cycles: 0xcaf478abb4, max_idle_ns: 440795247997 ns
[ 0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 4343773742 ns
[ 0.000008] sched_clock: 32 bits at 440MHz, resolution 2ns, wraps every 4880645118ns
[ 0.015562] Console: colour dummy device 80x25
[ 0.024289] Calibrating delay loop... 583.68 BogoMIPS (lpj=1167360)
[ 0.064615] pid_max: default: 32768 minimum: 301
[ 0.073940] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.088338] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[ 0.106082] rcu: Hierarchical SRCU implementation.
[ 0.115999] smp: Bringing up secondary CPUs ...
[ 2.497770] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[ 2.497778] Primary data cache 32kB, 4-way, PIPT, no aliases, linesize 32 bytes
[ 2.497789] MIPS secondary cache 256kB, 8-way, linesize 32 bytes.
[ 2.497889] CPU1 revision is: 0001992f (MIPS 1004Kc)
[ 0.153051] Synchronize counters for CPU 1: done.
[ 0.212690] smp: Brought up 1 node, 2 CPUs
[ 0.225154] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.244425] futex hash table entries: 512 (order: 2, 16384 bytes, linear)
[ 0.258030] pinctrl core: initialized pinctrl subsystem
[ 0.269253] NET: Registered protocol family 16
[ 0.281251] rt2880-pinmux pinctrl: invalid group "gpio" for function "gpio"
[ 0.331178] vgaarb: loaded
[ 0.337040] usbcore: registered new interface driver usbfs
[ 0.347955] usbcore: registered new interface driver hub
[ 0.358488] usbcore: registered new device driver usb
[ 0.371141] clocksource: Switched to clocksource GIC
[ 0.390853] NET: Registered protocol family 2
[ 0.399791] IP idents hash table entries: 4096 (order: 3, 32768 bytes, linear)
[ 0.415290] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[ 0.431928] TCP established hash table entries: 2048 (order: 1, 8192 bytes, linear)
[ 0.447144] TCP bind hash table entries: 2048 (order: 2, 16384 bytes, linear)
[ 0.461271] TCP: Hash tables configured (established 2048 bind 2048)
[ 0.474012] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.486912] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[ 0.500984] NET: Registered protocol family 1
[ 0.509552] PCI: CLS 0 bytes, default 32
[ 0.606976] 4 CPUs re-calibrate udelay(lpj = 1163264)
[ 0.619618] workingset: timestamp_bits=14 max_order=16 bucket_order=2
[ 0.645638] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 0.661216] mt7621_gpio 1e000600.gpio: registering 32 gpios
[ 0.672688] mt7621_gpio 1e000600.gpio: registering 32 gpios
[ 0.684119] mt7621_gpio 1e000600.gpio: registering 32 gpios
[ 0.696085] Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
[ 0.710318] printk: console [ttyS0] disabled
[ 0.718768] 1e000c00.uartlite: ttyS0 at MMIO 0x1e000c00 (irq = 15, base_baud = 3125000) is a 16550A
[ 0.736703] printk: console [ttyS0] enabled
[ 0.736703] printk: console [ttyS0] enabled
[ 0.753252] printk: bootconsole [early0] disabled
[ 0.753252] printk: bootconsole [early0] disabled
[ 0.772802] 1e000d00.uartlite2: ttyS1 at MMIO 0x1e000d00 (irq = 16, base_baud = 3125000) is a 16550A
[ 0.791907] 1e000e00.uartlite3: ttyS2 at MMIO 0x1e000e00 (irq = 17, base_baud = 3125000) is a 16550A
[ 0.813020] mt7621-nand 1e003000.nand: Using programmed access timing: 31c07388
[ 0.827972] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xda
[ 0.840633] nand: Macronix MX30LF2G18AC
[ 0.848277] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[ 0.863365] mt7621-nand 1e003000.nand: ECC strength adjusted to 4 bits
[ 0.876401] mt7621-nand 1e003000.nand: Using programmed access timing: 21005134
[ 0.890985] mt7621-nand 1e003000.nand: Using programmed access timing: 21005134
[ 0.905548] Scanning device for bad blocks
[ 0.929940] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 769.1
[ 0.944144] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 769.2
[ 1.918684] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 11713.3
[ 2.034043] Bad eraseblock 263 at 0x0000020e0000
[ 4.309779] 5 fixed-partitions partitions found on MTD device mt7621-nand
[ 4.323309] Creating 5 MTD partitions on "mt7621-nand":
[ 4.333728] 0x000000000000-0x000000080000 : "u-boot"
[ 4.345069] 0x000000080000-0x000000100000 : "u-boot-env"
[ 4.357000] 0x000000100000-0x000000140000 : "factory"
[ 4.368468] 0x000000140000-0x000008b80000 : "firmware"
[ 4.382281] 2 uimage-fw partitions found on MTD device firmware
[ 4.394155] Creating 2 MTD partitions on "firmware":
[ 4.404070] 0x000000000000-0x0000002724d4 : "kernel"
[ 4.415396] 0x0000002724d4-0x000008a40000 : "rootfs"
[ 4.427429] mtd: device 5 (rootfs) set to be root filesystem
[ 4.438734] 1 squashfs-split partitions found on MTD device rootfs
[ 4.451055] 0x000000dc0000-0x000008a40000 : "rootfs_data"
[ 4.463871] 0x000008b80000-0x00000f780000 : "ubi"
[ 4.476500] libphy: Fixed MDIO Bus: probed
[ 4.509374] libphy: mdio: probed
[ 4.516071] mt7530 mdio-bus:1f: MT7530 adapts as multi-chip module
[ 4.530907] mtk_soc_eth 1e100000.ethernet: generated random MAC address 2a:4c:07:0a:a4:70
[ 4.548092] mtk_soc_eth 1e100000.ethernet eth0: mediatek frame engine at 0xbe100000, irq 20
[ 4.565083] usbcore: registered new interface driver qmi_wwan
[ 4.576626] usbcore: registered new interface driver cdc_wdm
[ 4.589066] i2c-mt7621 1e000900.i2c: clock 100 kHz
[ 4.600367] rt2880-pinmux pinctrl: pin io19 already requested by pinctrl; cannot claim for 1e140000.pcie
[ 4.619285] rt2880-pinmux pinctrl: pin-19 (1e140000.pcie) status -22
[ 4.631946] rt2880-pinmux pinctrl: could not request pin 19 (io19) from group pcie on device rt2880-pinmux
[ 4.651350] mt7621-pci 1e140000.pcie: Error applying setting, reverse things back
[ 4.666274] mt7621-pci: probe of 1e140000.pcie failed with error -22
[ 4.681826] NET: Registered protocol family 10
[ 4.692100] Segment Routing with IPv6
[ 4.699566] NET: Registered protocol family 17
[ 4.708727] 8021q: 802.1Q VLAN Support v1.8
[ 4.719300] mt7530 mdio-bus:1f: MT7530 adapts as multi-chip module
[ 4.743524] libphy: dsa slave smi: probed
[ 4.751958] mt7530 mdio-bus:1f wan (uninitialized): PHY [dsa-0.0:00] driver [Generic PHY]
[ 4.769810] mt7530 mdio-bus:1f lan1 (uninitialized): PHY [dsa-0.0:01] driver [Generic PHY]
[ 4.787815] mt7530 mdio-bus:1f lan2 (uninitialized): PHY [dsa-0.0:02] driver [Generic PHY]
[ 4.805834] mt7530 mdio-bus:1f lan3 (uninitialized): PHY [dsa-0.0:03] driver [Generic PHY]
[ 4.823948] mt7530 mdio-bus:1f lan4 (uninitialized): PHY [dsa-0.0:04] driver [Generic PHY]
[ 4.842035] mt7530 mdio-bus:1f: configuring for fixed/rgmii link mode
[ 4.859666] DSA: tree 0 setup
[ 4.866095] ubi0: default fastmap pool size: 50
[ 4.875173] ubi0: default fastmap WL pool size: 25
[ 4.884723] ubi0: attaching mtd5
[ 4.891162] ubi0: MTD device 5 is write-protected, attach in read-only mode
[ 4.905376] mt7530 mdio-bus:1f: Link is Up - 1Gbps/Full - flow control off
[ 4.931584] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.2
[ 4.945964] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.3
[ 4.960206] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 18:0, read only 0 bytes, retry
[ 4.982890] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.2
[ 4.997296] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.3
[ 5.011537] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 18:0, read only 0 bytes, retry
[ 5.034211] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.2
[ 5.048616] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.3
[ 5.062857] ubi0 warning: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 18:0, read only 0 bytes, retry
[ 5.085544] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.2
[ 5.099948] mt7621-nand 1e003000.nand: Uncorrectable ECC error at page 3044.3
[ 5.114172] ubi0 error: ubi_io_read: error -77 (ECC error) while reading 64 bytes from PEB 18:0, read 0 bytes
[ 5.133932] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.171 #0
[ 5.145869] Stack : 8fc35000 8007e260 80720000 8071bb84 80790000 8071bb4c 8071abc8 8fc2dc1c
[ 5.162487] 808d0000 8fc383a8 80768f23 806a3e9c 00000000 00000001 8fc2dbc0 e78b3a8c
[ 5.179099] 00000000 00000000 80910000 00000000 00000030 000000d4 342e3520 3137312e
[ 5.195711] 00000000 00000000 00000000 00020b2c 00000000 80790000 00000000 00000012
[ 5.212321] 00240000 00000000 00000000 00000000 00000003 80365598 00000000 808d0000
[ 5.228934] ...
[ 5.233785] Call Trace:
[ 5.238658] [<8000b64c>] show_stack+0x30/0x100
[ 5.247510] [<805e04c0>] dump_stack+0xa4/0xdc
[ 5.256165] [<803c4bf8>] ubi_io_read+0x274/0x3a0
[ 5.265341] [<803c4fc0>] ubi_io_read_ec_hdr+0x64/0x2ac
[ 5.275559] [<803cb0d0>] scan_peb+0x130/0x89c
[ 5.284215] [<803cca48>] ubi_attach+0x294/0x444
[ 5.293215] [<803bdcb4>] ubi_attach_mtd_dev+0x614/0xcd4
[ 5.303602] [<807a40d0>] ubi_init+0x180/0x3e4
[ 5.312258] [<800015f8>] do_one_initcall+0x7c/0x1dc
[ 5.321971] [<8078bf08>] kernel_init_freeable+0x1ec/0x2d0
[ 5.332702] [<805faef8>] kernel_init+0x10/0xf8
[ 5.341531] [<800067f8>] ret_from_kernel_thread+0x14/0x1c
[ 5.352555] UBI assert failed in ubi_io_read at 190 (pid 1)
[ 5.363657] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.4.171 #0
[ 5.375591] Stack : 8fc35000 8007e260 80720000 8071bb84 80790000 8071bb4c 8071abc8 8fc2dc1c
[ 5.392207] 808d0000 8fc383a8 80768f23 806a3e9c 00000000 00000001 8fc2dbc0 e78b3a8c
[ 5.408820] 00000000 00000000 80910000 00000000 00000030 000000e9 342e3520 3137312e
[ 5.425432] 00000000 00000000 00000000 00058c89 00000000 80790000 00000000 00000012
[ 5.442043] 00240000 00000000 00000000 00000000 00000003 80365598 00000000 808d0000
[ 5.458654] ...
[ 5.463504] Call Trace:
[ 5.468359] [<8000b64c>] show_stack+0x30/0x100
[ 5.477190] [<805e04c0>] dump_stack+0xa4/0xdc
[ 5.485846] [<803c4c30>] ubi_io_read+0x2ac/0x3a0
[ 5.495021] [<803c4fc0>] ubi_io_read_ec_hdr+0x64/0x2ac
[ 5.505233] [<803cb0d0>] scan_peb+0x130/0x89c
[ 5.513890] [<803cca48>] ubi_attach+0x294/0x444
[ 5.522892] [<803bdcb4>] ubi_attach_mtd_dev+0x614/0xcd4
[ 5.533277] [<807a40d0>] ubi_init+0x180/0x3e4
[ 5.541932] [<800015f8>] do_one_initcall+0x7c/0x1dc
[ 5.551626] [<8078bf08>] kernel_init_freeable+0x1ec/0x2d0
[ 5.562356] [<805faef8>] kernel_init+0x10/0xf8
[ 5.571185] [<800067f8>] ret_from_kernel_thread+0x14/0x1c
[ 5.582214] ubi0 error: ubi_attach_mtd_dev: failed to attach mtd5, error -5
[ 5.596141] UBI error: cannot attach mtd5
[ 5.604135] UBI: block: can't open volume on ubi0_-1, err=-19
[ 5.615600] hctosys: unable to open rtc device (rtc0)
[ 5.626518] /dev/root: Can't open blockdev
[ 5.634741] VFS: Cannot open root device "ubiblock0_0" or unknown-block(0,0): error -6
[ 5.650519] Please append a correct "root=" boot option; here are the available partitions:
[ 5.667171] 1f00 512 mtdblock0
[ 5.667175] (driver?)
[ 5.680214] 1f01 512 mtdblock1
[ 5.680217] (driver?)
[ 5.693245] 1f02 256 mtdblock2
[ 5.693249] (driver?)
[ 5.706276] 1f03 141568 mtdblock3
[ 5.706280] (driver?)
[ 5.719310] 1f04 2505 mtdblock4
[ 5.719313] (driver?)
[ 5.732342] 1f05 139062 mtdblock5
[ 5.732346] (driver?)
[ 5.745374] 1f06 127488 mtdblock6
[ 5.745377] (driver?)
[ 5.758405] 1f07 110592 mtdblock7
[ 5.758408] (driver?)
[ 5.771436] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 5.787898] Rebooting in 1 seconds..
From the log, it seems there might be an issue with the UBI initialization or the NAND flash itself, but I’m not entirely sure how to debug or resolve this.
Questions:
Has anyone encountered a similar issue when using UBIFS with OpenWrt on MT7621A devices?
Are there any specific configurations or patches required for UBI/UBIFS to work correctly with NAND flash on this platform?
Could this issue be related to the MTD partition layout or NAND flash initialization?
If anyone has experience with this setup or could provide guidance on debugging the issue, I’d greatly appreciate it. Please let me know if you need more information or additional logs to help diagnose the problem.
Thanks in advance for your help!