From patchwork Mon Aug 17 10:44:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thibaut X-Patchwork-Id: 1346120 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=quarantine dis=none) header.from=slashdirt.org 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=vfzXvu3U; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=slashdirt.org header.i=@slashdirt.org header.a=rsa-sha256 header.s=mail header.b=aJn2Dhxa; 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 4BVW7k2H0Lz9sRK for ; Mon, 17 Aug 2020 20:51:46 +1000 (AEST) 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: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:In-Reply-To:References:List-Owner; bh=cxQGajY/POME1cMrbb6Odj3+b6OUkY6OqmlQm8HSK3k=; b=vfzXvu3UZtWZgBWkOHygAvbGxS kt/H29H8W+WBoabp4J0l8UVLyDEHbUZf+Gf8Zmi4HXRMA3KlgESPivwzXNfYnUBYDdqAdkkJAkDPF okzh+8pSnaYbi5zufA73d1yfHGpjAGiGH2ZTG1k/ifBZYN19uv1dAZDxip5Pz+kKlX++x37qXcLYp WF1kwSFRXPIV9XFI7JZDVkhyjXWHdUNRgqdH/e2FwQiRR0qBy1Beghrs5mvdpZTc1oE6/s54VRHmP o0sBDPxr+DZBGWyZQLvecBonM6KHv4g6XDvoCqctnPNPSfE0e7wNRJ3Dt0m2Jw9d3fiMPY3cbYBnQ EAam6OKg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7ciZ-0002Z5-9r; Mon, 17 Aug 2020 10:50:19 +0000 Received: from vps.slashdirt.org ([144.91.108.218]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7ci9-0002H5-B8 for openwrt-devel@lists.openwrt.org; Mon, 17 Aug 2020 10:49:54 +0000 Received: from Chuck.tardis.lan (tardis.herebedragons.eu [171.22.3.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by vps.slashdirt.org (Postfix) with ESMTPSA id DD48B602C3; Mon, 17 Aug 2020 12:44:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 vps.slashdirt.org DD48B602C3 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=slashdirt.org; s=mail; t=1597661064; bh=iONDtF3WsvCa8Kl1lOzoJifEgJKk7hNmFOLiSvSN0mg=; h=From:To:Cc:Subject:Date:From; b=aJn2DhxawZSxlXmRVpvfOr49/RlnrHT2naSdDa1My9e0qWVFqFkiMkUKz8LBEjhnf aQU/ZvIWwbJG6NibL68sI4LMjvl8J94TE06pVtx/TUGtbcvAWBM2drDangzA3R0D5L jwEosGhCY84mBLqAa6LqwvdTh54+p2zL28Jcld5k= From: =?utf-8?q?Thibaut_VAR=C3=88NE?= To: openwrt-devel@lists.openwrt.org Subject: [PATCH] ath79: mikrotik: erase firmware on SPI NOR devices before install Date: Mon, 17 Aug 2020 12:44:13 +0200 Message-Id: <20200817104413.1798-1-hacks@slashdirt.org> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200817_064953_700018_3A4A49E6 X-CRM114-Status: GOOD ( 12.18 ) X-Spam-Score: 0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.4 NO_DNS_FOR_FROM RBL: Envelope sender has no MX or A DNS records [listed in slashdirt.org. IN A] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 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?Thibaut_VAR=C3=88NE?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org On Mikrotik SPI NOR devices, the firmware partition must be erased when flashing from stock firmware, otherwise leftover bits (in particular a kernel signature) can trigger a boot loop. When booted from initramfs (the only way to install OpenWRT on these devices), this patch unconditionally erases the firmware partition in the do_upgrade() stage for all supported SPI NOR devices. This is forward-ported from ed49d0876 and 20452a8db Signed-off-by: Thibaut VARĂˆNE --- target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh b/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh index d79bd03af5..d7fac35708 100644 --- a/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/mikrotik/base-files/lib/upgrade/platform.sh @@ -38,6 +38,8 @@ platform_do_upgrade() { platform_do_upgrade_mikrotik_nand "$1" ;; *) + # NOR devices: erase firmware if booted from initramfs + [ -z "$(rootfs_type)" ] && mtd erase firmware default_do_upgrade "$1" ;; esac