From patchwork Wed Jul 17 09:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 1133215 X-Patchwork-Delegate: zajec5@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.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=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m3xKzKSh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A014926G"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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 45pXCN2RCpz9sBF for ; Wed, 17 Jul 2019 19:34:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:Message-Id:Date:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0oaxXVMnv3V71ugXZDrvKvDr//aFjGtoiz9fieu6umk=; b=m3xKzKSh50kzvu 7faRToXFIcLoMCfwrtJyt0186pCuZy6qxlzyV898umnWpGEvsOA4Ki8JRfwKeeQ4ELu211TGEHSAh 69zQMP41h/DvchmgyM6xdU9Q5Zpsd/F3ZWAPab5SAJddiEzM6GjhEFSx5xCaESwtnLizIUQrf7hxk yDptBB3dBLBKvZasa+w+0gI9nf6vhRPV1nqrejcMABtDF4mvyw5iG+zUt7imVxLe/CxEzXUMGvUwD glb+yCgS8Q2x6bIg1tmrQbQUOQkDCWql/61QG0L7VptdDnJK08H2bL5qlSBYYEmJmdBUYrIRHYOQW DijFm53pntExDqziSH3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hngJx-0002GT-0V; Wed, 17 Jul 2019 09:33:57 +0000 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hngJC-0001hk-Hj for openwrt-devel@lists.openwrt.org; Wed, 17 Jul 2019 09:33:15 +0000 Received: by mail-lf1-x143.google.com with SMTP id b17so15927696lff.7 for ; Wed, 17 Jul 2019 02:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3J/7xVb1Z6HwY7T0V3jBfYYGzc9dXZd1dktG1Y2fSnM=; b=A014926GSznu7qOA/t1XwCUAygo0I5FBogV1lzrm1sIXytP42DtHysGGtSwKRdnhCT aiawxw8gq/aQch7AYDCVW1jgNTqijxY9BbWvD29ZDZ/thpAoQlbpodYABr4VA1u39KNr qrMW8rzPPv/q8mp71q6735UY2o10d6Iws9lSbpB7pD9fuww++bLyfLwuAoZEX/1H159H oehi9A5RxOLP3GP7OkmzrtgDsehZF0Dg/fWxI6s7BN/VnZ0sFVC5Raiuo6T962fOH6CG V0ceU9Dauwif7sNHebqXlXaR0qJlOBWRRy/oxGEbh5psVRBQl33AARK3YQ/QWaRtGG2B afpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3J/7xVb1Z6HwY7T0V3jBfYYGzc9dXZd1dktG1Y2fSnM=; b=MzUEd/vDBHtn9FsGP1LWqRAJNIdp0C0Ih7AsdTUe3zEP6YskIkPA9WbyZWTcMGRY4K Pu9BVvqLiNxQO4buzbJsmd9u54rlyBXLC9xQiYGDZzOzFUca/NiENhnC2sA2bZsqrctK Zg/Pjd+vSE7psMAkgQIsxcC9BwZPGuwQ9H/s3l3g+eXvWPIPPYpz4xax3NocVY4MsUCn 5lwiYHfhVr0KqjSjt3ZXWwq0t/raytFf3NeWJxYLww8UOVjGHSYO36QIzth01e4B769Y fg6KLBUzKODwXRIDwbGTZU6/c8t+JKTxG0+cDkptqBkiZ8t63r64LFsoNdXQGYBFrOOC 0QvA== X-Gm-Message-State: APjAAAV1wuhF6PirWQ1XvQNlplL9A0TAGfrg1zarwO4YYOMEcKkf3Mty jTX/diGD7L7s6VbXYJHn6RYR2Z9g X-Google-Smtp-Source: APXvYqwiEKYqZvWxSDKFIwbxV9+8MpS3ek7IMvTVHP7KZvt4n+Mi2ecFh4FY0ZmwIcO4KVP5hYZQ6Q== X-Received: by 2002:ac2:5382:: with SMTP id g2mr16780960lfh.92.1563355985464; Wed, 17 Jul 2019 02:33:05 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id r17sm4373555ljc.85.2019.07.17.02.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 02:33:04 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: openwrt-devel@lists.openwrt.org Date: Wed, 17 Jul 2019 11:32:54 +0200 Message-Id: <20190717093255.26245-1-zajec5@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190717_023310_842742_90308AD7 X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:143 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zajec5[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (zajec5[at]gmail.com) 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH 1/2] treewide: sysupgrade: get rid of platform_nand_pre_upgrade() X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Rafał Miłecki 1) nand_do_upgrade() is always called by a target code 2) nand_do_upgrade() starts with calling platform_nand_pre_upgrade() It means there is no need for the platform_nand_pre_upgrade() callback at all. All code that was present there could bo moved & simplly called by a target right before the nand_do_upgrade(). Signed-off-by: Rafał Miłecki --- .../ar71xx/base-files/lib/upgrade/platform.sh | 73 ++++++++++--------- .../base-files/lib/upgrade/platform.sh | 34 +++------ .../base-files/lib/upgrade/platform.sh | 14 +--- .../ipq806x/base-files/lib/upgrade/zyxel.sh | 2 + .../base-files/lib/upgrade/platform.sh | 5 +- .../ramips/base-files/lib/upgrade/platform.sh | 17 +---- .../ramips/base-files/lib/upgrade/ubnt.sh | 2 + .../rb532/base-files/lib/upgrade/platform.sh | 5 +- 8 files changed, 64 insertions(+), 88 deletions(-) diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 5de7af667f..6898c0e0c2 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -746,36 +746,35 @@ platform_check_image() { return 1 } -platform_nand_pre_upgrade() { - local board=$(board_name) +platform_do_upgrade_mikrotik_rb() { + CI_KERNPART=none + local fw_mtd=$(find_mtd_part kernel) + fw_mtd="${fw_mtd/block/}" + [ -n "$fw_mtd" ] || return + mtd erase kernel + tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" - + + nand_do_upgrade "$1" +} - case "$board" in - rb*) - CI_KERNPART=none - local fw_mtd=$(find_mtd_part kernel) - fw_mtd="${fw_mtd/block/}" - [ -n "$fw_mtd" ] || return - mtd erase kernel - tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" - +platform_do_upgrade_nokia() { + case "$(fw_printenv -n dualPartition)" in + imgA) + fw_setenv dualPartition imgB + fw_setenv ActImg NokiaImageB ;; - wi2a-ac200i) - case "$(fw_printenv -n dualPartition)" in - imgA) - fw_setenv dualPartition imgB - fw_setenv ActImg NokiaImageB - ;; - imgB) - fw_setenv dualPartition imgA - fw_setenv ActImg NokiaImageA - ;; - esac - ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null - rm -f /dev/ubiblock0_0 - ubidetach -d 0 2>/dev/null >/dev/null - CI_UBIPART=ubi_alt - CI_KERNPART=kernel_alt + imgB) + fw_setenv dualPartition imgA + fw_setenv ActImg NokiaImageA ;; esac + ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null + rm -f /dev/ubiblock0_0 + ubidetach -d 0 2>/dev/null >/dev/null + CI_UBIPART=ubi_alt + CI_KERNPART=kernel_alt + + nand_do_upgrade "$1" } platform_do_upgrade() { @@ -859,6 +858,14 @@ platform_do_upgrade() { nbg6716|\ r6100|\ rambutan|\ + wndr3700v4|\ + wndr4300) + nand_do_upgrade "$1" + ;; + mr18|\ + z1) + merakinand_do_upgrade "$1" + ;; rb-411|\ rb-411u|\ rb-433|\ @@ -890,21 +897,17 @@ platform_do_upgrade() { rb-2011uias-2hnd|\ rb-2011uias-2hnd-r2|\ rb-sxt2n|\ - rb-sxt5n|\ - wi2a-ac200i|\ - wndr3700v4|\ - wndr4300) - nand_do_upgrade "$1" - ;; - mr18|\ - z1) - merakinand_do_upgrade "$1" + rb-sxt5n) + platform_do_upgrade_mikrotik_rb "$1" ;; uap-pro|\ unifi-outdoor-plus) MTD_CONFIG_ARGS="-s 0x180000" default_do_upgrade "$1" ;; + wi2a-ac200i) + platform_do_upgrade_nokia "$1" + ;; wp543|\ wpe72) platform_do_upgrade_compex "$1" diff --git a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh index a5e39c280c..dac773d2fe 100644 --- a/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq40xx/base-files/lib/upgrade/platform.sh @@ -47,12 +47,22 @@ zyxel_do_upgrade() { platform_do_upgrade() { case "$(board_name)" in 8dev,jalapeno |\ - alfa-network,ap120c-ac |\ avm,fritzbox-7530 |\ avm,fritzrepeater-3000 |\ qxwlan,e2600ac-c2) nand_do_upgrade "$1" ;; + alfa-network,ap120c-ac) + part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')" + if [ "$part" = "rootfs1" ]; then + fw_setenv active 2 || exit 1 + CI_UBIPART="rootfs2" + else + fw_setenv active 1 || exit 1 + CI_UBIPART="rootfs1" + fi + nand_do_upgrade "$1" + ;; asus,map-ac2200) CI_KERNPART="linux" nand_do_upgrade "$1" @@ -83,25 +93,3 @@ platform_do_upgrade() { ;; esac } - -platform_nand_pre_upgrade() { - case "$(board_name)" in - alfa-network,ap120c-ac) - part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')" - if [ "$part" = "rootfs1" ]; then - fw_setenv active 2 || exit 1 - CI_UBIPART="rootfs2" - else - fw_setenv active 1 || exit 1 - CI_UBIPART="rootfs1" - fi - ;; - asus,rt-ac58u) - CI_UBIPART="UBI_DEV" - CI_KERNPART="linux" - ;; - meraki,mr33) - CI_KERNPART="part.safe" - ;; - esac -} diff --git a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh index 5919613cb9..b61047ff70 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/platform.sh @@ -21,10 +21,12 @@ platform_do_upgrade() { netgear,r7500v2 |\ netgear,r7800 |\ qcom,ipq8064-ap148 |\ - qcom,ipq8064-ap161 |\ - zyxel,nbg6817) + qcom,ipq8064-ap161) nand_do_upgrade "$1" ;; + zyxel,nbg6817) + zyxel_do_upgrade "$1" + ;; linksys,ea8500) platform_do_upgrade_linksys "$1" ;; @@ -44,11 +46,3 @@ platform_do_upgrade() { ;; esac } - -platform_nand_pre_upgrade() { - case "$(board_name)" in - zyxel,nbg6817) - zyxel_do_upgrade "$1" - ;; - esac -} diff --git a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh index ba8e825956..33cd98339c 100644 --- a/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh +++ b/target/linux/ipq806x/base-files/lib/upgrade/zyxel.sh @@ -118,5 +118,7 @@ zyxel_do_upgrade() { zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd + nand_do_upgrade "$1" + return 0 } diff --git a/target/linux/pistachio/base-files/lib/upgrade/platform.sh b/target/linux/pistachio/base-files/lib/upgrade/platform.sh index 4de019a27c..174c321d38 100755 --- a/target/linux/pistachio/base-files/lib/upgrade/platform.sh +++ b/target/linux/pistachio/base-files/lib/upgrade/platform.sh @@ -26,10 +26,7 @@ platform_do_upgrade() { # stage2 directly but need to refactor nand_upgrade_success # for this to work. # Also the nand functions don't allow url to be used - nand_do_upgrade $1 -} -platform_nand_pre_upgrade() { local board=$(board_name) case "$board" in @@ -48,4 +45,6 @@ platform_nand_pre_upgrade() { echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))" ;; esac + + nand_do_upgrade $1 } diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index ae7a72c649..a65492a309 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -9,17 +9,6 @@ platform_check_image() { return 0 } -platform_nand_pre_upgrade() { - local board=$(board_name) - - case "$board" in - ubiquiti,edgerouterx|\ - ubiquiti,edgerouterx-sfp) - platform_upgrade_ubnt_erx "$1" - ;; - esac -} - platform_do_upgrade() { local board=$(board_name) @@ -35,8 +24,6 @@ platform_do_upgrade() { hiwifi,hc5962|\ netgear,r6220|\ netgear,r6350|\ - ubiquiti,edgerouterx|\ - ubiquiti,edgerouterx-sfp|\ xiaomi,mir3g|\ xiaomi,mir3p) nand_do_upgrade "$1" @@ -45,6 +32,10 @@ platform_do_upgrade() { MTD_ARGS="-t romfile" default_do_upgrade "$1" ;; + ubiquiti,edgerouterx|\ + ubiquiti,edgerouterx-sfp) + platform_upgrade_ubnt_erx "$1" + ;; *) default_do_upgrade "$1" ;; diff --git a/target/linux/ramips/base-files/lib/upgrade/ubnt.sh b/target/linux/ramips/base-files/lib/upgrade/ubnt.sh index 316a70444f..748ec8e628 100644 --- a/target/linux/ramips/base-files/lib/upgrade/ubnt.sh +++ b/target/linux/ramips/base-files/lib/upgrade/ubnt.sh @@ -73,4 +73,6 @@ platform_upgrade_ubnt_erx() { fi ubnt_update_target_kernel ${factory_mtd} ${kernel_part} || exit 1 + + nand_do_upgrade "$1" } diff --git a/target/linux/rb532/base-files/lib/upgrade/platform.sh b/target/linux/rb532/base-files/lib/upgrade/platform.sh index a6a6e9b8d3..334d6e2ff6 100644 --- a/target/linux/rb532/base-files/lib/upgrade/platform.sh +++ b/target/linux/rb532/base-files/lib/upgrade/platform.sh @@ -10,11 +10,8 @@ platform_check_image() { return 0; } -platform_nand_pre_upgrade() { +platform_do_upgrade() { mtd erase kernel tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 - -} - -platform_do_upgrade() { nand_do_upgrade "$1" }