Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1617 - Sysupgrade failure due to double detection of mtd partitions (ubi, kernel) #6549

Closed
openwrt-bot opened this issue Jun 27, 2018 · 9 comments
Labels

Comments

@openwrt-bot
Copy link

hnyman:

Noticed in master builds for ipq806x R7800 - r7344 and r7314

ipq806x R7800 detects two mtd partitions twice, which leads into failing sysupgrade:

Writing from to kernel ... ubiattach: error!: strtoul: unable to parse the number '6 mtd10' ubiattach: error!: bad MTD device number: "6 mtd10" ubiformat: error!: more then one MTD device specified (use -h for help) ubiattach: error!: strtoul: unable to parse the number '6 mtd10' ubiattach: error!: bad MTD device number: "6 mtd10" libubi: error!: "/dev/" is not a character device ubimkvol: error!: error while probing "/dev/" error 22 (Invalid argument) cannot create rootfs volume

The reason is that mtd detects kernel and ubi inside "firmware",
which leads into wrong parsing of "mtd6 mtd10" into "6 mtd10".

Kernel log:

[ 1.048426] 9 fixed-partitions partitions found on MTD device qcom_nand.0
[ 1.055861] Creating 9 MTD partitions on "qcom_nand.0":
[ 1.062716] 0x000000000000-0x000000c80000 : "qcadata"
[ 1.089741] 0x000000c80000-0x000001180000 : "APPSBL"
[ 1.098876] 0x000001180000-0x000001200000 : "APPSBLENV"
[ 1.100482] 0x000001200000-0x000001340000 : "art"
[ 1.105764] 0x000001340000-0x000001480000 : "artbak"
[ 1.110595] 0x000001480000-0x000001880000 : "kernel"
[ 1.120242] 0x000001880000-0x000007900000 : "ubi"
[ 1.282232] 0x000007900000-0x000008000000 : "reserve"
[ 1.294766] 0x000001480000-0x000007900000 : "firmware"
[ 1.465539] no rootfs found after FIT image in "firmware"
[ 2.421008] 2 uimage-fw partitions found on MTD device firmware
[ 2.421078] 0x000001480000-0x000001880000 : "kernel"
[ 2.434540] 0x000001880000-0x000007900000 : "ubi"

/proc/mtd:

OpenWrt SNAPSHOT, r7344-6e3c2d7

root@OpenWrt:/#
root@OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00c80000 00020000 "qcadata"
mtd1: 00500000 00020000 "APPSBL"
mtd2: 00080000 00020000 "APPSBLENV"
mtd3: 00140000 00020000 "art"
mtd4: 00140000 00020000 "artbak"
mtd5: 00400000 00020000 "kernel"
mtd6: 06080000 00020000 "ubi"
mtd7: 00700000 00020000 "reserve"
mtd8: 06480000 00020000 "firmware"
mtd9: 00400000 00020000 "kernel"
mtd10: 06080000 00020000 "ubi"

I have tested my own build of r7275 from 18 June, and that is still ok.
Buildbot snapshot r7344 of today is broken,
and also my own build of r7314 two days ago is also broken.

Regression range is currently r7275-512c57e7f3 - r7314-c4aadbdaf6

@openwrt-bot
Copy link
Author

hnyman:

The culprit may be:

+CONFIG_MTD_SPLIT_UIMAGE_FW=y

in the commit in the regression range:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=4645a6d3183ad27ab1ca74ed82495ac8f6019331

ipq806x: add support for NEC Aterm WG2600HP

@openwrt-bot
Copy link
Author

hnyman:

I built a test build of r7344 with "CONFIG_MTD_SPLIT_UIMAGE_FW=y" reverted in target/linux/ipq806x/config-4.14, and that fixes sysupgrade again for R7800.

@openwrt-bot
Copy link
Author

mkresin:

The mentioned commit most likely triggered an issue which was there from the beginning.

Indeed, a partition named "firmware" is treated special if SPLIT_UIMAGE_FW is enabled. The question is why do we have a partition named firmware for the ipq806x boards? If a "kernel" and "ubi" partition exists, are "firmware" partition isn't expected to exists.

The fix is as easy as rename the partition to something different than firmware. I might can propose a better name if I know about the content of the partition.

@openwrt-bot
Copy link
Author

hnyman:

The fix is as easy as rename the partition to something different than firmware. I might can propose a better name if I know about the content of the partition.

The contents is easy: it is kernel+ubi combined, the same flash area.

https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8065-r7800.dts;hb=HEAD#l315

DTS defines "kernel", "ubi", and then also those combined as "firmware".

For some reason it has been defined there that way since the beginning.
(and is found that way already in the OEM firmware.)

If that is not needed for sysupgrade or Openwrt functionality, we might as well get rid of it.

@openwrt-bot
Copy link
Author

hnyman:

Note that the same additional definition of "firmware" is found also in R7500, R7500v2, D7800. I guess that in really many Netgear routers.

My hunch is that it has been needed in the age of the single file sysupgrade, instead of flashing kernel+ubi separately.

@openwrt-bot
Copy link
Author

mkresin:

The contents is easy: it is kernel+ubi combined, the same flash area.

Danged! Suspected something like this, but had a look at the wrong dts file.

Are you going to send a patch?

@openwrt-bot
Copy link
Author

hnyman:

Are you going to send a patch?

Patch to do what?
remove the whole definition?
or rename it? (e.g. "rawfirmware")

have you any idea if "firmware" is used for anything in the current sysupgrade scene, or otherwise? Are "kernel" and "ubi" enough?

Renaming it will remove functionality from any existing script etc. in any case, but I just wonder if the combined partition definition might be needed for something so that it would make sense to rename it.

@openwrt-bot
Copy link
Author

mkresin:

remove the whole definition?

Yes, please remove the "firmware" partition definition and test if everything works again.

have you any idea if "firmware" is used for anything in the current sysupgrade scene, or otherwise? Are "kernel" and "ubi" enough?

The "firmware" partition isn't used for NAND based boards with ubi. The logic within the [[https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/base-files/files/lib/upgrade/nand.sh;hb=681e825f8fbf59a32c3b09810b2a3fef29880c63#l1|nand upgrade scripts]] is the following:

  • if a "kernel" partition exists, write the kernel to the partition
  • if a partition named "ubi" exists
    • if no "kernel" partition exists, create an ubi volume "kernel" and store the kernel
    • create "rootfs" ubi volume and store rootfs
    • create rootfs_data ubi volume

The partition names "ubi" and "kernel" can be overridden, but I haven't seen something like that in the ipq806x sysupgrade scripts.

@openwrt-bot
Copy link
Author

hnyman:

Thanks for explanation, I had come to the same conclusion:

As far as I can see, target/linux/ipq806x/base-files/lib/upgrade/platform.sh does define "firmware" as a shell variable, but as the mentioned Netgear routers use nand_do_upgrade instead of default_do_upgrade, I think that the variable is not actually used for anything.

So that might indicate that the partition definition might be deleted from DTS.

I will test removing the "firmware" partition definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant