public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [RFC PATCH] cmd: gpt: add - partition size parsing
@ 2016-06-08  8:18 Michael Trimarchi
  2016-06-10  0:35 ` Simon Glass
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael Trimarchi @ 2016-06-08  8:18 UTC (permalink / raw)
  To: u-boot

This patch try to parse name=userdata,size=-,uuid=${uuid_gpt_userdata};

gpt mmc write 0 $partitions
gpt mmc verify 0 $partitions

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 cmd/gpt.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 8ffaef3..3d9706b 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -181,6 +181,7 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 	disk_partition_t *parts;
 	int errno = 0;
 	uint64_t size_ll, start_ll;
+	lbaint_t offset = 0;
 
 	debug("%s:  lba num: 0x%x %d\n", __func__,
 	      (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba);
@@ -296,8 +297,14 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 		}
 		if (extract_env(val, &p))
 			p = val;
-		size_ll = ustrtoull(p, &p, 0);
-		parts[i].size = lldiv(size_ll, dev_desc->blksz);
+		if ((strcmp(p, "-") == 0)) {
+			/* remove first usable lba and last block */
+			parts[i].size = dev_desc->lba - 34  - 1 - offset;
+		} else {
+			size_ll = ustrtoull(p, &p, 0);
+			parts[i].size = lldiv(size_ll, dev_desc->blksz);
+		}
+
 		free(val);
 
 		/* start address */
@@ -310,6 +317,8 @@ static int set_gpt_info(struct blk_desc *dev_desc,
 			free(val);
 		}
 
+		offset += parts[i].size + parts[i].start;
+
 		/* bootable */
 		if (found_key(tok, "bootable"))
 			parts[i].bootable = 1;
-- 
2.8.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-07-27 13:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-08  8:18 [U-Boot] [RFC PATCH] cmd: gpt: add - partition size parsing Michael Trimarchi
2016-06-10  0:35 ` Simon Glass
2016-06-19 14:08 ` [U-Boot] [U-Boot,RFC] " Tom Rini
2016-07-27 12:57 ` [U-Boot] [RFC PATCH] " Julian Scheel
2016-07-27 13:05   ` Michael Trimarchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox