From patchwork Wed Nov 25 11:45:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 1406053 X-Patchwork-Delegate: ynezz@true.cz Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=CklWTUn0; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.a=rsa-sha256 header.s=b header.b=cDGIVeV+; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Cgzdt14SHz9sSf for ; Wed, 25 Nov 2020 22:47:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XAjDqvcigIIRWrCzMS43k0Ve0eRU2y0M1aBT0o7PVUY=; b=CklWTUn0f5X28WqMIu4DEOES7 wW4hANt7ueWENi5C8xqKdPYdYQXtvYX7hpcm8CWbxnapPCfF7Gg82mveazP2ZnrY4vNWQ3Gz5AZ8P SZzlrf6O38pUqKQo/zZs0M2zgvyf4xnnTy7mceqPbqoqfj8zScaHLB0KMNoYVJrk5Bv6EK44xE/J6 0UgS+9wjjSq3rM52XPHgpUgsoxUaMjDSez+mvjVNcZVOl5Hw+/Xv4+dTGoUkZWmiZXuf+9TcZReiX 6Tv3WHagZ6mvtXI6OVtRT50WPeceN9/a0XarQtuTaXHRCL5lly0TjCcRmbuLHL+v/gszE8VF9Q3XC tWroPseYQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khtFB-0003D1-25; Wed, 25 Nov 2020 11:45:53 +0000 Received: from canardo.mork.no ([2001:4641::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khtEn-00034K-1X for openwrt-devel@lists.openwrt.org; Wed, 25 Nov 2020 11:45:33 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id 0APBjRdF026792 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Wed, 25 Nov 2020 12:45:27 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1606304727; bh=z7znH6bHLlTyuDslKepnlCXPjWQUfepFuh38SQC/H5M=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=cDGIVeV+ShwD5E0eHKCDnxmTwvdDhi3x7rhSL4JxTYnsc6aup48CLqAQFxX8621xx GIpV1AxvGnOhlBGx+qFCOA7Fl1pVQZrq2NlTu9zbV0UjqX9NwJY9ede6igIf8Tmdgu Q10K4goAfM02FcDztPpHfP81kpUiFaqJxZbMLa7Y= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id 0APBjR5J026785; Wed, 25 Nov 2020 12:45:27 +0100 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH 7/8] kernel: mtdsplit_uimage: replace "netgear,uimage" parser Date: Wed, 25 Nov 2020 12:45:10 +0100 Message-Id: <20201125114511.26663-8-bjorn@mork.no> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201125114511.26663-1-bjorn@mork.no> References: <20201125114511.26663-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.102.4 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201125_064529_709378_919C3787 X-CRM114-Status: GOOD ( 14.00 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The "netgear,uimage" parser can be replaced by the generic parser using device specific ih-magic and ih-type properties. Device tree properties for the following devices have not been set, as they have been dropped from OpenWrt with the removal of the ar71xx target: FW_MAGIC_WNR2000V1 0x32303031 FW_MAGIC_WNR2000V4 0x32303034 FW_MAGIC_WNR1000V2_VC 0x31303030 FW_MAGIC_WPN824N 0x31313030 Signed-off-by: Bjørn Mork --- .../ath79/dts/ar7161_netgear_wndr3700-v2.dts | 4 +- .../ath79/dts/ar7161_netgear_wndr3700.dts | 4 +- .../ath79/dts/ar7161_netgear_wndr3800.dts | 4 +- .../ath79/dts/ar7161_netgear_wndr3800ch.dts | 4 +- .../ath79/dts/ar7161_netgear_wndrmac-v1.dts | 4 +- .../ath79/dts/ar7161_netgear_wndrmac-v2.dts | 4 +- .../ath79/dts/ar7240_netgear_wnr1000-v2.dts | 4 +- .../ath79/dts/ar7240_netgear_wnr612-v2.dtsi | 4 +- .../ath79/dts/ar7241_netgear_wnr2000-v3.dts | 4 +- .../ath79/dts/ar7241_netgear_wnr2200-16m.dts | 4 +- .../ath79/dts/ar7241_netgear_wnr2200-8m.dts | 4 +- .../linux/ath79/dts/ar9344_netgear_wndr.dtsi | 4 +- .../drivers/mtd/mtdsplit/mtdsplit_uimage.c | 66 ------------------- 13 files changed, 36 insertions(+), 78 deletions(-) diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts index 0543c471130c..70445b080907 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700-v2.dts @@ -22,7 +22,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0xf80000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373031>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts index 955dd2edf0f1..5d89cf5a2bd7 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndr3700.dts @@ -22,7 +22,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0x780000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373030>; + ih-type = <7>; }; art: partition@7f0000 { diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts index 41fe401ddb01..387374f1769a 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800.dts @@ -23,7 +23,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0xf80000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373031>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts index 79569adba87f..d31e98c21c11 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndr3800ch.dts @@ -23,7 +23,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0xf80000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373031>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts index 65d2393c67a3..9cda726b33ae 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v1.dts @@ -22,7 +22,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0xf80000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373031>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts index f7641203cf01..b0b111ff623f 100644 --- a/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts +++ b/target/linux/ath79/dts/ar7161_netgear_wndrmac-v2.dts @@ -23,7 +23,9 @@ partition@70000 { label = "firmware"; reg = <0x070000 0xf80000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373031>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts b/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts index d67af04d1cbd..4d6076a68a77 100644 --- a/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts +++ b/target/linux/ath79/dts/ar7240_netgear_wnr1000-v2.dts @@ -160,7 +160,9 @@ partition@50000 { label = "firmware"; reg = <0x50000 0x3a0000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x31303031>; + ih-type = <7>; }; art: partition@3f0000 { diff --git a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi index 44dbe9c55ec7..a419ef152968 100644 --- a/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi +++ b/target/linux/ath79/dts/ar7240_netgear_wnr612-v2.dtsi @@ -91,7 +91,9 @@ }; partition@50000 { - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x32303631>; + ih-type = <7>; reg = <0x50000 0x3a0000>; label = "firmware"; }; diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts index 1b124f3f2e6b..ef04190182a3 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2000-v3.dts @@ -163,7 +163,9 @@ partition@50000 { label = "firmware"; reg = <0x50000 0x3a0000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x32303033>; + ih-type = <7>; }; art: partition@3f0000 { diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts index 2c7443654788..822bd27b69e1 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-16m.dts @@ -22,7 +22,9 @@ partition@50000 { label = "firmware"; reg = <0x50000 0xfa0000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x32323030>; + ih-type = <7>; }; art: partition@ff0000 { diff --git a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts index c23cb6e00250..628fd8f4957e 100644 --- a/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts +++ b/target/linux/ath79/dts/ar7241_netgear_wnr2200-8m.dts @@ -22,7 +22,9 @@ partition@50000 { label = "firmware"; reg = <0x50000 0x7a0000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x32323030>; + ih-type = <7>; }; art: partition@7f0000 { diff --git a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi index 92b0beccd7c9..e594faa98427 100644 --- a/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi +++ b/target/linux/ath79/dts/ar9344_netgear_wndr.dtsi @@ -161,7 +161,9 @@ partition@6c0000 { label = "firmware"; reg = <0x6c0000 0x1900000>; - compatible = "netgear,uimage"; + compatible = "denx,uimage"; + ih-magic = <0x33373033>; + ih-type = <7>; }; partition@1fc0000 { diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c index 8b07b35d9bd5..20aae10a0a2a 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -34,7 +34,6 @@ #define IH_OS_LINUX 5 /* Linux */ #define IH_TYPE_KERNEL 2 /* OS Kernel Image */ -#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image */ /* * Legacy format image header, @@ -276,70 +275,6 @@ static struct mtd_part_parser uimage_generic_parser = { .type = MTD_PARSER_TYPE_FIRMWARE, }; -#define FW_MAGIC_WNR2000V1 0x32303031 -#define FW_MAGIC_WNR2000V3 0x32303033 -#define FW_MAGIC_WNR2000V4 0x32303034 -#define FW_MAGIC_WNR2200 0x32323030 -#define FW_MAGIC_WNR612V2 0x32303631 -#define FW_MAGIC_WNR1000V2 0x31303031 -#define FW_MAGIC_WNR1000V2_VC 0x31303030 -#define FW_MAGIC_WNDR3700 0x33373030 -#define FW_MAGIC_WNDR3700V2 0x33373031 -#define FW_MAGIC_WPN824N 0x31313030 - -static ssize_t uimage_verify_wndr3700(u_char *buf, size_t len, u32 ih_magic, u32 ih_type) -{ - struct uimage_header *header = (struct uimage_header *)buf; - uint8_t expected_type = IH_TYPE_FILESYSTEM; - - switch (be32_to_cpu(header->ih_magic)) { - case FW_MAGIC_WNR612V2: - case FW_MAGIC_WNR1000V2: - case FW_MAGIC_WNR1000V2_VC: - case FW_MAGIC_WNR2000V1: - case FW_MAGIC_WNR2000V3: - case FW_MAGIC_WNR2200: - case FW_MAGIC_WNDR3700: - case FW_MAGIC_WNDR3700V2: - case FW_MAGIC_WPN824N: - break; - case FW_MAGIC_WNR2000V4: - expected_type = IH_TYPE_KERNEL; - break; - default: - return -EINVAL; - } - - if (header->ih_os != IH_OS_LINUX || - header->ih_type != expected_type) - return -EINVAL; - - return 0; -} - -static int -mtdsplit_uimage_parse_netgear(struct mtd_info *master, - const struct mtd_partition **pparts, - struct mtd_part_parser_data *data) -{ - return __mtdsplit_parse_uimage(master, pparts, data, - uimage_verify_wndr3700); -} - -static const struct of_device_id mtdsplit_uimage_netgear_of_match_table[] = { - { .compatible = "netgear,uimage" }, - {}, -}; - -static struct mtd_part_parser uimage_netgear_parser = { - .owner = THIS_MODULE, - .name = "netgear-fw", - .of_match_table = mtdsplit_uimage_netgear_of_match_table, - .parse_fn = mtdsplit_uimage_parse_netgear, - .type = MTD_PARSER_TYPE_FIRMWARE, - -}; - /************************************************** * Edimax **************************************************/ @@ -396,7 +331,6 @@ static struct mtd_part_parser uimage_edimax_parser = { static int __init mtdsplit_uimage_init(void) { register_mtd_parser(&uimage_generic_parser); - register_mtd_parser(&uimage_netgear_parser); register_mtd_parser(&uimage_edimax_parser); return 0;