From patchwork Wed Apr 24 09:39:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1090035 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44pwK459btz9s6w for ; Wed, 24 Apr 2019 19:40:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 4F42427153; Wed, 24 Apr 2019 09:40:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id txiTneXMdjip; Wed, 24 Apr 2019 09:39:56 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 3707A27408; Wed, 24 Apr 2019 09:39:56 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 984B01BF97A for ; Wed, 24 Apr 2019 09:39:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9556285F18 for ; Wed, 24 Apr 2019 09:39:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IgYKK9XANgm0 for ; Wed, 24 Apr 2019 09:39:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C941585F58 for ; Wed, 24 Apr 2019 09:39:49 +0000 (UTC) Received: from localhost (132.230.147.77.rev.sfr.net [77.147.230.132]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 35A94240007; Wed, 24 Apr 2019 09:39:47 +0000 (UTC) From: Thomas Petazzoni To: Buildroot List Date: Wed, 24 Apr 2019 11:39:30 +0200 Message-Id: <20190424093933.6212-3-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190424093933.6212-1-thomas.petazzoni@bootlin.com> References: <20190424093933.6212-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH 2/4] package/genimage: add patch to support bootable flag in GPT tables X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexandre.belloni@bootlin.com, Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" This commit adds a patch, submitted upstream, to add support for setting the bootable flag in GPT partition tables. While we normally don't accept feature patches in Buildroot, this one is really minimal (two lines of code) and is in fact necessary for the STM32MP157 Discovery Kit defconfig. Indeed, the STM32MP157 BootROM loads the first stage bootloader from the GPT partitions named fsbl*, which requires a GPT partition table. But then, the "U-Boot Generic Distro" mechanism identifies the GPT partition that contains the extlinux.conf file to use thanks to the "bootable" flag of GPT partitions. Signed-off-by: Thomas Petazzoni --- ...dd-support-for-bootable-flags-on-GPT.patch | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch diff --git a/package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch b/package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch new file mode 100644 index 0000000000..03cc5dd39d --- /dev/null +++ b/package/genimage/0001-image-hd-add-support-for-bootable-flags-on-GPT.patch @@ -0,0 +1,45 @@ +From f23a09b177d9a55679fd3a57951313b8a34dc4d9 Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Tue, 23 Apr 2019 14:09:42 +0200 +Subject: [PATCH] image-hd: add support for bootable flags on GPT + +Bit 2 of the GPT partition table entry "flags" attribute allows to +mark the partition as bootable, so we add support for setting this +flag, using the same bootable flag used for MBR partition tables. + +Setting this flag is useful to properly support the "Generic Distro" +concept from U-Boot [1], which searches for boot scripts in the +bootable partition. + +[1] http://git.denx.de/?p=u-boot.git;a=blob;f=doc/README.distro + +Signed-off-by: Thomas Petazzoni +Upstream: https://github.com/pengutronix/genimage/pull/58 +--- + image-hd.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/image-hd.c b/image-hd.c +index 2c2860c..1f80ae7 100644 +--- a/image-hd.c ++++ b/image-hd.c +@@ -78,6 +78,8 @@ struct gpt_partition_entry { + #define GPT_SECTORS (1 + GPT_ENTRIES * sizeof(struct gpt_partition_entry) / 512) + #define GPT_REVISION_1_0 0x00010000 + ++#define GPT_PE_FLAG_BOOTABLE (1 << 2) ++ + static void hdimage_setup_chs(unsigned int lba, unsigned char *chs) + { + const unsigned int hpc = 255; +@@ -275,6 +277,7 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions) + uuid_parse(part->partition_uuid, table[i].uuid); + table[i].first_lba = htole64(part->offset/512); + table[i].last_lba = htole64((part->offset + part->size)/512 - 1); ++ table[i].flags = part->bootable ? GPT_PE_FLAG_BOOTABLE : 0; + for (j = 0; j < strlen(part->name) && j < 36; j++) + table[i].name[j] = htole16(part->name[j]); + i++; +-- +2.20.1 +