[U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-10 Thread Suriyan Ramasami
Initialize usb and ide.
Scan through the usb for storage and boot capable partitions.
Scan through the ide interface for boot capable partitions.
Present such bootable options to the user to choose to boot from
If the user does not choose any choose the default option
the default option is the option chosen by the user the last time
If no such default option exists, boot from the first possible
bootable option.

Signed-off-by: Suriyan Ramasami 
---
Changes in v2:
- Coding style changes

 board/Seagate/goflexhome/goflexhomemenu.c |  415 +
 1 files changed, 415 insertions(+), 0 deletions(-)
 create mode 100644 board/Seagate/goflexhome/goflexhomemenu.c

diff --git a/board/Seagate/goflexhome/goflexhomemenu.c 
b/board/Seagate/goflexhome/goflexhomemenu.c
new file mode 100644
index 000..6169cf8
--- /dev/null
+++ b/board/Seagate/goflexhome/goflexhomemenu.c
@@ -0,0 +1,415 @@
+/*
+ * Copyright (C) 2013 Suriyan Ramasami 
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#include 
+
+#if defined(CONFIG_MENU)
+/* Menu related code begins here */
+
+/* Added to use the various usb/fat/ext4fs interfaces */
+#include 
+#include 
+#include 
+
+#define MENU_MAX_DEVICES10
+#define MENU_MAX_PARTITIONS 10
+#define MENU_MAX_BOOTABLES  10
+
+#define MENU_EXIT 1
+#define MENU_SHOW 2
+
+#define MENU_DEFAULT_BOOTARGS \
+   "setenv bootargs ${console} ubi.mtd=2,2048 " \
+   "root=ubi0:root rootfstype=ubifs debug"
+
+#define MENU_DEFAULT_BOOTCMD \
+   "setenv bootcmd nand read.e 0x80 0x10 0x60"
+
+#define MENU_PROMPT_BOOTCMD \
+   "setenv bootcmd echo Dropping you to u-boot"
+
+#define MENU_CHOSEN_BOOTARGS \
+   "setenv bootargs $console rootdelay=10 root=${menu_root} debug"
+
+#define MENU_OPTIONS_HEADER \
+   "Bootables:\nChoice\tIntface\tDrive\tDevice\tPart\tFS\tFileName\n" \
+   "---"
+
+#define MENU_DEFAULT_NOBOOTABLES \
+   "* Last boot options (None, and no bootables found!"
+
+struct menu_bootables {
+   charinterface[5];
+   chardrive;
+   int device;
+   int partition;
+   charfilename[64];
+   charfstype; /* f => fat, e => ext2/4 0 => invalid */
+};
+
+static void goflexhome_menuprint(void *print_buffer)
+{
+   printf("%s\n", (char *)print_buffer);
+}
+
+/*
+ * We shall use menu_<> variables to capture the state of past menu
+ * choices.
+ * menu_bootargs corresponds to bootargs
+ * menu_bootcmd corresponds to bootcmd
+ * menu_choice corresponds to the last choice that was picked
+ * menu_choice will be NULL the first time and also
+ * if a choice was never made. In that case we should pick
+ * to boot from the 1st bootable option if present.
+*/
+static int goflexhome_evaluate_env(void)
+{
+char *s;
+
+   run_command("run menu_bootargs", 0);
+   s = getenv("bootargs");
+   printf("bootargs is %s\n", s);
+   run_command("run menu_bootcmd", 0);
+   s = getenv("bootcmd");
+   printf("bootcmd is %s\n", s);
+   if (run_command("run bootcmd", 0) != 0) {
+   /* We failed to boot, present the menu */
+   return MENU_SHOW;
+   }
+   if (strncmp(s, "echo", 4) == 0) {
+   /* User wants the u-boot prmpt */
+   return MENU_EXIT;
+   }
+   run_command("bootm", 0);
+
+   /* We are here, we failed to boot */
+   return MENU_SHOW;
+}
+
+static int goflexhome_handle_choice(struct menu_bootables menu_bootlist[],
+   char *choice)
+{
+char *s, *last_menu_choice;
+char menu_command[128];
+char load_command[16];
+int index;
+int call_saveenv;
+
+   call_saveenv = 0;
+   if (choice == NULL) {
+   /* Exit menu and let it do its auto boot */
+   return MENU_EXIT;
+   }
+   printf("\nYou chose: %s\n", choice);
+
+   last_menu_choice = getenv("menu_choice");
+   if (last_menu_choice == NULL) {
+   /* User has not yet chosen before */
+   /* Lets default to boot from nand */
+   setenv("menu_bootargs", MENU_DEFAULT_BOOTARGS);
+   setenv("menu_bootcmd

Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-10 Thread Rob Herring
On Wed, Apr 10, 2013 at 8:12 AM, Suriyan Ramasami  wrote:
> Initialize usb and ide.
> Scan through the usb for storage and boot capable partitions.
> Scan through the ide interface for boot capable partitions.
> Present such bootable options to the user to choose to boot from
> If the user does not choose any choose the default option
> the default option is the option chosen by the user the last time
> If no such default option exists, boot from the first possible
> bootable option.

This all sounds very generic but...

>
> Signed-off-by: Suriyan Ramasami 
> ---
> Changes in v2:
> - Coding style changes
>
>  board/Seagate/goflexhome/goflexhomemenu.c |  415 
> +

but this is not a generic location. This feature would interest me and
probably Stephen as well.

Rob

>  1 files changed, 415 insertions(+), 0 deletions(-)
>  create mode 100644 board/Seagate/goflexhome/goflexhomemenu.c
>
> diff --git a/board/Seagate/goflexhome/goflexhomemenu.c 
> b/board/Seagate/goflexhome/goflexhomemenu.c
> new file mode 100644
> index 000..6169cf8
> --- /dev/null
> +++ b/board/Seagate/goflexhome/goflexhomemenu.c
> @@ -0,0 +1,415 @@
> +/*
> + * Copyright (C) 2013 Suriyan Ramasami 
> + *
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> + * MA 02110-1301 USA
> + */
> +
> +#include 
> +
> +#if defined(CONFIG_MENU)
> +/* Menu related code begins here */
> +
> +/* Added to use the various usb/fat/ext4fs interfaces */
> +#include 
> +#include 
> +#include 
> +
> +#define MENU_MAX_DEVICES10
> +#define MENU_MAX_PARTITIONS 10
> +#define MENU_MAX_BOOTABLES  10
> +
> +#define MENU_EXIT 1
> +#define MENU_SHOW 2
> +
> +#define MENU_DEFAULT_BOOTARGS \
> +   "setenv bootargs ${console} ubi.mtd=2,2048 " \
> +   "root=ubi0:root rootfstype=ubifs debug"
> +
> +#define MENU_DEFAULT_BOOTCMD \
> +   "setenv bootcmd nand read.e 0x80 0x10 0x60"
> +
> +#define MENU_PROMPT_BOOTCMD \
> +   "setenv bootcmd echo Dropping you to u-boot"
> +
> +#define MENU_CHOSEN_BOOTARGS \
> +   "setenv bootargs $console rootdelay=10 root=${menu_root} debug"
> +
> +#define MENU_OPTIONS_HEADER \
> +   "Bootables:\nChoice\tIntface\tDrive\tDevice\tPart\tFS\tFileName\n" \
> +   "---"
> +
> +#define MENU_DEFAULT_NOBOOTABLES \
> +   "* Last boot options (None, and no bootables found!"
> +
> +struct menu_bootables {
> +   charinterface[5];
> +   chardrive;
> +   int device;
> +   int partition;
> +   charfilename[64];
> +   charfstype; /* f => fat, e => ext2/4 0 => invalid */
> +};
> +
> +static void goflexhome_menuprint(void *print_buffer)
> +{
> +   printf("%s\n", (char *)print_buffer);
> +}
> +
> +/*
> + * We shall use menu_<> variables to capture the state of past menu
> + * choices.
> + * menu_bootargs corresponds to bootargs
> + * menu_bootcmd corresponds to bootcmd
> + * menu_choice corresponds to the last choice that was picked
> + * menu_choice will be NULL the first time and also
> + * if a choice was never made. In that case we should pick
> + * to boot from the 1st bootable option if present.
> +*/
> +static int goflexhome_evaluate_env(void)
> +{
> +char *s;
> +
> +   run_command("run menu_bootargs", 0);
> +   s = getenv("bootargs");
> +   printf("bootargs is %s\n", s);
> +   run_command("run menu_bootcmd", 0);
> +   s = getenv("bootcmd");
> +   printf("bootcmd is %s\n", s);
> +   if (run_command("run bootcmd", 0) != 0) {
> +   /* We failed to boot, present the menu */
> +   return MENU_SHOW;
> +   }
> +   if (strncmp(s, "echo", 4) == 0) {
> +   /* User wants the u-boot prmpt */
> +   return MENU_EXIT;
> +   }
> +   run_command("bootm", 0);
> +
> +   /* We are here, we failed to boot */
> +   return MENU_SHOW;
> +}
> +
> +static int goflexhome_handle_choice(struct menu_bootables menu_bootlist[],
> +   char *choice)
> +{
> +char *s, *last_menu_choice;
> +char menu_command[128];
> +char load_command[16];
> +int index;
> +int call_saveenv;
> +
> +   call_saveen

Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-10 Thread Suriyan Ramasami
I shall probably move it to a generic location with a more generic name.
Any reocmmendations?

- Suriyan


On Wed, Apr 10, 2013 at 6:43 PM, Rob Herring  wrote:

> On Wed, Apr 10, 2013 at 8:12 AM, Suriyan Ramasami 
> wrote:
> > Initialize usb and ide.
> > Scan through the usb for storage and boot capable partitions.
> > Scan through the ide interface for boot capable partitions.
> > Present such bootable options to the user to choose to boot from
> > If the user does not choose any choose the default option
> > the default option is the option chosen by the user the last time
> > If no such default option exists, boot from the first possible
> > bootable option.
>
> This all sounds very generic but...
>
> >
> > Signed-off-by: Suriyan Ramasami 
> > ---
> > Changes in v2:
> > - Coding style changes
> >
> >  board/Seagate/goflexhome/goflexhomemenu.c |  415
> +
>
> but this is not a generic location. This feature would interest me and
> probably Stephen as well.
>
> Rob
>
> >  1 files changed, 415 insertions(+), 0 deletions(-)
> >  create mode 100644 board/Seagate/goflexhome/goflexhomemenu.c
> >
> > diff --git a/board/Seagate/goflexhome/goflexhomemenu.c
> b/board/Seagate/goflexhome/goflexhomemenu.c
> > new file mode 100644
> > index 000..6169cf8
> > --- /dev/null
> > +++ b/board/Seagate/goflexhome/goflexhomemenu.c
> > @@ -0,0 +1,415 @@
> > +/*
> > + * Copyright (C) 2013 Suriyan Ramasami 
> > + *
> > + * See file CREDITS for list of people who contributed to this
> > + * project.
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License as
> > + * published by the Free Software Foundation; either version 2 of
> > + * the License, or (at your option) any later version.
> > + *
> > + * This program is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> > + * GNU General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU General Public License
> > + * along with this program; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> > + * MA 02110-1301 USA
> > + */
> > +
> > +#include 
> > +
> > +#if defined(CONFIG_MENU)
> > +/* Menu related code begins here */
> > +
> > +/* Added to use the various usb/fat/ext4fs interfaces */
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define MENU_MAX_DEVICES10
> > +#define MENU_MAX_PARTITIONS 10
> > +#define MENU_MAX_BOOTABLES  10
> > +
> > +#define MENU_EXIT 1
> > +#define MENU_SHOW 2
> > +
> > +#define MENU_DEFAULT_BOOTARGS \
> > +   "setenv bootargs ${console} ubi.mtd=2,2048 " \
> > +   "root=ubi0:root rootfstype=ubifs debug"
> > +
> > +#define MENU_DEFAULT_BOOTCMD \
> > +   "setenv bootcmd nand read.e 0x80 0x10 0x60"
> > +
> > +#define MENU_PROMPT_BOOTCMD \
> > +   "setenv bootcmd echo Dropping you to u-boot"
> > +
> > +#define MENU_CHOSEN_BOOTARGS \
> > +   "setenv bootargs $console rootdelay=10 root=${menu_root} debug"
> > +
> > +#define MENU_OPTIONS_HEADER \
> > +
> "Bootables:\nChoice\tIntface\tDrive\tDevice\tPart\tFS\tFileName\n" \
> > +   "---"
> > +
> > +#define MENU_DEFAULT_NOBOOTABLES \
> > +   "* Last boot options (None, and no bootables found!"
> > +
> > +struct menu_bootables {
> > +   charinterface[5];
> > +   chardrive;
> > +   int device;
> > +   int partition;
> > +   charfilename[64];
> > +   charfstype; /* f => fat, e => ext2/4 0 => invalid */
> > +};
> > +
> > +static void goflexhome_menuprint(void *print_buffer)
> > +{
> > +   printf("%s\n", (char *)print_buffer);
> > +}
> > +
> > +/*
> > + * We shall use menu_<> variables to capture the state of past menu
> > + * choices.
> > + * menu_bootargs corresponds to bootargs
> > + * menu_bootcmd corresponds to bootcmd
> > + * menu_choice corresponds to the last choice that was picked
> > + * menu_choice will be NULL the first time and also
> > + * if a choice was never made. In that case we should pick
> > + * to boot from the 1st bootable option if present.
> > +*/
> > +static int goflexhome_evaluate_env(void)
> > +{
> > +char *s;
> > +
> > +   run_command("run menu_bootargs", 0);
> > +   s = getenv("bootargs");
> > +   printf("bootargs is %s\n", s);
> > +   run_command("run menu_bootcmd", 0);
> > +   s = getenv("bootcmd");
> > +   printf("bootcmd is %s\n", s);
> > +   if (run_command("run bootcmd", 0) != 0) {
> > +   /* We failed to boot, present the menu */
> > +   return MENU_SHOW;
> > +   }
> > +   if (strncmp(s, "echo", 4) == 0) {
> > +   /* User wants the u-boot prmpt */
> > +   return MENU_

Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-11 Thread Mike Dunn
On 04/10/2013 06:43 PM, Rob Herring wrote:
> On Wed, Apr 10, 2013 at 8:12 AM, Suriyan Ramasami  wrote:
>> Initialize usb and ide.
>> Scan through the usb for storage and boot capable partitions.
>> Scan through the ide interface for boot capable partitions.
>> Present such bootable options to the user to choose to boot from
>> If the user does not choose any choose the default option
>> the default option is the option chosen by the user the last time
>> If no such default option exists, boot from the first possible
>> bootable option.
> 
> This all sounds very generic but...
> 
>>
>> Signed-off-by: Suriyan Ramasami 
>> ---
>> Changes in v2:
>> - Coding style changes
>>
>>  board/Seagate/goflexhome/goflexhomemenu.c |  415 
>> +
> 
> but this is not a generic location. This feature would interest me and
> probably Stephen as well.


I was thinking along these lines as well for the treo 680.  Suriyan, perhaps we
can collaborate, with the guidance of the maintainers here.

Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-11 Thread Suriyan Ramasami
Sounds good to me.

I shall attempt a generic version and call it cmd_bootscan.c in the common
directory.

- Suriyan


On Thu, Apr 11, 2013 at 6:02 AM, Mike Dunn  wrote:

> On 04/10/2013 06:43 PM, Rob Herring wrote:
> > On Wed, Apr 10, 2013 at 8:12 AM, Suriyan Ramasami 
> wrote:
> >> Initialize usb and ide.
> >> Scan through the usb for storage and boot capable partitions.
> >> Scan through the ide interface for boot capable partitions.
> >> Present such bootable options to the user to choose to boot from
> >> If the user does not choose any choose the default option
> >> the default option is the option chosen by the user the last time
> >> If no such default option exists, boot from the first possible
> >> bootable option.
> >
> > This all sounds very generic but...
> >
> >>
> >> Signed-off-by: Suriyan Ramasami 
> >> ---
> >> Changes in v2:
> >> - Coding style changes
> >>
> >>  board/Seagate/goflexhome/goflexhomemenu.c |  415
> +
> >
> > but this is not a generic location. This feature would interest me and
> > probably Stephen as well.
>
>
> I was thinking along these lines as well for the treo 680.  Suriyan,
> perhaps we
> can collaborate, with the guidance of the maintainers here.
>
> Mike
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-12 Thread Tom Rini
On Thu, Apr 11, 2013 at 12:51:03PM -0700, Suriyan Ramasami wrote:

> Sounds good to me.
> 
> I shall attempt a generic version and call it cmd_bootscan.c in the common
> directory.

A good first pass.  Please keep board/ait/cam_enc_4xx/cam_enc_4xx.c in
mind as that has a similar set of things going on.  Thanks!

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot