All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions
@ 2015-02-25 22:23 Sjoerd Simons
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions Sjoerd Simons
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Sjoerd Simons @ 2015-02-25 22:23 UTC (permalink / raw)
  To: u-boot

In the discussion after the submission of the "Let the distro boot command scan
all partitions" patchset it became clear the general consensus was that
u-boot should not simply scan all partitions but instead only partitions with
the bootable flag set, falling back to parition 1 as was previously done.

This set of patches implements that

Changes since v1:
  * Make updated part list command more precise about what arguments ordering
    it accepts.

Sjoerd Simons (3):
  part: Add support for list filtering on bootable partitions
  config_cmd_default.h: Add 'env exists' command
  config_distro_bootcmd.h: Prefer booting from bootable paritions

 common/cmd_part.c               | 53 +++++++++++++++++++++++++++++++----------
 include/config_cmd_default.h    |  1 +
 include/config_distro_bootcmd.h |  3 ++-
 3 files changed, 44 insertions(+), 13 deletions(-)

-- 
2.1.4

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

* [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions
  2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
@ 2015-02-25 22:23 ` Sjoerd Simons
  2015-03-25 20:49   ` Tom Rini
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command Sjoerd Simons
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Sjoerd Simons @ 2015-02-25 22:23 UTC (permalink / raw)
  To: u-boot

Add an optional -bootable parameter to the part list commands to only
put the list of bootable partitions in the environment variable

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---
 common/cmd_part.c | 53 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 12 deletions(-)

Changes since v1:
  * Be more specific about the arguments ordering that is accepted

diff --git a/common/cmd_part.c b/common/cmd_part.c
index c99f527..d04588e 100644
--- a/common/cmd_part.c
+++ b/common/cmd_part.c
@@ -53,29 +53,57 @@ static int do_part_list(int argc, char * const argv[])
 {
 	int ret;
 	block_dev_desc_t *desc;
+	char *var = NULL;
+	bool bootable = false;
+	int i;
 
-	if (argc < 2 || argc > 3)
+	if (argc < 2)
 		return CMD_RET_USAGE;
 
+	if (argc > 2) {
+		for (i = 2; i < argc ; i++) {
+			if (argv[i][0] == '-') {
+				if (!strcmp(argv[i], "-bootable")) {
+					bootable = true;
+				} else {
+					printf("Unknown option %s\n", argv[i]);
+					return CMD_RET_USAGE;
+				}
+			} else {
+				var = argv[i];
+				break;
+			}
+		}
+
+		/* Loops should have been exited@the last argument, which
+		 * as it contained the variable */
+		if (argc != i + 1)
+			return CMD_RET_USAGE;
+	}
+
 	ret = get_device(argv[0], argv[1], &desc);
 	if (ret < 0)
 		return 1;
 
-	if (argc == 3) {
+	if (var != NULL) {
 		int p;
-		char str[512] = { 0, };
+		char str[512] = { '\0', };
 	  disk_partition_t info;
 
 		for (p = 1; p < 128; p++) {
+			char t[5];
 			int r = get_partition_info(desc, p, &info);
 
-			if (r == 0) {
-				char t[5];
-				sprintf(t, "%s%d", str[0] ? " " : "", p);
-				strcat(str, t);
-			}
+			if (r != 0)
+				continue;
+
+			if (bootable && !info.bootable)
+				continue;
+
+			sprintf(t, "%s%d", str[0] ? " " : "", p);
+			strcat(str, t);
 		}
-		setenv(argv[2], str);
+		setenv(var, str);
 		return 0;
 	}
 
@@ -98,7 +126,7 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 }
 
 U_BOOT_CMD(
-	part,	5,	1,	do_part,
+	part,	CONFIG_SYS_MAXARGS,	1,	do_part,
 	"disk partition related commands",
 	"part uuid <interface> <dev>:<part>\n"
 	"    - print partition UUID\n"
@@ -106,6 +134,7 @@ U_BOOT_CMD(
 	"    - set environment variable to partition UUID\n"
 	"part list <interface> <dev>\n"
 	"    - print a device's partition table\n"
-	"part list <interface> <dev> <varname>\n"
-	"    - set environment variable to the list of partitions"
+	"part list <interface> <dev> [flags] <varname>\n"
+	"    - set environment variable to the list of partitions\n"
+	"      flags can be -bootable (list only bootable partitions)"
 );
-- 
2.1.4

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

* [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command
  2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions Sjoerd Simons
@ 2015-02-25 22:23 ` Sjoerd Simons
  2015-03-25 20:49   ` Tom Rini
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions Sjoerd Simons
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Sjoerd Simons @ 2015-02-25 22:23 UTC (permalink / raw)
  To: u-boot

env exists allows scripts to query whether an environment variable
exists. Enable by default as it adds only a trivial amount of code and
can be useful in scripts.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 include/config_cmd_default.h | 1 +
 1 file changed, 1 insertion(+)

Changes since v1:
  * no changes

diff --git a/include/config_cmd_default.h b/include/config_cmd_default.h
index 73c9544..e79a13b 100644
--- a/include/config_cmd_default.h
+++ b/include/config_cmd_default.h
@@ -21,6 +21,7 @@
 #define CONFIG_CMD_CONSOLE	/* coninfo			*/
 #define CONFIG_CMD_ECHO		/* echo arguments		*/
 #define CONFIG_CMD_EDITENV	/* editenv			*/
+#define CONFIG_CMD_ENV_EXISTS	/* query whether env variables exists */
 #define CONFIG_CMD_FPGA		/* FPGA configuration Support	*/
 #define CONFIG_CMD_IMI		/* iminfo			*/
 #define CONFIG_CMD_ITEST	/* Integer (and string) test	*/
-- 
2.1.4

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

* [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions
  2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions Sjoerd Simons
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command Sjoerd Simons
@ 2015-02-25 22:23 ` Sjoerd Simons
  2015-03-25 20:50   ` Tom Rini
  2015-02-25 23:06 ` [U-Boot] [PATCH v2 0/3] Boot from the " Stephen Warren
  2015-03-18  7:45 ` Sjoerd Simons
  4 siblings, 1 reply; 10+ messages in thread
From: Sjoerd Simons @ 2015-02-25 22:23 UTC (permalink / raw)
  To: u-boot

List bootable partitions and only scan those for bootable files, falling
back to partition 1 if there are no bootable partitions

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
---
 include/config_distro_bootcmd.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Changes since v1:
  * No changes

diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h
index 07a0b3b..ad2dda1 100644
--- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h
@@ -197,7 +197,8 @@
 		"done\0"                                                  \
 	\
 	"scan_dev_for_boot_part="                                         \
-		"part list ${devtype} ${devnum} devplist; "               \
+		"part list ${devtype} ${devnum} -bootable devplist; "     \
+		"env exists devplist || setenv devplist 1; "              \
 		"for bootpart in ${devplist}; do "                        \
 			"if fstype ${devtype} ${devnum}:${bootpart} "     \
 					"bootfstype; then "               \
-- 
2.1.4

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

* [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions
  2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
                   ` (2 preceding siblings ...)
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions Sjoerd Simons
@ 2015-02-25 23:06 ` Stephen Warren
  2015-03-18  7:45 ` Sjoerd Simons
  4 siblings, 0 replies; 10+ messages in thread
From: Stephen Warren @ 2015-02-25 23:06 UTC (permalink / raw)
  To: u-boot

On 02/25/2015 03:23 PM, Sjoerd Simons wrote:
> In the discussion after the submission of the "Let the distro boot command scan
> all partitions" patchset it became clear the general consensus was that
> u-boot should not simply scan all partitions but instead only partitions with
> the bootable flag set, falling back to parition 1 as was previously done.
>
> This set of patches implements that

The series,
Reviewed-by: Stephen Warren <swarren@nvidia.com>

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

* [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions
  2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
                   ` (3 preceding siblings ...)
  2015-02-25 23:06 ` [U-Boot] [PATCH v2 0/3] Boot from the " Stephen Warren
@ 2015-03-18  7:45 ` Sjoerd Simons
  2015-03-25  8:45   ` Sjoerd Simons
  4 siblings, 1 reply; 10+ messages in thread
From: Sjoerd Simons @ 2015-03-18  7:45 UTC (permalink / raw)
  To: u-boot

The release of -rc4 reminded me that i never got around to pinging about
this set:

On Wed, 2015-02-25 at 23:23 +0100, Sjoerd Simons wrote:
> In the discussion after the submission of the "Let the distro boot command scan
> all partitions" patchset it became clear the general consensus was that
> u-boot should not simply scan all partitions but instead only partitions with
> the bootable flag set, falling back to parition 1 as was previously done.

As Hans de Goede already remarked for the first revision of this set,
this patchset should probably be included in final v2015.04 to prevent
the boot behaviour of the distro boot commands changing again post
release.

For reference, v2015.1 just tried from the first partition on the
various devices, current master tries to boot from all partitions (due
to one of my earlier patchsets) and with this patchset we again change
to just booting from partitions with the boot flag set, falling back to
the first partition (as was the consensus from the mailinglist
discussion).

> This set of patches implements that
> 
> Changes since v1:
>   * Make updated part list command more precise about what arguments ordering
>     it accepts.
> 
> Sjoerd Simons (3):
>   part: Add support for list filtering on bootable partitions
>   config_cmd_default.h: Add 'env exists' command
>   config_distro_bootcmd.h: Prefer booting from bootable paritions
> 
>  common/cmd_part.c               | 53 +++++++++++++++++++++++++++++++----------
>  include/config_cmd_default.h    |  1 +
>  include/config_distro_bootcmd.h |  3 ++-
>  3 files changed, 44 insertions(+), 13 deletions(-)
> 

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

* [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions
  2015-03-18  7:45 ` Sjoerd Simons
@ 2015-03-25  8:45   ` Sjoerd Simons
  0 siblings, 0 replies; 10+ messages in thread
From: Sjoerd Simons @ 2015-03-25  8:45 UTC (permalink / raw)
  To: u-boot

+ Corrected Tom Rini's e-mail address

On Wed, 2015-03-18 at 08:45 +0100, Sjoerd Simons wrote:
> The release of -rc4 reminded me that i never got around to pinging about
> this set:
> 
> On Wed, 2015-02-25 at 23:23 +0100, Sjoerd Simons wrote:
> > In the discussion after the submission of the "Let the distro boot command scan
> > all partitions" patchset it became clear the general consensus was that
> > u-boot should not simply scan all partitions but instead only partitions with
> > the bootable flag set, falling back to parition 1 as was previously done.
> 
> As Hans de Goede already remarked for the first revision of this set,
> this patchset should probably be included in final v2015.04 to prevent
> the boot behaviour of the distro boot commands changing again post
> release.
> 
> For reference, v2015.1 just tried from the first partition on the
> various devices, current master tries to boot from all partitions (due
> to one of my earlier patchsets) and with this patchset we again change
> to just booting from partitions with the boot flag set, falling back to
> the first partition (as was the consensus from the mailinglist
> discussion).
> 
> > This set of patches implements that
> > 
> > Changes since v1:
> >   * Make updated part list command more precise about what arguments ordering
> >     it accepts.
> > 
> > Sjoerd Simons (3):
> >   part: Add support for list filtering on bootable partitions
> >   config_cmd_default.h: Add 'env exists' command
> >   config_distro_bootcmd.h: Prefer booting from bootable paritions
> > 
> >  common/cmd_part.c               | 53 +++++++++++++++++++++++++++++++----------
> >  include/config_cmd_default.h    |  1 +
> >  include/config_distro_bootcmd.h |  3 ++-
> >  3 files changed, 44 insertions(+), 13 deletions(-)
> > 
> 
> 

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

* [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions Sjoerd Simons
@ 2015-03-25 20:49   ` Tom Rini
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2015-03-25 20:49 UTC (permalink / raw)
  To: u-boot

On Wed, Feb 25, 2015 at 11:23:50PM +0100, Sjoerd Simons wrote:

> Add an optional -bootable parameter to the part list commands to only
> put the list of bootable partitions in the environment variable
> 
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150325/836f6d53/attachment.sig>

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

* [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command Sjoerd Simons
@ 2015-03-25 20:49   ` Tom Rini
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2015-03-25 20:49 UTC (permalink / raw)
  To: u-boot

On Wed, Feb 25, 2015 at 11:23:51PM +0100, Sjoerd Simons wrote:

> env exists allows scripts to query whether an environment variable
> exists. Enable by default as it adds only a trivial amount of code and
> can be useful in scripts.
> 
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150325/a688a2aa/attachment.sig>

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

* [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions
  2015-02-25 22:23 ` [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions Sjoerd Simons
@ 2015-03-25 20:50   ` Tom Rini
  0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2015-03-25 20:50 UTC (permalink / raw)
  To: u-boot

On Wed, Feb 25, 2015 at 11:23:52PM +0100, Sjoerd Simons wrote:

> List bootable partitions and only scan those for bootable files, falling
> back to partition 1 if there are no bootable partitions
> 
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150325/97c06fce/attachment.sig>

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

end of thread, other threads:[~2015-03-25 20:50 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-25 22:23 [U-Boot] [PATCH v2 0/3] Boot from the bootable paritions Sjoerd Simons
2015-02-25 22:23 ` [U-Boot] [PATCH v2 1/3] part: Add support for list filtering on bootable partitions Sjoerd Simons
2015-03-25 20:49   ` Tom Rini
2015-02-25 22:23 ` [U-Boot] [PATCH v2 2/3] config_cmd_default.h: Add 'env exists' command Sjoerd Simons
2015-03-25 20:49   ` Tom Rini
2015-02-25 22:23 ` [U-Boot] [PATCH v2 3/3] config_distro_bootcmd.h: Prefer booting from bootable paritions Sjoerd Simons
2015-03-25 20:50   ` Tom Rini
2015-02-25 23:06 ` [U-Boot] [PATCH v2 0/3] Boot from the " Stephen Warren
2015-03-18  7:45 ` Sjoerd Simons
2015-03-25  8:45   ` Sjoerd Simons

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.