MTD devices not shown the same way in OpenWrt

Hi,

First, I really don't have much experience in OpenWRT and embedded system that's why I am asking this here, it's over my knowledge level right now.

I have a Meraki MR32 that I flashed with OpenWrt, I want to use kexec to boot another kernel from within OpenWrt, the problem is that mtd partitions are not visible in OpenWrt.

Here's /proc/mtd from Meraki first stage bootloader, right before OpenWrt is booted using kexec:

/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "U-boot"
mtd1: 00300000 00020000 "bootkernel1"
mtd2: 00100000 00020000 "senao_nvram"
mtd3: 00300000 00020000 "bootkernel2"
mtd4: 07780000 00020000 "ubi"
mtd5: 0024d000 0001f000 "part.safe"
mtd6: 009e2000 0001f000 "part.old"
mtd7: 00345000 0001f000 "rootfs"
mtd8: 0081d000 0001f000 "storage"
mtd9: 009f9000 0001f000 "diagnostic1"
mtd10: 04f32000 0001f000 "rootfs_data"

But after OpenWrt started:

root@OpenWrt:/tmp# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00100000 00020000 "u-boot"
mtd1: 00300000 00020000 "bootkernel1"
mtd2: 00100000 00020000 "nvram"
mtd3: 00300000 00020000 "bootkernel2"
mtd4: 07780000 00020000 "ubi"

How can I see all the MTD devices that exists on the flash under OpenWrt ?

Thanks!

The other problem is you already have booted the OpenWrt's Kernel on the device's CPU.

Mount them.

There's a serious caveat. If you can mount, be sure you realize what each partition does. Since you already seem lost trying to boot a CPU twice, I don't want to elaborate on this or accessing those partitions thru OpenWrt fruther if booting is your goal (which obviously isn't possible).

Hi lleachii,

I probably didn't explain myself correctly.

Kexec is a system call that enables you to load and boot into another kernel from the currently running kernel. This is useful for kernel developers or other people who need to reboot very quickly without waiting for the whole BIOS boot process to finish.

This is how the Meraki firmware works, from u-boot is starts the first kernel ( bootkernel2 in this case ), after bootkernel2 is running then is using kexec to boot another kernel that is stored in part.safe or part.old.

I want to do the same thing from OpenWrt in order to boot the kernel stored in mtd8 device ( diagnostic1 ).

Here's the output from using kexec to boot another kernel from within the running one:

[    2.680000] UBIFS: recovery needed
[    2.840000] UBIFS: recovery completed
[    2.840000] UBIFS: mounted UBI device 0, volume 3, name "storage"
[    2.850000] UBIFS: file system size:   7364608 bytes (7192 KiB, 7 MiB, 58 LEBs)
[    2.850000] UBIFS: journal size:       1015809 bytes (992 KiB, 0 MiB, 6 LEBs)
[    2.860000] UBIFS: media format:       w4/r0 (latest is w4/r0)
[    2.870000] UBIFS: default compressor: lzo
[    2.870000] UBIFS: reserved for root:  347848 bytes (339 KiB)
Press S for a sh[    2.940000] Mapping ell, or another 2412544magic key...

 bytes for /dev/mtdblock/part.safe
Description: ARM OpenWrt Linux-5.4.188
[    3.380000] find_itb_subimage: Ignoring unknown algorithm crc32
[    3.390000] find_itb_subimage: error finding ramdisk@1: FDT_ERR_NOTFOUND
Description: ARM[    3.400000] find_itb_subimage OpenWrt meraki_: Ignoring unknown algorithm mr32 device treecrc32 blob

**[    3.410000] UBIFS: un-mount UBI device 0, volume 3**
**[    3.420000] Starting new kernel**
**[    3.420000] Bye!**
**Uncompressing Linux... done, booting the kernel.**
**[    0.000000] Booting Linux on physical CPU 0x0**
[    0.000000] Linux version 5.4.188 (builder@buildhost) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r16554-1d4dea6d4f)) #0 SMP Sat Apr 16 12:59:34 2022
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Meraki MR32
[    0.000000] earlycon: ns16550 at MMIO 0x18000300 (options '115200n8')
[    0.000000] printk: bootconsole [ns16550] enabled

I believe the problem of not seeing all the mtd devices is due to the flash layout or something, as I said, those thing are kind of new to me.

Thanks!