[openwrt/openwrt] firmware-utils: ptgen: add SiFive-related GUID types

LEDE Commits lede-commits at lists.infradead.org
Wed Jun 14 00:24:44 PDT 2023


wigyori pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/0f30f47d61815ad77934693456226076f6e40a49

commit 0f30f47d61815ad77934693456226076f6e40a49
Author: Zoltan HERPAI <wigyori at uid0.hu>
AuthorDate: Sat Apr 23 19:06:28 2022 +0200

    firmware-utils: ptgen: add SiFive-related GUID types
    
    Add patch until it gets accepted in firmware-utils upstream.
    
    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 <GPT partition
    type>' parameter.
    
    Signed-off-by: Zoltan HERPAI <wigyori at uid0.hu>
    (cherry picked from commit 18238c442866a6ae93533e2421a6f44bc9e57ac6)
---
 .../patches/001-add-sifiveu-guid-types.patch       | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/firmware-utils/patches/001-add-sifiveu-guid-types.patch b/tools/firmware-utils/patches/001-add-sifiveu-guid-types.patch
new file mode 100644
index 0000000000..45900e982c
--- /dev/null
+++ b/tools/firmware-utils/patches/001-add-sifiveu-guid-types.patch
@@ -0,0 +1,38 @@
+diff -ruN firmware-utils-2022-02-28-002cfaf0.old/src/ptgen.c firmware-utils-2022-02-28-002cfaf0/src/ptgen.c
+--- firmware-utils-2022-02-28-002cfaf0.old/src/ptgen.c	2022-04-23 19:02:07.307896842 +0200
++++ firmware-utils-2022-02-28-002cfaf0/src/ptgen.c	2022-04-22 18:48:54.477970950 +0200
+@@ -82,6 +82,14 @@
+ 	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 @@
+ 			      (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;
+ }
+ 




More information about the lede-commits mailing list