From patchwork Tue Jan 23 22:17:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1889911 X-Patchwork-Delegate: linus.walleij@linaro.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hcX3JqQ6; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=E5igS9uu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TKM7W5xMGz23dy for ; Wed, 24 Jan 2024 09:23:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date: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=1giFVKIjbLSv+RZfFnhacI2DyVV/jmeLFGR841VhFTM=; b=hcX3JqQ6GBkF9j 3Vyfr+UAUN6CkKmtbXI0Ybb4WzGifNkArSRDCzcEnA6IEmWcCLBG1q+o9HjlM+ft/j5LB44RLgE3d 2o+0+TejskTmBPr7xikClWGOgM628h1gy3ZQBJHXOzrv2R5sf5Kf6wnlJc9/baHrlXOUEkefj/lOa N0vfbHbh8uGtICUOsJj/zyD7D15MemLQzSdo+zxmM0+J5rCao6519dmT/3jMvaVZplSCr+izLohZT uG7KByWrujSN8GRwYlc7HFObt7msEPlw+/mxusgC5aQ8M/18o2U0i3Oprz8bjRCbYYAT96Ly9uWiS xOhjxsIVRpDkSQg/errw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSP5L-000dXC-2c; Tue, 23 Jan 2024 22:17:35 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSP5H-000dWk-1j for openwrt-devel@lists.openwrt.org; Tue, 23 Jan 2024 22:17:32 +0000 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5100ed2b33dso371527e87.0 for ; Tue, 23 Jan 2024 14:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706048247; x=1706653047; darn=lists.openwrt.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=iknCB5TcqWhmqZz6/aFUJhFs8Mx4ViiAckPmKoAh8zM=; b=E5igS9uuF1ED5JM2IM+TiB3IJfjSpkZzsjTYesqmgjLKOMM6n7pvhr905efTcNXZ8O W+SsTLgs5F76nsFYuQ6LuEioeyIGfKOqHuWkiXYfz7FlkX4c3PaiZizTH6IVZ447NIUx MlgeItuaQpG2SQ1Y8QQbEZjeaXf+SRoY8L9FYKrcZ1WsXIs+ZIpadv9Zhcb0mSbmgZcj xJLQto5hE7ot/ZplrtQy6QcdlZHQHHxWaQ8pktb+UrqgYot3czVmWpxMjms4uz8Qq48R TaW8EWdNWz3UFI2uJ5aBB2B2SfVlDSeP51GrJoL7LI0VZ1pAlk6gmKXOipOEbOaVwr9r IG1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706048247; x=1706653047; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iknCB5TcqWhmqZz6/aFUJhFs8Mx4ViiAckPmKoAh8zM=; b=AeKhDJQ+IUtXvGBNFjiLFScbcyeKkIf3R60oElXM4dKYCbRbyqeiYsn22Quvfr9F/l vTnHEcc7DctHNC2oqUto7mfsIpXwyL/ZoIUP7dkM37CmVKoIRsaBc1Zy5REV+PlAQZUE hVLWUzClvkA5rfE5cvuYRGgeDsrmVBIqt/QAtA93m/kcqLrG9iDckAs8nKPL6NmXkdAs o5CguD0fvq3/2qQw4XCiNocu5L5N5nYHDleWG6T1uABb7qgE8T0ThBzNdDmp5jqXEbVB n1tMngVtaj3LhkHMnfQJRYi3mGsARJQiYCOTMPZWisv/ZkcapdSMAoAw/VLB7jf8c1Xb eK5A== X-Gm-Message-State: AOJu0Yy1pUWF7GWdSm0DIFPrYWiRz3ZprN0UmKwxlXsCNmN3oz/RKY1w xpIQsdMxdRD5jiojJKfFF9gLlsvu+b4Z4sl1xn8UwtSqXLTAB5/pqQIe0wsf8rKjO685uFtS4rc poJU= X-Google-Smtp-Source: AGHT+IGlxjf+jtu0rDOSlQM6lihorDuP6OmRtgPY/+FkyYQPOKPAdiumBY5l2xHuYXg5Nab89byACw== X-Received: by 2002:a05:6512:470:b0:50e:e9fc:b6ee with SMTP id x16-20020a056512047000b0050ee9fcb6eemr2729942lfd.56.1706048247402; Tue, 23 Jan 2024 14:17:27 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h23-20020a19ca57000000b0050ee3e540e4sm2464201lfj.65.2024.01.23.14.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 14:17:27 -0800 (PST) From: Linus Walleij Date: Tue, 23 Jan 2024 23:17:26 +0100 Subject: [PATCH] mtdsplit_uimage: Split also after offsetted uImage MIME-Version: 1.0 Message-Id: <20240123-offsetted-uimage-splitter-v1-1-dc0812b43c97@linaro.org> X-B4-Tracking: v=1; b=H4sIAPU6sGUC/x3MSwqAMAxF0a1IxhZq/QzcijhQm2hAqzQqgnTvB oeHy3svCEZGgTZ7IeLNwntQFHkG0zKEGQ17NTjrKlu40uxEgueJ3ly8DdrlWFkdDdVjU5P15NC D7o+IxM//3fUpfQ1USS9rAAAA To: openwrt-devel@lists.openwrt.org, =?utf-8?q?Bj=C3=B8rn_Mork?= Cc: Linus Walleij X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_141731_600339_6B69E188 X-CRM114-Status: GOOD ( 14.19 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.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: The uImage splitter recognizes a rootfs either: 1. Right after the uImage if it comes first in the partition or 2. Before the uImage if it is located at an offset inside the partition. Add a third case: Content analysis details: (-0.2 points, 5.0 required) 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:132 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an 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_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.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 The uImage splitter recognizes a rootfs either: 1. Right after the uImage if it comes first in the partition or 2. Before the uImage if it is located at an offset inside the partition. Add a third case: 3. After the uImage also at an offset inside the partition, if and only if 1 and 2 fails. The reason why this is needed is because on the BCM6328-based Inteno XG6846 we need to put a small U-Boot binary first in the partition, then the uImage, then the rootfs. The U-Boot binary that comes first cannot be split off into its own partition in this case because it needs to be part of the bigger "firmware" partition. Which we use for installation and upgrades. Signed-off-by: Linus Walleij --- .../files/drivers/mtd/mtdsplit/mtdsplit_uimage.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- base-commit: 1b7e62b20b1735fcdc498a35e005afcd775abcf4 change-id: 20240123-offsetted-uimage-splitter-f5b65f0df2ed Best regards, 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 a3e55fb1fe38..de043fb9f702 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c @@ -217,11 +217,22 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master, if (ret) { pr_debug("no rootfs before uImage in \"%s\"\n", master->name); - goto err_free_buf; - } - rootfs_offset = 0; - rootfs_size = uimage_offset; + /* Try after the uImage */ + ret = mtd_find_rootfs_from(master, uimage_offset + uimage_size, + master->size, &rootfs_offset, &type); + if (ret) { + pr_debug("no rootfs after uImage either in \"%s\"\n", + master->name); + goto err_free_buf; + } + + rootfs_size = master->size - rootfs_offset; + uimage_size = rootfs_offset - uimage_offset; + } else { + rootfs_offset = 0; + rootfs_size = uimage_offset; + } } if (rootfs_size == 0) {