[SOLVED] Facing issue in mounting root fs on mtd block

Hi guys!
I'm in need of some help here,

Basically i have kernel partions (kernel and kernel_slave) and corresponding rootfs & rootfs data partitions for each of these kernel partitions. When i try to swap to the kernel_slave partition, i'm facing issues with the mounting of rootfs.

I have created the partitions as shown below:

> Creating 11 MTD partitions on "EN7512-SPI_NAND":
> 0x000000000000-0x000000080000 : "u-boot"
> 0x000000080000-0x0000001ea49a : "kernel"
> 0x000001080000-0x0000011c66c5 : "kernel_slave"
> 0x0000001ea49a-0x000000c67d5a : "rootfs"
> 0x0000011c66c5-0x000001c43f85 : "rootfs1"
> 0x00000de40000-0x00000e000000 : "reservearea"
> 0x00000e000000-0x00000e540000 : "rootfs_data"
> 0x00000e540000-0x00000ea80000 : "rootfs_data1"
> 0x00000ea80000-0x00000eac0000 : "art"
> 0x000000080000-0x00000ea80000 : "firmware1"
> 0x000001080000-0x00000ea80000 : "firmware2"

Error when mounting rootfs1 of kernel slave partition:

> 
> [    2.320000] 1f00             512 mtdblock0  (driver?)
> [    2.320000] 1f01            1449 mtdblock1  (driver?)
> [    2.330000] 1f02            1305 mtdblock2  (driver?)
> [    2.330000] 1f03           10742 mtdblock3  (driver?)
> [    2.340000] 1f04           10742 mtdblock4  (driver?)
> [    2.340000] 1f05            1792 mtdblock5  (driver?)
> [    2.350000] 1f06            5376 mtdblock6  (driver?)
> [    2.350000] 1f07            5376 mtdblock7  (driver?)
> [    2.360000] 1f08             256 mtdblock8  (driver?)
> [    2.360000] 1f09          239616 mtdblock9  (driver?)
> [    2.370000] 1f0a          223232 mtdblock10  (driver?)
> [    2.370000] No filesystem could mount root, tried:  squashfs
> [    2.380000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,4)
> [    2.380000] Machine restart ...
> [    2.380000] Disable xpon phy Tx power
> [    2.380000] 0xbfb00834=0xeff88ce0

Thanks in advance!

I faced recently a rather similar error while crafting DTS for a device in ath79, and the reason was malformed (too complicated) cmdline argument for the kernel.

Might be that your error is different, if your device boots ok with the default before your modifications, but in any case:

The solution for me was to ads a simple cmdline to the DTS.

See discussion from Porting guide ar71xx to ath79? - #208 by hnyman

Should look like this:

chosen {
    bootargs = "console=ttyS0,115200";
};

If i set this inside dt, i only get console=ttyS0,115200 rootfstype=squashfs,jffs2 as cmdline...

That fixed my similar issue.

Thanks for the reply hynman, but I dont have a dts based architechture to proceed with this approach. Is there an alternate solution to this??

Look at your kernel log.
You might have similar error regarding your kernel cmdline, that the kernel run attempts gets assigned to the wrong partition, as you have changed the partition order, or somthing similar.

I had this in the error situation:
Kernel command line: console=ttyS0,115200 root=31:02 rootfstype=jffs2 init=/sbin/init mtdparts=ar7100-nor0:256k(uboot),128k(env),6144k(rootfs),64k(caldata),1024k(uImage) rootfstype=squashfs,jffs2
Note the "root=31:02" = 1f02

You have modified the partition structure, so it might well be pointing to a wrong place.

You VFS error points to 1f04 = 31,04

Since this is not U-Boot based device, I dont see the other env args during boootup, except the below one
Kernel command line: es=1

The error " VFS error points to 1f04 = 31,04" is the partition /dev/mtd4 - rootfs1 which i currently want to mount when partition is swapped to kernel slave. And it would be /dev/mtd3 - rootfs when the partition is kernel.

Could this be a super block corruption in the beginning of the rootfs1 partition ?

You might get better help if you provide at least some details about your device and its boot loader...

Its basically a Sercomm board with their proprietary bootloader.
I'm facing problem only when tring to mount mtd4 (rootfs1) and not mtd3 (rootfs)

Let me attach the device boot logs, if it could be of any use for a clue,

decompress to 80020000 free_mem_ptr=80750000 free_mem_ptr_end=807B0000
from slave
Uncompressing [LZMA] ...  done.
[    0.000000]
[    0.000000] 11111111111111111111111111111
[    0.000000] 22222222222222222222222222
[    0.000000] 3333333333333333333333333
[    0.000000] Linux version 3.18.21 (root@eurchn-buildsvr-1) (gcc version 4.8.3 (OpenWrt/Linaro GCC 4.8-2014.04 unknown) ) #29 SMP Fri Jun 15 20:02:47 IST 2018
[    0.000000] ISPRAM0: PA=00360000,Size=00010000,enabled
[    0.000000] memsize:256MB
[    0.000000] EcoNet EN751221 SOC prom init
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019558 (MIPS 34Kc)
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 0ffe0000 @ 00020000 (usable)
[    0.000000] Wasting 1024 bytes for tracking 32 unused pages
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x00020000-0x0fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x00020000-0x0fffffff]
[    0.000000] Initmem setup node 0 [mem 0x00020000-0x0fffffff]
[    0.000000] Detected 1 available secondary CPU(s)
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] PERCPU: Embedded 9 pages/cpu @81203000 s4992 r8192 d23680 u36864
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 64992
[    0.000000] Kernel command line:  es=1
[    0.000000]
4444444444444444444444444
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Writing ErrCtl register=0004e086
[    0.000000] Readback ErrCtl register=0004e086
[    0.000000] nmi base is 8124c200
[    0.000000] Memory: 254928K/262016K available (3328K kernel code, 159K rwdata, 656K rodata, 200K init, 360K bss, 7088K reserved)
[    0.000000] Hierarchical RCU implementation.
[    0.000000]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS:64
[    0.000000]
[    0.000000] tc3162_time_init: Init bus timeout and watchdog
[    0.000000] plat_set_irq_affinity: cpu 0
[    0.000000] plat_set_irq_affinity: cpu 0 vpe_id 0
[    0.000000] plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 0, irq = 10
[    0.000000] plat_set_irq_affinity: irq num 10
[    0.000000] plat_set_irq_affinity: cpu 0
[    0.000000] plat_set_irq_affinity: cpu 0 vpe_id 0
[    0.000000] plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 0, irq = 33
[    0.000000] plat_set_irq_affinity: irq num 33
[    0.000000] CPU frequency 900.00 MHz
[    0.000000] plat_time_init: Entered, mips_timer_ack ptr is [8002ce88]
[    0.000000]  Using 200.000 MHz high precision timer.
[    0.000000] r4k_clockevent_init: setup_irq OK, irq is [31]
[    0.010000] console [ttyS0] enabled
[    0.010000] console [ttyS0] enabled
[    0.010000] bootconsole [early0] disabled
[    0.010000] bootconsole [early0] disabled
[    0.020000] Calibrating delay loop... 597.60 BogoMIPS (lpj=2988032)
[    0.080000] pid_max: default: 32768 minimum: 301
[    0.080000] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.090000] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.100000] 34K sync es set to 1.
[    0.100000] Config7: 0x80080500
[    0.100000] ISPRAM0: PA=00360000,Size=00010000,enabled
[    0.110000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.110000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.110000] CPU1 revision is: 00019558 (MIPS 34Kc)
[    0.190000] Synchronize counters for CPU 1: done.
[    0.190000] Brought up 2 CPUs
[    0.200000] NET: Registered protocol family 16
[    0.210000] MT7512_pcie_init
[    0.570000] check pcie link up status:
[    0.570000] isRC0_LINKUP=1
[    0.570000] isRC1_LINKUP=1
[    0.580000] registering PCI controller with io_map_base unset
[    0.620000] SCSI subsystem initialized
[    0.620000] usbcore: registered new interface driver usbfs
[    0.630000] usbcore: registered new interface driver hub
[    0.630000] usbcore: registered new device driver usb
[    0.640000] PCI host bridge to bus 0000:00
[    0.640000] pci_bus 0000:00: root bus resource [mem 0x20000000-0x2fffffff]
[    0.650000] pci_bus 0000:00: root bus resource [io  0x1f600000-0x1f61ffff]
[    0.650000] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.800000] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    0.810000] pci 0000:00:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
[    1.130000] pci 0000:00:00.0: BAR 8: assigned [mem 0x20000000-0x201fffff]
[    1.140000] pci 0000:00:01.0: BAR 8: assigned [mem 0x20200000-0x202fffff]
[    1.140000] pci 0000:01:00.0: BAR 0: assigned [mem 0x20000000-0x200fffff 64bit]
[    1.160000] pci 0000:01:00.0: BAR 6: assigned [mem 0x20100000-0x2010ffff pref]
[    1.170000] pci 0000:00:00.0: PCI bridge to [bus 01]
[    1.180000] pci 0000:00:00.0:   bridge window [mem 0x20000000-0x201fffff]
[    1.200000] pci 0000:02:00.0: BAR 0: assigned [mem 0x20200000-0x202fffff]
[    1.210000] pci 0000:00:01.0: PCI bridge to [bus 02]
[    1.220000] pci 0000:00:01.0:   bridge window [mem 0x20200000-0x202fffff]
[    1.250000] NET: Registered protocol family 8
[    1.250000] NET: Registered protocol family 20
[    1.260000] Switched to clocksource MIPS
[    1.260000] NET: Registered protocol family 2
[    1.270000] TCP established hash table entries: 2048 (order: 1, 8192 bytes)
[    1.270000] TCP bind hash table entries: 2048 (order: 2, 16384 bytes)
[    1.280000] TCP: Hash tables configured (established 2048 bind 2048)
[    1.290000] TCP: reno registered
[    1.290000] UDP hash table entries: 256 (order: 1, 8192 bytes)
[    1.300000] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
[    1.300000] NET: Registered protocol family 1
[    1.310000]
 mt7512_pcie_fixup: 0x1438 = 20000015
 mt7512_pcie_fixup: 0x3438 = 20200014
 mt7512_pcie_rc1_retrain: 70 = 0045b811 80 = 01608c12
[    1.330000] TC3162 hardware watchdog module loaded.
[    1.340000] futex hash table entries: 512 (order: 2, 16384 bytes)
[    1.350000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    1.350000] jffs2: version 2.2 (NAND) (ZLIB) (RTIME) (c) 2001-2006 Red Hat, Inc.
[    1.360000] msgmni has been set to 497
[    1.360000] io scheduler noop registered
[    1.370000] io scheduler deadline registered
[    1.370000] io scheduler cfq registered (default)
[    1.380000] ttyS0 at I/O 0xbfbf0003 (irq = 1, base_baud = 7200) is a TC3162
[    1.380000] IS_SPIFLASH=0x0, IS_NANDFLASH=0x2, (0xBFA10114)=0x6)
[    1.390000] Set SPI Clock to 50 Mhz
[    1.390000] spi_nand_probe: mfr_id=0x98, dev_id=0xcb
[    1.400000] Using Flash ECC.
[    1.400000] Detected SPI NAND Flash : _SPI_NAND_DEVICE_ID_TC58CVG1S3H, Flash Size=0x10000000
[    1.410000] spi nand flash
[    1.410000] tc3162: flash device 0x00400000 at 0x1fc00000
[    1.420000] EN7512 mtd init: spi nand probe enter
[    1.420000] [spi_nand_setup] : Enter
[    1.430000] nand: device found, Manufacturer ID: 0x98, Chip ID: 0xcb
[    1.430000] nand: Toshiba _SPI_NAND_DEVICE_ID_TC58CVG1S3H
[    1.440000] nand: 256MiB, SLC, page size: 2048, OOB size: 64
[    1.440000] nand_scan_ident ok
[    1.450000] [spi_nand_setup]: chip size =  0x10000000, erase_shift=0x11
[    1.500000] bmt pool size: 163
[    1.510000] BMT & BBT Init Success
[    1.520000] Leftsize size is 00ac0000, Left block is 00000056
[    1.530000] rootfs_data off is 0e000000, off block is 00000700
[    1.530000] Creating 11 MTD partitions on "EN7512-SPI_NAND":
[    1.540000] 0x000000000000-0x000000080000 : "u-boot"
[    1.550000] 0x000000080000-0x0000001ea45f : "kernel"
[    1.550000] 0x000001080000-0x000001880100 : "kernel_slave"
[    1.560000] 0x0000001ea45f-0x000000c67d1f : "rootfs1"
[    1.560000] 0x000001880100-0x0000022fd9c0 : "rootfs"
[    1.570000] 0x00000de40000-0x00000e000000 : "reservearea"
[    1.570000] 0x00000e000000-0x00000e540000 : "rootfs_data1"
[    1.580000] 0x00000e540000-0x00000ea80000 : "rootfs_data"
[    1.590000] 0x00000ea80000-0x00000eac0000 : "art"
[    1.590000] 0x000000080000-0x00000ea80000 : "firmware1"
[    1.600000] 0x000001080000-0x00000ea80000 : "firmware2"
[    1.600000] PPP generic driver version 2.4.2
[    1.610000] 751221 USB PHY config, enable port0 port1
[    1.610000] USB driver version: 751221.kernel3.3.20170822
[    1.620000] port 0 u2_slew_rate_calibration
[    1.660000] FM_OUT value = 156(0x0000009C)
[    1.680000] SR calibration value = 4
[    1.680000] port 1 u2_slew_rate_calibration
[    1.710000] FM_OUT value = 152(0x00000098)
[    1.730000] SR calibration value = 4
[    1.840000] xhci-hcd xhci-hcd: xHCI Host Controller
[    1.840000] xhci-hcd xhci-hcd: new USB bus registered, assigned bus number 1
[    2.080000] plat_set_irq_affinity: cpu 0
[    2.080000] plat_set_irq_affinity: cpu 0 vpe_id 0
[    2.080000] plat_set_irq_affinity: cpu 1
[    2.090000] plat_set_irq_affinity: cpu 1 vpe_id 0
[    2.090000] plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 1, irq = 18
[    2.100000] plat_set_irq_affinity: irq num 18
[    2.100000] xhci-hcd xhci-hcd: irq 18, io mem 0x1fb90000
[    2.110000] hub 1-0:1.0: USB hub found
[    2.110000] hub 1-0:1.0: 2 ports detected
[    2.120000] xhci-hcd xhci-hcd: xHCI Host Controller
[    2.120000] xhci-hcd xhci-hcd: new USB bus registered, assigned bus number 2
[    2.130000] hub 2-0:1.0: USB hub found
[    2.130000] hub 2-0:1.0: 1 port detected
[    2.140000] usbcore: registered new interface driver cdc_acm
[    2.140000] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[    2.150000] usbcore: registered new interface driver usbserial
[    2.160000] usbcore: registered new interface driver usbserial_generic
[    2.160000] usbserial: USB Serial support registered for generic
[    2.170000] usbcore: registered new interface driver ch341
[    2.180000] usbserial: USB Serial support registered for ch341-uart
[    2.180000] usbcore: registered new interface driver cp210x
[    2.190000] usbserial: USB Serial support registered for cp210x
[    2.190000] usbcore: registered new interface driver ftdi_sio
[    2.200000] usbserial: USB Serial support registered for FTDI USB Serial Device
[    2.210000] usbcore: registered new interface driver pl2303
[    2.210000] usbserial: USB Serial support registered for pl2303
[    2.220000] ip_tables: (C) 2000-2006 Netfilter Core Team
[    2.220000] arp_tables: (C) 2002 David S. Miller
[    2.230000] TCP: cubic registered
[    2.230000] NET: Registered protocol family 17
[    2.240000] bridge: automatic filtering via arp/ip/ip6tables has been deprecated. Update your scripts to load br_netfilter if you need this.
[    2.250000] Bridge firewalling registered
[    2.250000] 8021q: 802.1Q VLAN Support v1.8
[    2.290000] plat_set_irq_affinity: cpu 0
[    2.290000] plat_set_irq_affinity: cpu 0 vpe_id 0
[    2.290000] plat_set_irq_affinity: cpu 1
[    2.290000] plat_set_irq_affinity: cpu 1 vpe_id 0
[    2.290000] plat_set_irq_affinity: irq_vpe0 1 irq_vpe1 1, irq = 1
[    2.290000] plat_set_irq_affinity: irq num 1
[    2.310000]
 DIV >> the value of err: -22 flags: 32769 name: /dev/root, fs_name: squashfs root_mount_data: (null)List of all partitions:
[    2.320000] 1f00             512 mtdblock0  (driver?)
[    2.320000] 1f01            1449 mtdblock1  (driver?)
[    2.330000] 1f02            8192 mtdblock2  (driver?)
[    2.330000] 1f03           10742 mtdblock3  (driver?)
[    2.340000] 1f04           10742 mtdblock4  (driver?)
[    2.340000] 1f05            1792 mtdblock5  (driver?)
[    2.350000] 1f06            5376 mtdblock6  (driver?)
[    2.350000] 1f07            5376 mtdblock7  (driver?)
[    2.360000] 1f08             256 mtdblock8  (driver?)
[    2.360000] 1f09          239616 mtdblock9  (driver?)
[    2.370000] 1f0a          223232 mtdblock10  (driver?)
[    2.370000] No filesystem could mount root, tried:  DIV>> squashfs
[    2.380000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,4)
[    2.380000] Machine restart ...
[    2.380000] Disable xpon phy Tx power
[    2.380000] 0xbfb00834=0xeff88ce0
BGA IC
Xtal:1
DDR3 init.
DRAMC init done.
Calculate size.
DRAM size=512MB(supported max size)
Set new TRFC.
ddr-1066

7512DRAMC V1.1.2 (0)
Set SPI Flash Clock to 50 Mhz


