From f7f9e6bd20bbdca6f136d469d1712e6b124635b4 Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Sat, 17 Jul 2021 18:28:47 +0900 Subject: [PATCH] ramips: use parser_trx for Buffalo WCR-1166DS Buffalo WCR-1166DS uses trx-fomatted firmware and the custom magic number (0x5C436F74, "\Cot") is required for OpenWrt installation from OEM WebUI. But the current mtdsplit_trx doesn't support the custom magic number and fail to parse and split to kernel and rootfs when the factory image is flashed. Then, the kernel fails to mount rootfs automatically and panics. Before the commit fddc78bc116bc043fb5cd92dbc45cfd054c21af8, mtdsplit_trx was patched in ramips target and the device-specific magic number was supported only for WCR-1166DS[1]. But the patch was not inherited to the later version of the kernel and deleted by the above commit, then, the custom magic number support was broken. [1]: https://github.com/openwrt/openwrt/blob/05d6e92594c507dcd1f4be6c1bcb2282fe1abe1f/target/linux/ramips/patches-4.4/0400-mtd-mtdsplit-add-support-for-custom-trx-magic-for-Buffalo-WCR-1166DS.patch#L27 log (factory image): [ 1.165312] spi-mt7621 10000b00.spi: sys_freq: 193333333 [ 1.195782] spi-nor spi0.0: w25q128 (16384 Kbytes) [ 1.205353] 7 fixed-partitions partitions found on MTD device spi0.0 [ 1.217938] Creating 7 MTD partitions on "spi0.0": [ 1.227436] 0x000000000000-0x000000030000 : "u-boot" [ 1.238427] 0x000000030000-0x000000040000 : "u-boot-env" [ 1.250123] 0x000000040000-0x000000050000 : "factory" [ 1.261306] 0x000000050000-0x000000810000 : "firmware" [ 1.282051] 0x000000810000-0x000000fd0000 : "firmware2" [ 1.293594] 0x000000fd0000-0x000000fe0000 : "glbcfg" [ 1.304719] 0x000000fe0000-0x000000ff0000 : "board_data" ... [ 1.452424] /dev/root: Can't open blockdev [ 1.460619] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6 [ 1.475434] Please append a correct "root=" boot option; here are the available partitions: [ 1.491986] 1f00 192 mtdblock0 [ 1.491989] (driver?) [ 1.504938] 1f01 64 mtdblock1 [ 1.504941] (driver?) [ 1.517885] 1f02 64 mtdblock2 [ 1.517888] (driver?) [ 1.530831] 1f03 7936 mtdblock3 [ 1.530834] (driver?) [ 1.543777] 1f04 7936 mtdblock4 [ 1.543781] (driver?) [ 1.556724] 1f05 64 mtdblock5 [ 1.556727] (driver?) [ 1.569672] 1f06 64 mtdblock6 [ 1.569675] (driver?) [ 1.582617] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) [ 1.598976] Rebooting in 1 seconds.. This patch fixes this issue by using parser_trx with specifying custom magic number in dts instead of mtdsplit_trx. log (fixed factory image): [ 1.202044] spi-mt7621 10000b00.spi: sys_freq: 193333333 [ 1.225369] spi-nor spi0.0: w25q128 (16384 Kbytes) [ 1.235015] 7 fixed-partitions partitions found on MTD device spi0.0 [ 1.247603] Creating 7 MTD partitions on "spi0.0": [ 1.257106] 0x000000000000-0x000000030000 : "u-boot" [ 1.269447] 0x000000030000-0x000000040000 : "u-boot-env" [ 1.281192] 0x000000040000-0x000000050000 : "factory" [ 1.294208] 0x000000050000-0x000000810000 : "firmware" [ 1.305774] 2 trx partitions found on MTD device firmware [ 1.316540] Creating 2 MTD partitions on "firmware": [ 1.326399] 0x00000000001c-0x000000214754 : "linux" [ 1.336063] mtd: partition "linux" doesn't start on an erase/write block boundary -- force read-only [ 1.357070] 0x000000214754-0x0000007c0000 : "rootfs" [ 1.366994] mtd: partition "rootfs" doesn't start on an erase/write block boundary -- force read-only [ 1.386368] mtd: device 5 (rootfs) set to be root filesystem [ 1.398700] 1 squashfs-split partitions found on MTD device rootfs [ 1.411027] 0x000000520000-0x0000007c0000 : "rootfs_data" [ 1.422841] 0x000000810000-0x000000fd0000 : "firmware2" [ 1.436282] 0x000000fd0000-0x000000fe0000 : "glbcfg" [ 1.447408] 0x000000fe0000-0x000000ff0000 : "board_data" ... [ 1.611216] VFS: Mounted root (squashfs filesystem) readonly on device 31:5. Signed-off-by: INAGAKI Hiroshi --- target/linux/ramips/dts/mt7628an_buffalo_wcr-1166ds.dts | 3 ++- target/linux/ramips/image/mt76x8.mk | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/dts/mt7628an_buffalo_wcr-1166ds.dts b/target/linux/ramips/dts/mt7628an_buffalo_wcr-1166ds.dts index f8c024a85d..c3ea41bbf6 100644 --- a/target/linux/ramips/dts/mt7628an_buffalo_wcr-1166ds.dts +++ b/target/linux/ramips/dts/mt7628an_buffalo_wcr-1166ds.dts @@ -146,7 +146,8 @@ }; partition@50000 { - compatible = "openwrt,trx"; + compatible = "brcm,trx"; + brcm,trx-magic = <0x746f435c>; label = "firmware"; reg = <0x50000 0x7c0000>; }; diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk index 59559c4164..49b3c860dc 100644 --- a/target/linux/ramips/image/mt76x8.mk +++ b/target/linux/ramips/image/mt76x8.mk @@ -68,7 +68,7 @@ define Device/buffalo_wcr-1166ds BUFFALO_TAG_VERSION := 9.99 BUFFALO_TAG_MINOR := 9.99 IMAGES += factory.bin - IMAGE/sysupgrade.bin := trx | pad-rootfs | append-metadata + IMAGE/sysupgrade.bin := trx -M 0x746f435c | pad-rootfs | append-metadata IMAGE/factory.bin := trx -M 0x746f435c | pad-rootfs | append-metadata | \ buffalo-enc WCR-1166DS $$(BUFFALO_TAG_VERSION) -l | \ buffalo-tag-dhp WCR-1166DS JP JP | buffalo-enc-tag -l | buffalo-dhp-image -- 2.30.2