From patchwork Thu Jun 2 10:29:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan HERPAI X-Patchwork-Id: 1638306 X-Patchwork-Delegate: wigyori@uid0.hu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=DUA9Ml0T; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LDMqs2Ytmz9sG6 for ; Thu, 2 Jun 2022 20:36:08 +1000 (AEST) 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:MIME-Version: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:In-Reply-To:References: List-Owner; bh=Zl37hSt1Ih2DnFVmZOXi72+Td1oQnZb52MPiThpod4w=; b=DUA9Ml0T1t743B ef/DEoTPoeHrXg9O7H0siZWRXQ94Kf5sZ9282U710MKNWRGd824YpH1KrLsQOlhUuNxpFOZUGaney Mi39zoGDnj5tDE7o7rktphaS5+5p2U/9zBR7wgSt7beoJN96QfV3pCasbbdZDH7CzGGivx3Je4vDf TzMTcBTwiW5vIxjuSH8E7sMK4NHxX/rEXRzRBhuIvZmcxkkKSVr9dXR05QNmLuWpkNWOTCUbEgCHJ 1QkWoHcc6+wO70FKli14mpSD89QHR2xlQV/ePl2A/R6BBR8L0S+r7YWJ+jd9YaOz1g3aZ1wAwohzQ NalNlImGUSxU8wSLIbVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwi5n-002nJc-8n; Thu, 02 Jun 2022 10:30:15 +0000 Received: from tunnel231050-pt.tunnel.tserv1.bud1.ipv6.he.net ([2001:470:1f1a:93::2] helo=trabant.uid0.hu) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nwi5g-002nIG-JB for openwrt-devel@lists.openwrt.org; Thu, 02 Jun 2022 10:30:11 +0000 Received: from wigyori by trabant.uid0.hu with local (Exim 4.92 #3 (Debian)) id 1nwi5Y-000WKu-Hb from ; Thu, 02 Jun 2022 12:30:00 +0200 From: Zoltan HERPAI To: openwrt-devel@lists.openwrt.org Cc: wigyori@uid0.hu Subject: [PATCH] firmware-utils: ptgen: add SiFive GPT partition support Date: Thu, 2 Jun 2022 12:29:57 +0200 Message-Id: <20220602102957.124248-1-wigyori@uid0.hu> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220602_033008_676580_2BF1E6DC X-CRM114-Status: UNSURE ( 9.48 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) 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 SiFive RISC-V SoCs use two special partition types in the boot process. As a first step, the ZSBL (zero-stage bootloader) in the CPU looks for a partition with a GUID of 5B193300-FC78-40CD-8002-E8 [...] Content analysis details: (0.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS 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 SiFive RISC-V SoCs use two special partition types in the boot process. As a first step, the ZSBL (zero-stage bootloader) in the CPU looks for a partition with a GUID of 5B193300-FC78-40CD-8002-E86C45580B47 to load the first-stage bootloader - which in OpenWrt's case is an SPL image. The FSBL (SPL) then looks for a partition with a GUID of 2E54B353-1271-4842-806F-E436D6AF6985 to load the SSBL which is usually an u-boot. With ptgen already supporting GPT partition creation, add the required GUID types and name them accordingly to be invoked with the '-T ' parameter. Signed-off-by: Zoltan HERPAI --- src/ptgen.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/ptgen.c b/src/ptgen.c index 58066fe..b231c28 100644 --- a/src/ptgen.c +++ b/src/ptgen.c @@ -82,6 +82,14 @@ typedef struct { GUID_INIT( 0x0fc63daf, 0x8483, 0x4772, \ 0x8e, 0x79, 0x3d, 0x69, 0xd8, 0x47, 0x7d, 0xe4) +#define GUID_PARTITION_SIFIVE_SPL \ + GUID_INIT( 0x5b193300, 0xfc78, 0x40cd, \ + 0x80, 0x02, 0xe8, 0x6c, 0x45, 0x58, 0x0b, 0x47) + +#define GUID_PARTITION_SIFIVE_UBOOT \ + GUID_INIT( 0x2e54b353, 0x1271, 0x4842, \ + 0x80, 0x6f, 0xe4, 0x36, 0xd6, 0xaf, 0x69, 0x85) + #define GPT_HEADER_SIZE 92 #define GPT_ENTRY_SIZE 128 #define GPT_ENTRY_MAX 128 @@ -276,6 +284,19 @@ static inline bool parse_gpt_parttype(const char *type, struct partinfo *part) (1ULL << 56); /* success=1 */ return true; } + + if (!strcmp(type, "sifiveu_spl")) { + part->has_guid = true; + part->guid = GUID_PARTITION_SIFIVE_SPL; + return true; + } + + if (!strcmp(type, "sifiveu_uboot")) { + part->has_guid = true; + part->guid = GUID_PARTITION_SIFIVE_UBOOT; + return true; + } + return false; }