From patchwork Tue Apr 6 09:43:03 2021 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: 1462696 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=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) 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=desiato.20200630 header.b=nkCbbDAN; 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=hIImeqKD; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (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 4FF2h86Gv6z9sVt for ; Tue, 6 Apr 2021 19:45:28 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0tWQWFdYViv1djHk5ScR9sXz8zvQo+GinDT3gRPZQ80=; b=nkCbbDANoM/x0rL3F0mtZnvN7 3M0MXbDB01CES+thvBRtZud48220I5gxvTV80KDr/V8DEmXJdwY8vCEXDmfDlqBJGe22pNL58RyZm dy7xwy7TwUzfBuUk2GVWCoOWVVl9KIi3/0awa3Cu5yvV4gMtRKfpKj1WbhVk01coOC0e5o9MVZsiP 1bAM4FtW8ArgR76W7Mn0Nks+Kj3bEdqE1VQydRhPEoTn4P3SeXOm4zJeTE0t/ib8Cjj4tLCuNlY6G rrKYhVrgC5KXm48Gw0dSM2IqxnEOod78V2T1FdQmr+SqMF/hk6RI2r2y/S3YsFfmYOzyi9eErnkXY CtpP6/Z4g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lTiFO-0024F0-Am; Tue, 06 Apr 2021 09:43:46 +0000 Received: from canardo.mork.no ([2001:4641::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lTiF9-0024BK-VX for openwrt-devel@lists.openwrt.org; Tue, 06 Apr 2021 09:43:34 +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 1369hUjq023971 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=OK); Tue, 6 Apr 2021 11:43:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1617702210; bh=RzoIKhbTcRDmceKDwYBsIDyceb5ChbcRwkWnTXxNWz8=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=hIImeqKD+XucL9Xdy/oMZRHVL9/5uBlEv/X88xG1JBhGe4O/ujZGHVo+XHm3Ysc8J f+3uOHgA63UUWaN0F0/YIQ/AZL0j+dKVWoEmT0BtTq/9iNLnWwbgdCsqnX88s2D16U xxqk2Fh/6WQPjFQXjWc16sUpvFaLCVLX83FzFo0E= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id 1369hU0J023970; Tue, 6 Apr 2021 11:43:30 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: openwrt-devel@lists.openwrt.org Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Subject: [PATCH v3 1/3] uboot-envtools: add support for multiple config partitions Date: Tue, 6 Apr 2021 11:43:03 +0200 Message-Id: <20210406094305.23905-2-bjorn@mork.no> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406094305.23905-1-bjorn@mork.no> References: <20201213190735.31978-1-bjorn@mork.no> <20210406094305.23905-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-20210406_104332_263015_E66BFFFB X-CRM114-Status: GOOD ( 11.30 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Most (all?) of the realtek devices have two u-boot config partitions with a different set of variables in each. The U-Boot shell provides two sets of apps to manipulate these: printenv- print environment variables printsys- printsys - print system information variables saveenv - save environment variables to persistent storage savesys - savesys - save system information va [...] Content analysis details: (-2.5 points, 5.0 required) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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 X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Most (all?) of the realtek devices have two u-boot config partitions with a different set of variables in each. The U-Boot shell provides two sets of apps to manipulate these: printenv- print environment variables printsys- printsys - print system information variables saveenv - save environment variables to persistent storage savesys - savesys - save system information variables to persistent storage setenv - set environment variables setsys - setsys - set system information variables Add support for multiple ubootenv configuration types, allowing more than one configuration file. Section names are not suitable for naming the different configurations since each file can be the result of multiple sections in case of backup partitions. Signed-off-by: Bjørn Mork --- package/boot/uboot-envtools/Makefile | 1 + package/boot/uboot-envtools/files/realtek | 8 +++- .../uboot-envtools/files/uboot-envtools.sh | 38 ++++++++++++------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile index a9eccec0cec9..03dc6c678d74 100644 --- a/package/boot/uboot-envtools/Makefile +++ b/package/boot/uboot-envtools/Makefile @@ -61,6 +61,7 @@ MAKE_FLAGS += \ define Package/uboot-envtools/conffiles /etc/config/ubootenv /etc/fw_env.config +/etc/fw_sys.config endef define Package/uboot-envtools/install diff --git a/package/boot/uboot-envtools/files/realtek b/package/boot/uboot-envtools/files/realtek index a91ca826044e..75a399208e67 100644 --- a/package/boot/uboot-envtools/files/realtek +++ b/package/boot/uboot-envtools/files/realtek @@ -18,15 +18,21 @@ zyxel,gs1900-10hp) idx="$(find_mtd_index u-boot-env)" [ -n "$idx" ] && \ ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x400" "0x10000" + idx2="$(find_mtd_index u-boot-env2)" + [ -n "$idx2" ] && \ + ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000" ;; *) idx="$(find_mtd_index u-boot-env)" [ -n "$idx" ] && \ ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" + idx2="$(find_mtd_index u-boot-env2)" + [ -n "$idx2" ] && \ + ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x1000" "0x10000" ;; esac config_load ubootenv -config_foreach ubootenv_add_app_config ubootenv +config_foreach ubootenv_add_app_config exit 0 diff --git a/package/boot/uboot-envtools/files/uboot-envtools.sh b/package/boot/uboot-envtools/files/uboot-envtools.sh index 9218bc4e3912..980c9962b17c 100644 --- a/package/boot/uboot-envtools/files/uboot-envtools.sh +++ b/package/boot/uboot-envtools/files/uboot-envtools.sh @@ -3,34 +3,44 @@ # Copyright (C) 2011-2012 OpenWrt.org # -ubootenv_add_uci_config() { - local dev=$1 - local offset=$2 - local envsize=$3 - local secsize=$4 - local numsec=$5 +_ubootenv_add_uci_config() { + local cfgtype=$1 + local dev=$2 + local offset=$3 + local envsize=$4 + local secsize=$5 + local numsec=$6 uci batch <>/etc/fw_env.config + grep -q "^[[:space:]]*${dev}[[:space:]]*${offset}" "/etc/fw_${cfgtype#uboot}.config" || echo "$dev $offset $envsize $secsize $numsec" >>"/etc/fw_${cfgtype#uboot}.config" } -