EN751221 at Wed May 30 11:33:48 IST 2018 version 1.3 free bootbase

Memory size 512MB

Set SPI Flash Clock to 50 Mhz
spi_nand_probe: mfr_id=0x98, dev_id=0xcb
Dected SPI NAND Flash : _SPI_NAND_DEVICE_ID_TC58CVG1S3H, Flash Size=0x10000000
bmt pool size: 163
BMT & BBT Init Success

I would avoid using mtd partition names

kernel
rootfs
rootfs-data

without appended a digit.

OpenWrt uses this scheme to generate these partition from "firmware" on the fly during boot.

firmware = (kernel + rootfs) + rootfs_data
Some DTS have only the firmware entry.

rootfs_data is setup after kernel+rootfs beginning at next the next erase block of the flash

so, is there a problem with the address allocation sequence here?

How are you trying to switch booting from primary to slave? Might be that it requires more settings that you currently have.
Is that dual boot native OEM stuff? Does their gpl sources give any hints?

mvebu has dual boot and there it requires toggling several settings in uboot.

The toggling from primary to slave is based on a boot flag which is written into the reserve area of the flash. And changing this flag in the flash each time helps in toggle of partitions. (primary to slave)

Yeah, but is something additional needed?

Example about mvebu that I mentioned earlier:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/mvebu/base-files/lib/upgrade/linksys.sh;hb=HEAD#l5

It requires toggling both boot_part and also adjusting the bootcmd (select either nandboot or altnandboot script, which then contains the actual commands and has the correct root specification)

The specifics can be seen from u-boot env:

boot_part=2
bootcmd=run altnandboot

altnandboot=setenv bootargs console=ttyS0,115200 root=/dev/mtdblock8 ro rootdelay=1 rootfstype=jffs2 earlyprintk $mtdparts;nand read $defaultLoadAddr $altKernAddr $altKernSize; bootm $defaultLoadAddr

nandboot=setenv bootargs console=ttyS0,115200 root=/dev/mtdblock6 ro rootdelay=1 rootfstype=jffs2 earlyprintk $mtdparts;nand read $defaultLoadAddr $priKernAddr $priKernSize; bootm $defaultLoadAddr

My point is just that also your bootloader may require some more settings than just the one flag. I am not familiar with your dual-boot bootloader's internals, so this is pure hunch, but maybe something that you might evaluate.

Dual boot depends on the vendor

I have here some NAS boxes here which are using dual boot with Marvell Kirkwood and some portable wifi hotspot with mt7620.

Both devices using a different scheme ...

@Divya
Can you swap your mtd names for testing ?
kernel <-> kernel_slave
rootfs <-> rootfs1
rootfs_data1 <-> rootfs_data2
firmware1 <-> firmware2

I tried changing the mtd names out and tested, but still could face the same issue with the rootfs1 (of slave) which currently is renamed as rootfs.

My bad

so this is your layout from your first post, may from your vendor.
I've sorted these

0x000000000000-0x000000080000 : "u-boot"

0x000000080000-0x00000ea80000 : "firmware1"
0x000000080000-0x0000001ea49a : "kernel"
0x0000001ea49a-0x000000c67d5a : "rootfs"
0x00000e000000-0x00000e540000 : "rootfs_data"

0x000001080000-0x00000ea80000 : "firmware2"
0x000001080000-0x0000011c66c5 : "kernel_slave"
0x0000001ea49a-0x000000c67d5a : "rootfs1"
0x00000e540000-0x00000ea80000 : "rootfs_data1"

0x00000de40000-0x00000e000000 : "reservearea"
0x00000ea80000-0x00000eac0000 : "art"

So you have this OpenWrt compatible layout

0x000000000000-0x000000080000 : "u-boot"
0x000000080000-0x00000ea80000 : "firmware1"
0x000001080000-0x00000ea80000 : "firmware2"
0x00000de40000-0x00000e000000 : "reservearea"
0x00000ea80000-0x00000eac0000 : "art"

Note here is kernel/rootfs/rootfs_data missing !
These are generated on the fly from the firmware mtd partition only
The size of kernel and rootfs may change.
Thus the appended rootfs can not found with your "static" partition scheme.

I would suggest the check this

0x000000000000-0x000000080000 : "u-boot"
0x000000080000-0x00000ea80000 : "firmware-backup"
0x000001080000-0x00000ea80000 : "firmware"
0x00000de40000-0x00000e000000 : "reservearea"
0x00000ea80000-0x00000eac0000 : "art"

Hey ElektromAn,

The kernel tainted with the above layot,

 1.520000] Creating 5 MTD partitions on "EN7512-SPI_NAND":
[    1.520000] 0x000000000000-0x000000080000 : "u-boot"
[    1.530000] 0x000000080000-0x00000ea80000 : "firmware1"
[    1.530000] 0x000001080000-0x00000ea80000 : "firmware2"
[    1.540000] 0x00000de40000-0x00000e000000 : "reservearea"
[    1.550000] 0x00000ea80000-0x00000eac0000 : "art"
[    1.550000] Unhandled kernel unaligned access[#1]:
[    1.560000] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.18.21 #43
[    1.560000] task: 8f831568 ti: 8f834000 task.ti: 8f834000
[    1.570000] $ 0   : 00000000 00000072 ffffffed 00000001
[    1.570000] $ 4   : 80397c38 00000005 00000005 00000000
[    1.580000] $ 8   : 00000000 fffffffc 00000000 ffffffff
[    1.580000] $12   : 8f9ce940 00000000 00000000 00000006
[    1.590000] $16   : 00000005 00000020 80397c38 00000000
[    1.590000] $20   : 00000008 8042e300 8044a5d4 80460000
[    1.600000] $24   : 00000000 00000000
[    1.600000] $28   : 8f834000 8f837e18 00000039 80442784
[    1.610000] Hi    : 00000000
[    1.610000] Lo    : 00000000
[    1.610000] epc   : 8044278c tc3162_mtd_init+0x410/0x498
[    1.620000]     Not tainted
[    1.620000] ra    : 80442784 tc3162_mtd_init+0x408/0x498
[    1.630000] Status: 11000303 KERNEL EXL IE
[    1.630000] Cause : 00807c10
[    1.630000] BadVA : 00000025
[    1.640000] PrId  : 00019558 (MIPS 34Kc)
[    1.640000] Modules linked in:
[    1.640000] Process swapper/0 (pid: 1, threadinfo=8f834000, task=8f831568, tls=00000000)
[    1.650000] Stack : 1fc00000 00000030 00000000 00000000 30ffffff 00000000 30ffffff 80442358
          80441e88 8f9afa80 8044237c 00000000 80460000 800297a8 80450000 8013a5fc
          8044237c fffffff0 00000001 00000003 00000000 80430000 80450000 80405db8
          00000039 8006737c 00100100 00200200 00000000 00000000 81200c65 00000006
          00000006 00000000 80451348 00000006 8044a610 80460000 80451430 00000006
          ...
[    1.690000] Call Trace:
[    1.690000] [<8044278c>] tc3162_mtd_init+0x410/0x498
[    1.700000] [<800297a8>] do_one_initcall+0x140/0x200
[    1.700000] [<8042ed6c>] kernel_init_freeable+0x160/0x228
[    1.710000] [<80024ca0>] kernel_init+0x10/0x114
[    1.710000] [<80020078>] ret_from_kernel_thread+0x14/0x1c
[    1.720000]
[    1.720000]
Code: 00002021  1040000f  02402021 <8c430038> 90650000  90810000  24630001  14250004  24840001
[    1.730000] ---[ end trace ef3be0d7c9a219d2 ]---
[    1.730000] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
[    1.730000]
[    1.740000] Machine restart ...
[    1.740000] Disable xpon phy Tx power
[    1.750000] 0xbfb00834=0xeff88ce0

I see no mtd split action here
kernel, rootfs and rootfs_data are not generated
you should see something like this

[    3.005478] 4 cmdlinepart partitions found on MTD device spi0.0
[    3.011394] Creating 4 MTD partitions on "spi0.0":
[    3.016184] 0x000000000000-0x000000050000 : "u-boot"
[    3.022883] 0x000000050000-0x000000070000 : "u-boot-env"
[    3.029490] 0x000000070000-0x000000ff0000 : "firmware"
[    3.047465] 2 netgear-fw partitions found on MTD device firmware
[    3.053505] 0x000000070000-0x0000001a6440 : "kernel"
[    3.059618] 0x0000001a6440-0x000000ff0000 : "rootfs"
[    3.065969] mtd: device 4 (rootfs) set to be root filesystem
[    3.071701] 1 squashfs-split partitions found on MTD device rootfs
[    3.077870] 0x0000003e0000-0x000000ff0000 : "rootfs_data"
[    3.084641] 0x000000ff0000-0x000001000000 : "art"

please check your kernel config

$ grep MTD_SPLIT target/linux/ramips/mt7620/config-4.14 
CONFIG_MTD_SPLIT_FIRMWARE=y
CONFIG_MTD_SPLIT_JIMAGE_FW=y
CONFIG_MTD_SPLIT_SEAMA_FW=y
CONFIG_MTD_SPLIT_TPLINK_FW=y
CONFIG_MTD_SPLIT_UIMAGE_FW=y

There is one finding on this issue,
The partition following the kernel is alone treated as valid to mount the squash fs on.

The magic check "#define SQUASHFS_MAGIC_SWAP 0x68737173" on the rootfs (/dev/mtd3) is passed, since the first block of a valid fs partition should contain "hsqs/sqhs" as below:

root@OpenWrt:/# hexdump -C /dev/mtd3
      00000000  68 73 71 73 25 08 00 00  b8 b8 27 5b 00 00 04 00  |hsqs%.....'[....|

Whereas the partition which is failing to mount the squashfs on it has this block corrupted,


root@OpenWrt:/# hexdump -C /dev/mtd4
00000000  0e f3 54 96 b1 95 14 96  62 20 de e5 e2 bc 47 2f  |..T.....b ....G/|

How is this magic written on to this /dev/mtd3 partition is still a question!
Is there a way to replicate the same for the secondary rootfs /dev/mtd4 as well ?

I need some suggesions here!
Thanks in advance!

As you can see from your first post
The partition layout is changed dynamically

Please read

You have two firmware partitions.
Only one can have the name "firmware" and OpenWrt does the other magic.
And please don't assume the partition numbers in the wiki are fixed

Hey all,

Thanks for the responses and guidance.
The issue with the rootfs partition for the slave not being mounted was because of the corruption in the fs.
This corruption had occurred due to the size of the kernel slave partition which has lead to the corruption of the rootfs_slave partition following it.

The size to be allocated for the kernel partitions is now allocated dynamically.

This solved my problem!
Thanks :slight_smile:

1 Like