From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/6] gpt: Support for new "gpt" command
Date: Thu, 06 Sep 2012 16:01:50 +0200 [thread overview]
Message-ID: <20120906160150.6a450d28@amdc308.digital.local> (raw)
In-Reply-To: <5047B135.8000403@wwwdotorg.org>
Hi Stephen,
> On 08/24/2012 02:13 AM, Lukasz Majewski wrote:
> > New command - "gpt" is now supported. It shows and restores the GPT
> > partition table.
> > It looks into the "partitions" environment variable for partitions
> > definition. It can be enabled at target configuration file with
> > CONFIG_CMD_GPT.
>
> > diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
>
> > +int set_gpt_info(block_dev_desc_t *dev_desc)
> > +{
> > + char *ps[GPT_PARTS_NUM], *name[GPT_PARTS_NUM];
> > + unsigned int size[GPT_PARTS_NUM];
> > + char *tok, *t, *p, *s, *ss;
> > + int i, ret;
> > +
> > + s = getenv("partitions");
> > + if (s == NULL) {
> > + printf("%s: \"partitions\" env variable not
> > defined!\n",
> > + __func__);
> > + return -1;
> > + }
>
> It'd be nice to be able to pass the partition definition on the
> command-line instead of (or perhaps as an alternative to) reading an
> environment variable.
>
> Some documentation of the expected format of the partitions variable
> would be useful. From the following patch, the format appears to be:
>
> 8M(csa-mmc),60M(u-boot),60M(kernel),...
>
> That's not particularly extensible (think about allowing partition
> type UUID to or attributes to be specified), and the brackets are a
> bit painful. Can we use key/value for defining the values, and have a
> simple separate separator between fields and partitions, e.g.
> something like:
>
> size=8M,name=csa-mmc;size=60M,name=u-boot;size=60M,name=kernel;...
This approach looks reasonable, but...
>
> That would allow us to very easily allow new fields to be specified
> per partition in the future, e.g.:
>
> uuid=XXXXX,size=512M,name=boot,type=21686148-6449-6E6F-744E-656564454649,attrs=2;uuid=YYYYY,size=7000M,name=root,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4,attrs=0;...
it would be a pain to paste so long string to u-boot command line.
Suppose we have 8 partitions to define. Then the definition string grows
considerable.
For default restoration, it would be good to define the environment
variable (like "partitions") to perform quick default restoration.
However there is a problem with passing UUID - size, name and
attributes can be defined at ./include/config/{board}.h
(partitions=size=8M,name=csa-mmc;size=60M,name=u-boot;size=60M,name=kernel)
, but UUID shall be passed by user via command line or generated
internally at u-boot (as it is proposed in this patch).
When passing from user it would look like:
gpt default uuid1 uuid2 .... uuid8
But we shall also think about using guid_gen() function (reimplemented)
for handy and quick gpt restoration.
>
> > +U_BOOT_CMD(
> > + gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
> > + "GUID Partition Table",
> ...
> > + "gpt restore - reset GPT partition to defaults\n"
> > + "gpt dev #num - set device number\n"
> ...
> > +static void set_gpt_dev(int dev)
> > +{
> > + gpt_dev = dev;
> > +}
> > +
>
> Hmmm. I think it'd be better to specify the device each time the gpt
> command was invoked. That would be simpler to use, more flexible, and
> more consistent with how other commands such as "ext2load" operate.
>
> In other words, I would get rid of "gpt dev" completely, and instead
> of implementing "gpt restore", implement "gpt restore mmc 0".
Agree - the same approach is in dfu.
>
> I'm not sure "restore" is the correct name, given that the command can
> write arbitrary new partition layouts, rather than just restoring some
> specific hard-coded table from e.g. a backup image.
>
> I'm not sure that "gpt" is even the best command name; it'd be nice if
> this were generic and could be extended to work with e.g. FAT in the
> future - something like:
>
> part write usb 1 gpt uuid=XXXXX,size=512M,name=boot,...
> part write mmc 0 fat size=512M,attrs=0x80;...
I'm open for discussion. Since part command is not yet finished, I will
use the gpt command for version 2 of this patch series. When we agree
with rest of GPT implementation we can decide if gpt or part command
will be used. OK?
>
> > +U_BOOT_CMD(
> > + gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
> > + "GUID Partition Table",
> > + "show - show GPT\n"
>
> s/show/gpt show/
>
> > +static void gpt_show(void)
> > +{
> > + struct mmc *mmc = find_mmc_device(gpt_dev);
> > +
> > + print_part_efi(&mmc->block_dev);
> > +}
>
> Do we really need another way of showing partition tables; "mmc part",
> "usb part", ... already exist. I think if we want another way, it'd be
> better to add this functionality to my proposed "part" command, i.e.
> "part show mmc 0".
I agree that "gpt show" is not needed. Instead "mmc part" can be used.
>
> > +static int gpt_default(void)
> > +{
> > + struct mmc *mmc = find_mmc_device(gpt_dev);
> > +
> > + if (mmc == NULL) {
> > + printf("%s: mmc dev %d NOT available\n", __func__,
> > gpt_dev);
> > + return CMD_RET_FAILURE;
> > + }
>
> Why only allow mmc devices; what about USB for example? Other commands
> such as ext2load allow arbitrary device types to be used. Rob Herring
> recently posted some patches to unify how commands such as ext2load,
> ext2ls, fatload, fatls, ... all obtain a device/partition handle from
> their command-line - this patch should probably build on top of those
> patches.
Yes, but Rob's patches are not yet accepted to mainline. I'd prefer to
not use patches which aren't accepted as a base for development.
>
> > + puts("Using default GPT UUID\n");
> > +
> > + return set_gpt_info(&mmc->block_dev);
> > +}
>
I think, that most important change is to pass table with pointers to
partition entries to set_gpt_table. Second thing is to fix guid_gen()
function and change the format of "partitions" to be key=value pairs.
--
Best regards,
Lukasz Majewski
Samsung Poland R&D Center | Linux Platform Group
next prev parent reply other threads:[~2012-09-06 14:01 UTC|newest]
Thread overview: 95+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-24 8:13 [U-Boot] [PATCH 0/6] gpt: GUID Partition Table (GPT) restoration Lukasz Majewski
2012-08-24 8:13 ` [U-Boot] [PATCH 1/6] gpt:doc: GPT (GUID Partition Table) documentation Lukasz Majewski
2012-09-05 19:31 ` Stephen Warren
2012-09-06 9:22 ` Lukasz Majewski
2012-08-24 8:13 ` [U-Boot] [PATCH 2/6] gpt: Replace the leXX_to_int() calls with ones defined at <compiler.h> Lukasz Majewski
2012-09-05 19:35 ` Stephen Warren
2012-09-06 10:20 ` Lukasz Majewski
2012-09-06 18:53 ` Stephen Warren
[not found] ` <SNT002-W181FE3CE14BE68990CDF80CCB920@phx.gbl>
2012-09-12 14:42 ` Lukasz Majewski
2012-09-05 19:45 ` Stephen Warren
2012-09-06 10:15 ` Lukasz Majewski
2012-08-24 8:13 ` [U-Boot] [PATCH 3/6] gpt: Replacement of GPT structures members with ones indicating endianness and size Lukasz Majewski
2012-09-05 19:41 ` Stephen Warren
2012-09-06 10:24 ` Lukasz Majewski
2012-08-24 8:13 ` [U-Boot] [PATCH 4/6] gpt: Support for GPT (GUID Partition Table) restoration Lukasz Majewski
2012-09-05 19:49 ` Stephen Warren
2012-09-06 11:19 ` Lukasz Majewski
2012-09-06 18:55 ` Stephen Warren
2012-09-05 20:19 ` Stephen Warren
2012-10-03 23:00 ` [U-Boot] [U-Boot, " Tom Rini
2012-10-04 7:18 ` [U-Boot] [u-boot] Adding missing CONFIG_SYS_CACHELINE_SIZE to boards definitions Lukasz Majewski
2012-10-04 8:28 ` esw
2012-10-18 18:48 ` Albert ARIBAUD
2012-10-04 9:02 ` Helmut Raiger
2012-08-24 8:13 ` [U-Boot] [PATCH 5/6] gpt: Support for new "gpt" command Lukasz Majewski
2012-09-05 20:08 ` Stephen Warren
2012-09-06 14:01 ` Lukasz Majewski [this message]
2012-08-24 8:13 ` [U-Boot] [PATCH 6/6] gpt: Enable support for GPT partition table restoration at Samsung's Trats Lukasz Majewski
2012-08-24 8:48 ` [U-Boot] gpt: GUID/UUID - GPT restoration - open questions Lukasz Majewski
2012-09-05 20:21 ` Stephen Warren
2012-09-06 11:27 ` Lukasz Majewski
2012-09-06 12:27 ` Rob Herring
2012-09-06 14:14 ` Lukasz Majewski
2012-09-06 18:57 ` Stephen Warren
2012-09-07 6:45 ` Lukasz Majewski
2012-09-03 9:28 ` [U-Boot] gpt: GUID/UUID - GPT restoration - open questions - RESEND Lukasz Majewski
2012-10-02 13:46 ` Simon Glass
2012-10-02 16:39 ` Lukasz Majewski
2012-09-03 9:30 ` [U-Boot] [PATCH 0/6] gpt: GUID Partition Table (GPT) restoration Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 0/7] " Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 1/7] vsprintf:fix: Change type returned by ustrtoul Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 2/7] part:efi: Move part_efi.h file to ./include Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 3/7] gpt:doc: GPT (GUID Partition Table) documentation Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 4/7] gpt: The leXX_to_int() calls replaced with ones defined at <compiler.h> Lukasz Majewski
2012-09-12 14:50 ` [U-Boot] [PATCH v2 5/7] gpt: Support for GPT (GUID Partition Table) restoration Lukasz Majewski
2012-09-12 17:22 ` Tom Rini
2012-09-12 14:50 ` [U-Boot] [PATCH v2 6/7] gpt: Support for new "gpt" command Lukasz Majewski
2012-09-12 17:21 ` Tom Rini
2012-09-12 14:50 ` [U-Boot] [PATCH v2 7/7] gpt: Enable support for GPT partition table restoration at Samsung's Trats Lukasz Majewski
2012-09-12 17:23 ` [U-Boot] [PATCH v2 0/7] gpt: GUID Partition Table (GPT) restoration Tom Rini
2012-09-13 6:20 ` Lukasz Majewski
2012-09-13 17:39 ` Tom Rini
2012-09-13 8:09 ` [U-Boot] [PATCH v3 " Lukasz Majewski
2012-09-13 8:09 ` [U-Boot] [PATCH v3 1/7] vsprintf:fix: Change type returned by ustrtoul Lukasz Majewski
2012-09-13 8:10 ` [U-Boot] [PATCH v3 2/7] part:efi: Move part_efi.h file to ./include Lukasz Majewski
2012-09-13 18:54 ` Kim Phillips
2012-09-13 8:10 ` [U-Boot] [PATCH v3 3/7] gpt:doc: GPT (GUID Partition Table) documentation Lukasz Majewski
2012-09-17 17:58 ` Stephen Warren
2012-10-05 10:35 ` Lukasz Majewski
2012-10-05 15:19 ` Lukasz Majewski
2012-10-05 16:05 ` Stephen Warren
2012-09-13 8:10 ` [U-Boot] [PATCH v3 4/7] gpt: The leXX_to_int() calls replaced with ones defined at <compiler.h> Lukasz Majewski
2012-09-13 8:10 ` [U-Boot] [PATCH v3 5/7] gpt: Support for GPT (GUID Partition Table) restoration Lukasz Majewski
2012-09-17 18:07 ` Stephen Warren
2012-10-05 10:50 ` Lukasz Majewski
2012-09-13 8:10 ` [U-Boot] [PATCH v3 6/7] gpt: Support for new "gpt" command Lukasz Majewski
2012-09-13 8:10 ` [U-Boot] [PATCH v3 7/7] gpt: Enable support for GPT partition table restoration at Samsung's Trats Lukasz Majewski
2012-11-09 9:22 ` [U-Boot] [PATCH v4 0/7] gpt: GUID Partition Table (GPT) restoration Piotr Wilczek
2012-11-09 9:22 ` [U-Boot] [PATCH v4 1/7] vsprintf:fix: Change type returned by ustrtoul Piotr Wilczek
2012-11-19 19:19 ` Stephen Warren
2012-11-09 9:22 ` [U-Boot] [PATCH v4 2/7] part:efi: Move part_efi.h file to ./include Piotr Wilczek
2012-11-19 19:30 ` Stephen Warren
2012-11-19 20:41 ` Tom Rini
2012-11-20 17:46 ` Lukasz Majewski
2012-11-09 9:22 ` [U-Boot] [PATCH v4 3/7] gpt:doc: GPT (GUID Partition Table) documentation Piotr Wilczek
2012-11-19 19:28 ` Stephen Warren
2012-11-09 10:48 ` [U-Boot] [PATCH v4 4/7] gpt: The leXX_to_int() calls replaced with ones defined at <compiler.h> Piotr Wilczek
2012-11-09 10:48 ` [U-Boot] [PATCH v4 5/7] gpt: Support for GPT (GUID Partition Table) restoration Piotr Wilczek
2012-11-19 20:16 ` Stephen Warren
2012-11-21 13:18 ` Piotr Wilczek
2012-11-22 12:16 ` Lukasz Majewski
2012-11-26 23:46 ` Stephen Warren
2012-11-24 18:05 ` Stephen Warren
2012-11-26 13:08 ` Piotr Wilczek
2012-11-09 10:48 ` [U-Boot] [PATCH v4 6/7] gpt: Support for new "gpt" command Piotr Wilczek
2012-11-19 21:34 ` Stephen Warren
2012-11-21 11:22 ` Piotr Wilczek
2012-11-24 18:00 ` Stephen Warren
2012-11-26 13:08 ` Piotr Wilczek
2012-11-26 23:49 ` Stephen Warren
2012-11-09 10:48 ` [U-Boot] [PATCH v4 7/7] gpt: Enable support for GPT partition table restoration at Samsung's Trats Piotr Wilczek
2012-11-19 19:39 ` [U-Boot] [PATCH v4 4/7] gpt: The leXX_to_int() calls replaced with ones defined at <compiler.h> Stephen Warren
2012-11-19 20:43 ` [U-Boot] [PATCH v4 0/7] gpt: GUID Partition Table (GPT) restoration Tom Rini
2012-12-06 20:40 ` Tom Rini
2012-12-07 9:03 ` Piotr Wilczek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120906160150.6a450d28@amdc308.digital.local \
--to=l.majewski@samsung.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox