Wrong MTD partitions detected in Huawei B593u-12

Hi,

I am working on getting Huawei B593u-12 supported in OpenWrt. I can build an ELF image with initram that boots over TFTP. And I can flash my own TRX through the “Broadcom - CFE miniWeb Server”. This image will boot, but the MTD partitions recognized by OpenWrt are always different than from factory (both when booting ELF as well as when flashing). Ultimately there are many errors and the device halts.

For overall info (bootlogs, etc) on Huawei B593u-12 see: https://openwrt.org/toh/huawei/b593u-12

For the FACTORY IMAGE I get:

# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00040000 "nvram"
mtd1: 00080000 00040000 "auxfs"
mtd2: 0089eaa8 00040000 "rootfs"
# [Relevant subset of dmesg, see full log on the link above]
<4>[4294667.296000] Sflash type : 0x100 ; Sflash devid : 0x17 ; Sflash manuid : 0x1
<5>[4294667.751000] sflash: squash filesystem with lzma found at block 1669
<5>[4294667.752000] Creating 3 MTD partitions on "sflash":
<5>[4294667.753000] 0x00fc0000-0x01000000 : "nvram"
<5>[4294667.754000] 0x00f80000-0x01000000 : "auxfs"
<5>[4294667.755000] 0x001a1558-0x00a40000 : "rootfs"

Note that the sum of the size of all mtd is around 9,5 MB, i.e. much less than 16MB Flash.

For the OPENWRT IMAGE I get

[    0.000000]  bcm47xx_soc: bus0: Found M25FL128 serial flash (size: 16384KiB, blocksize: 0x10000, blocks: 256)
[    0.873578] 3 bcm47xxpart partitions found on MTD device bcm47xxsflash
[    0.880275] Creating 3 MTD partitions on "bcm47xxsflash":
[    0.885834] 0x000000000000-0x000000040000 : "boot"
[    0.897032] 0x000000040000-0x000000ff0000 : "firmware"
[    0.904023] 3 trx partitions found on MTD device firmware
[    0.909609] Creating 3 MTD partitions on "firmware":
[    0.914721] 0x00000000001c-0x00000000011c : "loader"
[    0.924637] 0x00000000011c-0x00000021f400 : "linux"
[    0.933063] 0x00000021f400-0x000000fb0000 : "rootfs"
[    0.939879] mtd: device 4 (rootfs) set to be root filesystem
[    0.945800] 1 squashfs-split partitions found on MTD device rootfs
[    0.952152] 0x0000003c0000-0x000000fb0000 : "rootfs_data"
[    0.962730] 0x000000ff0000-0x000001000000 : "nvram"
[   29.275109] Timeout waiting for flash to be ready!
[   29.280045] jffs2: Erase at 0x00bb0000 failed immediately: errno -16
..... The last 2 messages repeat almost 100 times .....
[  138.187107] Timeout waiting for flash to be ready!
[  138.192035] jffs2: Erase at 0x00010000 failed immediately: errno -16
[  138.289623] done.
[  138.291697] jffs2: notice: (767) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[  138.481707] overlayfs: upper fs does not support tmpfile.

Note that the erasize is different.

I tried compiling with a erasesize of 00040000, but I still get similar messages.

I tried forcing the MTD partitions through the kernel command line. I see these arguments in DMESG, so it got succesfully compiled in. But I still dont get the right MTD partitions

# CONFIG_CMDLINE="noinitrd console=ttyS0,115200 mtdparts=bcm47xxsflash:1709400(RESERVED_1),9038504(rootfs),5505024(RESERVED_2),262144(auxfs),262144(nvram)"
# CONFIG_CMDLINE="noinitrd console=ttyS0,115200 mtdparts=bcm47xxsflash:1770k(reserved1),8825k(rootfs),5376k(reserved2),256k(auxfs),256k(nvram)"

Any ideas what the problem is, and how to fix this?

Thank you and best regards!

Hi,

short update: removing the following pending patches from target\linux\generic\pending-5.4 makes the errors go away:

  • 401-mtd-add-support-for-different-partition-parser-types.patch
  • 402-mtd-use-typed-mtd-parsers-for-rootfs-and-firmware-split.patch
  • 403-mtd-hook-mtdsplit-to-Kbuild.patch
  • 404-mtd-add-more-helper-functions.patch

I only wanted to remove the first one, but the other ones seem to require the first one.

Here is the new relevant output from dmesg

[    0.871790] 3 bcm47xxpart partitions found on MTD device bcm47xxsflash
[    0.878478] Creating 3 MTD partitions on "bcm47xxsflash":
[    0.884046] 0x000000000000-0x000000040000 : "boot"
[    0.895252] 0x000000040000-0x000000ff0000 : "firmware"
[    0.902113] 3 trx partitions found on MTD device firmware
[    0.907714] Creating 3 MTD partitions on "firmware":
[    0.912826] 0x00000000001c-0x00000000011c : "loader"
[    0.922765] 0x00000000011c-0x00000021e000 : "linux"
[    0.930430] 0x00000021e000-0x000000fb0000 : "rootfs"
[    0.937106] mtd: device 4 (rootfs) set to be root filesystem
[    0.945837] 0x000000ff0000-0x000001000000 : "nvram"
[    1.046248] VFS: Mounted root (squashfs filesystem) readonly on device 31:4.
[   10.912981] mount_root: Could not open mtd device: /dev/mtd4
[   10.919193] mount_root: reading rootfs failed
[   10.923902] mount_root: mounting /dev/root

So the first boot completes. However, nvram gets overwrittern or corrupted, so no second boot.

Any ideas what is missing?

[   29.280045] jffs2: Erase at 0x00bb0000 failed immediately: errno -16
..... The last 2 messages repeat almost 100 times .....

This was probably caused by the commit 15a0701cdde8 ("kernel: rewrite run_parsers_by_type() to use add_mtd_partitions()"). Shold be fixed now.

[   10.912981] mount_root: Could not open mtd device: /dev/mtd4
[   10.919193] mount_root: reading rootfs failed
[   10.923902] mount_root: mounting /dev/root

This was probably caused by removing OpenWrt-required patches.


Basically: try more recent OpenWrt (it has breaking commit reverted) and don't manually drop patches.

1 Like