ANSI terminal Bootmenu
cover ANSI terminal Bootmenu
This patch series adds ANSI terminal Bootmenu command. It use generic menu code for creating menu structures, but use own functions for drawing menu on ANSI terminal. First patch modify generic menu code for using other functions for printing and choosing menu entry, second patch is bootmenu command itself.
Pali Roh?r (2):
menu: Added support to use user defined functions New command bootmenu: ANSI terminal Boot Menu support
board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 +- common/Makefile | 1 + common/cmd_bootmenu.c | 446 +++++++++++++++++++++++++++++++++++ common/cmd_pxe.c | 3 +- common/menu.c | 43 ++-- doc/README.bootmenu | 61 +++++ include/common.h | 20 ++ include/config_cmd_all.h | 1 + include/menu.h | 6 +- 9 files changed, 566 insertions(+), 20 deletions(-) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu
Signature · 1 line
1.7.9.5
PATCH 1/2 menu: Added support to use user defined functions
* In menu_interactive_choice can be used user specified function item_data_choice (instead hardcoded function which read input from standard input)
* Added option to specify user data for menu
* menu_display_statusline will pass pointer to user data (instead pointer to menu)
* This patch is needed for creating ANSI bootmenu
--- board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 ++-- common/cmd_pxe.c | 3 ++- common/menu.c | 43 +++++++++++++++++++++++------------ include/menu.h | 6 +++-- 4 files changed, 37 insertions(+), 20 deletions(-)
board/ait/cam_enc_4xx/cam_enc_4xx.c +3 -2
@@ -561,7 +561,8 @@ static char *menu_handle(struct menu_display *display)char *s;char temp[6 ][200 ]; - m =menu_create (display->title, display->timeout,1 , ait_menu_print); + m =menu_create (display->title, display->timeout,1 , ait_menu_print, +NULL ,NULL );for (i =0 ; display->menulist[i]; i++) {sprintf (key,"%d" , i +1 );
@@ -1097,7 +1098,7 @@ int menu_show(int bootdelay)return MENU_EXIT ; } -void menu_display_statusline (struct menu *m) +void menu_display_statusline (void *data) {char *s1, *s2;
common/cmd_pxe.c +2 -1
@@ -1198,7 +1198,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)/* * Create a menu and add items for all the labels. */ - m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print); + m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print, +NULL ,NULL );if (!m)return NULL ;
common/menu.c +28 -15
85 lines not on this page · raw message
include/menu.h +4 -2
@@ -21,12 +21,14 @@struct menu ;struct menu *menu_create (char *title,int timeout,int prompt, -void (*item_data_print)(void *)); +void (*item_data_print)(void *), +char *(*item_data_choice)(void *), +void *menu_data);int menu_default_set (struct menu *m,char *item_key);int menu_get_choice (struct menu *m,void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);int menu_destroy (struct menu *m); -void menu_display_statusline (struct menu *m); +void menu_display_statusline (void *menu_data);#if defined(CONFIG_MENU_SHOW )int menu_show (int bootdelay);
Signature · 1 line
1.7.9.5
PATCH 1/2 menu: Added support to use user defined functions
Dear Pali Roh?r,
Please CC proper custodians in order to get reviews next time.
[...]
include/menu.h line 25
Quoted 9 lines
include/menu.h +2
-1@@ -21,12 +21,14 @@struct menu ; struct menu *menu_create(char *title, int timeout, int prompt, -void (*item_data_print)(void *)); + void (*item_data_print)(void *), + char *(*item_data_choice)(void *),
Where is this item_data_choice() used?
include/menu.h line 34
Quoted 10 lines
include/menu.h +2
-1+ void *menu_data);int menu_default_set (struct menu *m,char *item_key);int menu_get_choice (struct menu *m,void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);int menu_destroy (struct menu *m); -void menu_display_statusline (struct menu *m); +void menu_display_statusline (void *menu_data);#if defined(CONFIG_MENU_SHOW )int menu_show (int bootdelay);
Best regards,
Marek Vasut
PATCH 1/2 menu: Added support to use user defined functions
Quoted 6 lines · On Sunday 03 June 2012 11:59:16 Marek Vasut wrote:
Quoted 6 lines
include/menu.h +0
-0@@ -21,12 +21,14 @@struct menu ;
Quoted 8 lines
include/menu.h line 25
Quoted 6 lines
include/menu.h +2
-1struct menu *menu_create(char *title, int timeout, int prompt, -void (*item_data_print)(void *)); + void (*item_data_print)(void *), + char *(*item_data_choice)(void *),Where is this
item_data_choice()used?
This is alternative function for menu entry choice. It is used in function menu_interactive_choice. If item_data_choice is NULL default code with readline_into_buffer is used.
ANSI bootmenu command (in next patch) is using its own function.
Signature · 9 lines
Pali Roh?r pali.rohar at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120603/890ac1d8/attachment.pgp>
PATCH 1/2 menu: Added support to use user defined functions
Dear Pali Roh?r,
Quoted 16 lines · On Sunday 03 June 2012 11:59:16 Marek Vasut wrote:
Quoted 6 lines
Quoted 6 lines
include/menu.h +0
-0@@ -21,12 +21,14 @@struct menu ;Quoted 8 lines
include/menu.h line 25
Quoted 6 lines
include/menu.h +2
-1struct menu *menu_create(char *title, int timeout, int prompt, -void (*item_data_print)(void *)); + void (*item_data_print)(void *), + char *(*item_data_choice)(void *),Where is this
item_data_choice()used?
Quoted 5 lines
This is alternative function for menu entry choice. It is used in function
menu_interactive_choice. Ifitem_data_choiceis NULL default code withreadline_into_bufferis used.ANSI bootmenu command (in next patch) is using its own function.
Hm so why not make this ANSI stuff one plugin and the other bootmenu stuff another plugin (which will be default). Then you won't have to check if anything is null.
Best regards,
Marek Vasut
PATCH 2/2 New command bootmenu: ANSI terminal Boot Menu support
In reply to Pali Rohár--- common/Makefile | 1 + common/cmd_bootmenu.c | 446 ++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 61 +++++++ include/common.h | 20 +++ include/config_cmd_all.h | 1 + 5 files changed, 529 insertions(+) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu
common/Makefile +1 -0
@@ -69,6 +69,7 @@ COBJS-$(CONFIG_CMD_SOURCE) += cmd_source.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o +COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
common/cmd_bootmenu.c new file +446 -0
446 lines not on this page · raw message
doc/README.bootmenu new file +61 -0
61 lines not on this page · raw message
include/common.h +20 -0
@@ -761,6 +761,26 @@ void clear_ctrlc (void); /* clear the Control-C condition */int disable_ctrlc (int );/* 1 to disable, 0 to enable Control-C detect */ /* +* ANSI terminal +*/ + +#define ANSI_CURSOR_UP "\e[%dA" +#define ANSI_CURSOR_DOWN "\e[%dB" +#define ANSI_CURSOR_FORWARD "\e[%dC" +#define ANSI_CURSOR_BACK "\e[%dD" +#define ANSI_CURSOR_NEXTLINE "\e[%dE" +#define ANSI_CURSOR_PREVIOUSLINE "\e[%dF" +#define ANSI_CURSOR_COLUMN "\e[%dG" +#define ANSI_CURSOR_POSITION "\e[%d;%dH" +#define ANSI_CURSOR_SHOW "\e[?25h" +#define ANSI_CURSOR_HIDE "\e[?25l" +#define ANSI_CLEAR_CONSOLE "\e[2J" +#define ANSI_CLEAR_LINE_TO_END "\e[0K" +#define ANSI_CLEAR_LINE "\e[2K" +#define ANSI_COLOR_RESET "\e[0m" +#define ANSI_COLOR_REVERSE "\e[7m" + +/* * STDIO based functions (can always be used) */ /* serial stuff */
include/config_cmd_all.h +1 -0
@@ -19,6 +19,7 @@#define CONFIG_CMD_BEDBUG /* Include BedBug Debugger */ #define CONFIG_CMD_BMP /* BMP support */ #define CONFIG_CMD_BOOTD /* bootd */ +#define CONFIG_CMD_BOOTMENU /* ANSI terminal Boot Menu */ #define CONFIG_CMD_BOOTZ /* boot zImage */ #define CONFIG_CMD_BSP /* Board Specific functions */ #define CONFIG_CMD_CACHE /* icache, dcache */
Signature · 1 line
1.7.9.5
PATCH 2/2 New command bootmenu: ANSI terminal Boot Menu support
Dear Pali Roh?r,
Quoted 1 line
Signed-off-by Pali Roh?r <[email protected]>
Try keeping the subject line short and add a patch description instead. Btw. Try avoiding unicode characters in the patch. Also, is "Pali" your real name that you have on your IDs etc. ?
Quoted 70 lines
--- common/Makefile | 1 + common/cmd_bootmenu.c | 446 ++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 61 +++++++ include/common.h | 20 +++ include/config_cmd_all.h | 1 + 5 files changed, 529 insertions(+) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenucommon/Makefile +1
-0@@ -69,6 +69,7 @@ COBJS-$(CONFIG_CMD_SOURCE) += cmd_source.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o +COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.ocommon/cmd_bootmenu.c new file +41
-0@@ -0,0 +1,446 @@ +/* +* (C) Copyright 2011-2012 Pali Roh?r <[email protected]> +* +* 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., 59 Temple Place, Suite 330, Boston, +* MA 02111-1307 USA +*/ + +#include <common.h> +#include <command.h> +#include <menu.h> +#include <hush.h> +#include <watchdog.h> +#include <malloc.h> +#include <linux/string.h> + +struct bootmenu_entry { +int num;/* unique number 0..99 */ +char key[3 ];/* key idetifier of number */ +char *title;/* title of entry */ +char *command;/* hush command of entry */ +struct bootmenu_data *menu;/* this bootmenu */ +struct bootmenu_entry *next;/* next menu entry (num+1) */ +}; + +struct bootmenu_data { +int delay;/* delay for autoboot */
common/cmd_bootmenu.c line 51
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+int active;/* active menu entry */ +int count;/* total count of menu entries */ +struct bootmenu_entry *first;/* first menu entry */ +}; + +static char *bootmenu_getoption (int n) +{ +char name[] ="bootmenu_\0\0" ; + +if (n <0 || n >99 )
Why add this artificial limit?
common/cmd_bootmenu.c line 61
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+return NULL ; + +sprintf (name+9 ,"%d" , n); +return getenv (name); +} + +static void bootmenu_print_entry (void *data) +{ +struct bootmenu_entry *entry = data; +int reverse = (entry->menu->active == entry->num);
Why not just write it below into the condition?
common/cmd_bootmenu.c line 63
Quoted 2 lines
common/cmd_bootmenu.c new file +2
-0+ +printf (ANSI_CURSOR_POSITION , entry->num +4 ,1 );
What are all these artificial numbers here?
Quoted 8 lines
common/cmd_bootmenu.c new file +8
-0+ +if (reverse) +puts (ANSI_COLOR_REVERSE ); + +puts (" " ); +puts (entry->title); +puts (ANSI_CLEAR_LINE_TO_END ); +
common/cmd_bootmenu.c line 81
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+if (reverse) +puts (ANSI_COLOR_RESET ); +} + +static char *bootmenu_choice_entry (void *data) +{ +struct bootmenu_data *menu = data; + +int key =0 ;/* 0 - NONE, 1 - UP, 2 - DOWN, 3 - SELECT */ +int esc =0 ;
Can't the spaghetti function below be split into multiple smaller ones? You know the rule of the thumb, if the code spans multiple screens, something's seriously wrong.
Quoted 5 lines
common/cmd_bootmenu.c new file +5
-0+while (1 ) { + +if (menu->delay >=0 ) { + +if (menu->delay >0 ) {
common/cmd_bootmenu.c line 97
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+printf (ANSI_CURSOR_POSITION , menu->count+5 ,1 ); +printf (" Hit any key to stop autoboot: %2d " , + menu->delay); + } + +while (menu->delay >0 ) { + +int i; +for (i =0 ; i <100 ; ++i) { +if (tstc ()) {
if (!tstc())
continue;
... do your job
break;
You'll get one less level of indent and much more readable code.
Quoted 7 lines
common/cmd_bootmenu.c new file +7
-0+ menu->delay =-1 ; + key =getc (); + +if (key =='\e' ) { + esc =1 ; + key =0 ; + }else if (key =='\r' )
common/cmd_bootmenu.c line 114
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+ key =3 ; + else + key =0 ; + +break ; + + } + +WATCHDOG_RESET (); +udelay (10000 );
mdelay() ?
common/cmd_bootmenu.c line 121
Quoted 7 lines
common/cmd_bootmenu.c new file +7
-0+ + } + +if (menu->delay <0 ) +break ; + + --menu->delay;
Why do you use predecrement in the above statement? It's pointless here, simply postdecrement it.
Quoted 50 lines
common/cmd_bootmenu.c new file +50
-0+printf ("\b\b\b%2d " , menu->delay); + + } + +if (menu->delay ==0 ) + key =3 ; + + }else { + +while (!tstc ()) { +WATCHDOG_RESET (); +udelay (10000 ); + } + + key =getc (); + +if (esc ==0 ) { + +if (key =='\e' ) { + esc =1 ; + key =0 ; + } + + }else if (esc ==1 ) { + +if (key =='[' ) { + esc =2 ; + key =0 ; + }else + esc =0 ; + + }else if (esc ==2 || esc ==3 ) { + +if (esc ==2 && key =='1' ) { + esc =3 ; + key =0 ; + }else + esc =0 ; + +if (key =='A' ) + key =1 ; +else if (key =='B' ) + key =2 ; +else + key =0 ; + + } + +if (key =='\r' ) + key =3 ;
common/cmd_bootmenu.c line 181
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+ + } + +if (key ==1 ) { +if (menu->active >0 ) + --menu->active; +return "" ;/* invalid menu entry, regenerate menu */ + }else if (key ==2 ) { +if (menu->active < menu->count-1 ) + ++menu->active;
Let me guess ... they taught you at the compiler class that predecrement is faster than postdecrement, right? Not so much on anything but intel ... and even on intel, GCC does the decision about putting the instructions there properly to create the fastest possible code anyway.
common/cmd_bootmenu.c line 193
Quoted 12 lines
common/cmd_bootmenu.c new file +12
-0+return "" ;/* invalid menu entry, regenerate menu */ + }else if (key ==3 ) { +int i; +struct bootmenu_entry *iter = menu->first; +for (i =0 ; i < menu->active; ++i) + iter = iter->next; +return iter->key; + } + + } + +/* never happends */
Add debug() clause maybe ?
Quoted 115 lines
common/cmd_bootmenu.c new file +115
-0+return NULL ; +} + +static struct bootmenu_data *bootmenu_create (int delay) +{ +int i =0 ; +const char *option; +struct bootmenu_data *menu; +struct bootmenu_entry *iter =NULL ; + + menu =malloc (sizeof (struct bootmenu_data )); +if (!menu) +return NULL ; + + menu->delay = delay; + menu->active =0 ; + menu->first =NULL ; + +while ((option =bootmenu_getoption (i))) { + +int len; +char *sep; +struct bootmenu_entry *entry; + + sep =strchr (option,'=' ); +if (!sep) +break ; + + entry =malloc (sizeof (struct bootmenu_entry )); +if (!entry) + goto cleanup; + + len = sep-option; + entry->title =malloc (len+1 ); +if (!entry->title) { +free (entry); + goto cleanup; + } +memcpy (entry->title, option, len); + entry->title[len] =0 ; + + len =strlen (sep+1 ); + entry->command =malloc (len+1 ); +if (!entry->command) { +free (entry->title); +free (entry); + goto cleanup; + } +memcpy (entry->command, sep+1 , len); + entry->command[len] =0 ; + +sprintf (entry->key,"%d" , i); + + entry->num = i; + entry->menu = menu; + entry->next =NULL ; + +if (!iter) + menu->first = entry; +else + iter->next = entry; + + iter = entry; + ++i; + +if (i >=100 ) +break ; + + } + +/* Add U-Boot console entry at the end */ +if (i <100 ) { +struct bootmenu_entry *entry =malloc ( +sizeof (struct bootmenu_entry )); +if (!entry) + goto cleanup; + + entry->title =strdup ("U-Boot console" ); +if (!entry->title) { +free (entry); + goto cleanup; + } + + entry->command =strdup ("" ); +if (!entry->command) { +free (entry->title); +free (entry); + goto cleanup; + } + + entry->num = i; + entry->menu = menu; + entry->next =NULL ; + +if (!iter) + menu->first = entry; +else + iter->next = entry; + + iter = entry; + ++i; + + } + + menu->count = i; +return menu; + +cleanup: + iter = menu->first; +while (iter) { +struct bootmenu_entry *next = iter->next; +free (iter->title); +free (iter->command); +free (iter); + iter = next;
common/cmd_bootmenu.c line 318
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+ } +free (menu); +return NULL ; +} + +static void bootmenu_destroy (struct bootmenu_data *menu) +{ +struct bootmenu_entry *iter = menu->first; +while (iter) { +struct bootmenu_entry *next = iter->next;
I don't like how you declare variables in the middle of code. It has sideeffects and looking them up is really troublesome.
Quoted 213 lines
common/cmd_bootmenu.c new file +128
-0+free (iter->title); +free (iter->command); +free (iter); + iter = next; + } +free (menu); +} + +static void bootmenu_show (int delay) +{ +int init =0 ; +void *choice =NULL ; +char *title =NULL ; +char *command =NULL ; +struct menu *menu; +struct bootmenu_data *bootmenu; +struct bootmenu_entry *iter; + +/* If delay is 0 do not create menu, just run first entry */ +if (delay ==0 ) { +char *option, *sep; + option =bootmenu_getoption (0 ); +if (!option) +return ; + sep =strchr (option,'=' ); +if (!sep) +return ; +run_command (sep+1 ,0 ); +return ; + } + + bootmenu =bootmenu_create (delay); +if (!bootmenu) +return ; + + menu =menu_create (NULL , bootmenu->delay, (bootmenu->delay >=0 ), + bootmenu_print_entry, bootmenu_choice_entry, bootmenu); +if (!menu) +return ; + +for (iter = bootmenu->first; iter; iter = iter->next) +if (!menu_item_add (menu, iter->key, iter)) + goto cleanup; + +/* Default menu entry is always first */ +menu_default_set (menu,"0" ); + +puts (ANSI_CURSOR_HIDE ); +puts (ANSI_CLEAR_CONSOLE ); +printf (ANSI_CURSOR_POSITION ,1 ,1 ); + + init =1 ; + +if (menu_get_choice (menu, &choice)) { + iter = choice; + title =strdup (iter->title); + command =strdup (iter->command); + } + +cleanup: +menu_destroy (menu); +bootmenu_destroy (bootmenu); + +if (init) { +puts (ANSI_CURSOR_SHOW ); +puts (ANSI_CLEAR_CONSOLE ); +printf (ANSI_CURSOR_POSITION ,1 ,1 ); + } + +if (title && command) { +printf ("Starting entry '%s'\n" , title); +free (title); +run_command (command,0 ); +free (command); + } +} + +void menu_display_statusline (void *data) +{ +struct bootmenu_data *menu = data; + +printf (ANSI_CURSOR_POSITION ,1 ,1 ); +puts (ANSI_CLEAR_LINE ); +printf (ANSI_CURSOR_POSITION ,2 ,1 ); +puts (" *** U-Boot BOOT MENU ***" ); +puts (ANSI_CLEAR_LINE_TO_END ); +printf (ANSI_CURSOR_POSITION ,3 ,1 ); +puts (ANSI_CLEAR_LINE ); + +printf (ANSI_CURSOR_POSITION , menu->count +5 ,1 ); +puts (ANSI_CLEAR_LINE ); +printf (ANSI_CURSOR_POSITION , menu->count +6 ,1 ); +puts (" Press UP/DOWN to move, ENTER to select" ); +puts (ANSI_CLEAR_LINE_TO_END ); +printf (ANSI_CURSOR_POSITION , menu->count +7 ,1 ); +puts (ANSI_CLEAR_LINE ); +} + +int menu_show (int bootdelay) +{ +bootmenu_show (bootdelay); +return -1 ;/* -1 - abort boot and run monitor code */ +} + +int do_bootmenu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +char *delay_str =NULL ; +int delay =10 ; + +if (argc >=2 ) + delay_str = argv[1 ]; + +if (!delay_str) + delay_str =getenv ("bootmenu_delay" ); + +if (delay_str) + delay = (int )simple_strtol (delay_str,NULL ,10 ); + +bootmenu_show (delay); +return 0 ; +} + +U_BOOT_CMD ( + bootmenu,2 ,1 , do_bootmenu, +"ANSI terminal bootmenu" , +"[delay]\n" +" - show ANSI terminal bootmenu with autoboot delay (default 10s)" +);doc/README.bootmenu new file +36
-0@@ -0,0 +1,61 @@ +/* + * (C) Copyright 2011-2012 Pali Roh?r <[email protected]> + * + * 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., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +This is ANSI terminal BootMenu command. It is extension to generic menu, +which provide output for ANSI terminals. + +Configuration is done via env variables bootmenu_delay and bootmenu_<num>: + + bootmenu_delay=<delay> + bootmenu_<num>="<title>=<commands>" + + (title and commands are separated by first char '=') + + <delay> is delay in seconds of autobooting first entry + <num> is boot menu entry, starting from zero + <title> is text shown in boot screen + <commands> are commands which will be executed when menu entry isselected +
doc/README.bootmenu new file +2
-0+First argument of bootmenu command override bootmenu_delay env +If env bootmenu_delay or bootmenu arg is not specified, delay is 10seconds +If delay is 0, no entry will be shown on screen and first will be called +If delay is less then 0, no autoboot delay will be used
doc/README.bootmenu new file +6
-0+Boot Menu will stop finding next menu entry if last was not defined +Boot Menu always add menu entry "U-Boot console" at end of all entries + +Example using: + + setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Set first menuentry + setenv
bootmenu_1Boot 2. kernel=bootm0x83000000# Set second
menu entry + setenvbootmenu_2Reset board=reset # Set
third menu entry + setenvbootmenu_3U-Boot boot order=boot #
Set fourth menu entry + setenvbootmenu_4# Empty string is end of all
bootmenu entries + bootmenu 20 # Run bootmenu with autoboot delay
20sdoc/README.bootmenu new file +9
-0+ + +To enable ANSI bootmenu comamnd add these definitions to board code: + + #define CONFIG_BOOTDELAY 30 + #define CONFIG_AUTOBOOT_KEYED + #define CONFIG_MENU + #define CONFIG_MENU_SHOW + #define CONFIG_CMD_BOOTMENUinclude/common.h +0
-0@@ -761,6 +761,26 @@ void clear_ctrlc (void); /* clear the Control-Ccondition */ int
disable_ctrlc(int); /* 1 to disable, 0 to enable
Control-C detect *//*
+ * ANSI terminal
+ */include/common.h +6
-0+ +#define ANSI_CURSOR_UP "\e[%dA" +#define ANSI_CURSOR_DOWN "\e[%dB" +#define ANSI_CURSOR_FORWARD "\e[%dC" +#define ANSI_CURSOR_BACK "\e[%dD" +#define ANSI_CURSOR_NEXTLINE "\e[%dE"
include/common.h void clear_ctrlc (void); /* clear the Control-C condition */ · line 781
Quoted 10 lines
include/common.h +10
-0+#define ANSI_CURSOR_PREVIOUSLINE "\e[%dF" +#define ANSI_CURSOR_COLUMN "\e[%dG" +#define ANSI_CURSOR_POSITION "\e[%d;%dH" +#define ANSI_CURSOR_SHOW "\e[?25h" +#define ANSI_CURSOR_HIDE "\e[?25l" +#define ANSI_CLEAR_CONSOLE "\e[2J" +#define ANSI_CLEAR_LINE_TO_END "\e[0K" +#define ANSI_CLEAR_LINE "\e[2K" +#define ANSI_COLOR_RESET "\e[0m" +#define ANSI_COLOR_REVERSE "\e[7m"
Isn't it possible to extend the normal bootmenu code with the ansi command sequences and be done with it?
Quoted 16 lines
include/common.h +1
-0+/* * STDIO based functions (can always be used) */ /* serial stuff */ include/config_cmd_all.h +1
-0@@ -19,6 +19,7 @@#define CONFIG_CMD_BEDBUG /* Include BedBug Debugger */ #define CONFIG_CMD_BMP /* BMP support */ #define CONFIG_CMD_BOOTD /* bootd */ +#define CONFIG_CMD_BOOTMENU /* ANSI terminal Boot Menu */ #define CONFIG_CMD_BOOTZ /* boot zImage */ #define CONFIG_CMD_BSP /* Board Specific functions */ #define CONFIG_CMD_CACHE /* icache, dcache */
PATCH 2/2 New command bootmenu: ANSI terminal Boot Menu support
Hi Marek,
Quoted 7 lines · Marek Vasut
Dear Pali Roh?r,
Quoted 1 line
Signed-off-by Pali Roh?r <[email protected]>Try keeping the subject line short and add a patch description instead. Btw. Try avoiding unicode characters in the patch. Also, is "Pali" your real name that you have on your IDs etc. ?
What kind of question is that :) ?
Like you can do anything if it's real or not...
Regards,
Luka
PATCH 2/2 New command bootmenu: ANSI terminal Boot Menu support
Dear Luka Perkov,
Quoted 7 lines
Hi Marek,
Quoted 4 lines · Marek Vasut
Dear Pali Roh?r,
Quoted 1 line
Signed-off-by Pali Roh?r <[email protected]>
Quoted 7 lines
Quoted 3 lines
Try keeping the subject line short and add a patch description instead. Btw. Try avoiding unicode characters in the patch. Also, is "Pali" your real name that you have on your IDs etc. ?
What kind of question is that :) ?
Like you can do anything if it's real or not...
I can vote for the patch to not be merged obviously if it's of suspicious origin. But before you loose your temper completely and flame me to death, read on ...
Basically, I don't want to be the bitch that wards people off here, but we better obey some kind of rules. See http://lwn.net/Articles/195643/ why such possibly minor thing might be an issue. There was very long thread about it in the LKML back in the day. Though it's not exactly the case here, Pavel, please use the real name in your patches and especially in the SoB lines.
Quoted 2 lines
Regards,
Luka
Best regards,
Marek Vasut
PATCH 2/2 New command bootmenu: ANSI terminal Boot Menu support
Hi Marek,
Quoted 10 lines · Marek Vasut
Quoted 7 lines
Quoted 3 lines
Try keeping the subject line short and add a patch description instead. Btw. Try avoiding unicode characters in the patch. Also, is "Pali" your real name that you have on your IDs etc. ?
What kind of question is that :) ?
Like you can do anything if it's real or not...
I can vote for the patch to not be merged obviously if it's of suspicious origin.
Ah yes, I forgot that one.
Quoted 2 lines
But before you loose your temper completely and flame me to death, read on ...
I'm not loosing my temper nor going to flame you ;) I was just supprised with the question. And now I know why you have asked it.
Quoted 4 lines
Basically, I don't want to be the bitch that wards people off here, but we better obey some kind of rules. See http://lwn.net/Articles/195643/ why such possibly minor thing might be an issue. There was very long thread about it in the LKML back in the day.
It was a good read. Thanks for pointing out that one.
Regards,
Luka
v2 cover ANSI terminal Bootmenu
In reply to Pali RohárThis patch series adds ANSI terminal Bootmenu command. It use generic menu code for creating menu structures, but use own functions for drawing menu on ANSI terminal. First patch modify generic menu code for using other functions for printing and choosing menu entry, second patch is bootmenu command itself. Third and fourth patches are new in v2. Third adding new command clear which clear ANSI terminal and fourth adding bootmenu support to Nokia RX-51 board.
Pali Roh?r (4):
menu: Added support to use user defined functions New command bootmenu: ANSI terminal Boot Menu support New command clear: Clear the ANSI terminal
RX-51: Add support for bootmenu
board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 +- common/Makefile | 2 + common/cmd_bootmenu.c | 471 +++++++++++++++++++++++++++++++++++ common/cmd_clear.c | 43 ++++ common/cmd_pxe.c | 3 +- common/menu.c | 43 ++-- doc/README.bootmenu | 61 +++++ include/ansi.h | 42 ++++ include/configs/nokia_rx51.h | 25 +- include/menu.h | 6 +- 10 files changed, 678 insertions(+), 23 deletions(-) create mode 100644 common/cmd_bootmenu.c create mode 100644 common/cmd_clear.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
Signature · 1 line
1.7.10.4
PATCH v2 1/4 menu: Added support to use user defined functions
* In menu_interactive_choice can be used user specified function item_data_choice (instead hardcoded function which read input from standard input)
* Added option to specify user data for menu
* menu_display_statusline will pass pointer to user data (instead pointer to menu)
* This patch is needed for creating ANSI bootmenu
---
Changes in v2:
- Rebased on next
board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 ++-- common/cmd_pxe.c | 3 ++- common/menu.c | 43 +++++++++++++++++++++++------------ include/menu.h | 6 +++-- 4 files changed, 37 insertions(+), 20 deletions(-)
board/ait/cam_enc_4xx/cam_enc_4xx.c +3 -2
@@ -561,7 +561,8 @@ static char *menu_handle(struct menu_display *display)char *s;char temp[6 ][200 ]; - m =menu_create (display->title, display->timeout,1 , ait_menu_print); + m =menu_create (display->title, display->timeout,1 , ait_menu_print, +NULL ,NULL );for (i =0 ; display->menulist[i]; i++) {sprintf (key,"%d" , i +1 );
@@ -1097,7 +1098,7 @@ int menu_show(int bootdelay)return MENU_EXIT ; } -void menu_display_statusline (struct menu *m) +void menu_display_statusline (void *data) {char *s1, *s2;
common/cmd_pxe.c +2 -1
@@ -1280,7 +1280,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)/* * Create a menu and add items for all the labels. */ - m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print); + m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print, +NULL ,NULL );if (!m)return NULL ;
common/menu.c +28 -15
83 lines not on this page · raw message
include/menu.h +4 -2
@@ -21,12 +21,14 @@struct menu ;struct menu *menu_create (char *title,int timeout,int prompt, -void (*item_data_print)(void *)); +void (*item_data_print)(void *), +char *(*item_data_choice)(void *), +void *menu_data);int menu_default_set (struct menu *m,char *item_key);int menu_get_choice (struct menu *m,void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);int menu_destroy (struct menu *m); -void menu_display_statusline (struct menu *m); +void menu_display_statusline (void *menu_data);#if defined(CONFIG_MENU_SHOW )int menu_show (int bootdelay);
Signature · 1 line
1.7.10.4
PATCH v2 2/4 New command bootmenu: ANSI terminal Boot Menu support
In reply to Pali RohárThis patch adding ANSI terminal bootmenu command. It is extension to generic menu which provide output for ANSI terminals.
---
Changes in v2:
- Added commit message
- Removed bootmenu from include/config_cmd_all.h
- Moved ANSI escape codes from include/common.h to include/ansi.h
- Fixed style and indentation problems
- Use mdelay instead udelay
- Removed autoboot delay message when some key is pressed
common/Makefile | 1 + common/cmd_bootmenu.c | 471 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 61 +++++++ include/ansi.h | 42 +++++ 4 files changed, 575 insertions(+) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
common/Makefile +1 -0
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_CMD_SOURCE) += cmd_source.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o +COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
common/cmd_bootmenu.c new file +471 -0
471 lines not on this page · raw message
doc/README.bootmenu new file +61 -0
61 lines not on this page · raw message
include/ansi.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 2/4 New command bootmenu: ANSI terminal Boot Menu support
Dear Pali Roh?r,
Quoted 2 lines · In message <[email protected]> you wrote:
This patch adding ANSI terminal bootmenu command. It is extension to generic menu which provide output for ANSI terminals.
...
common/cmd_bootmenu.c line 119
Quoted 7 lines
common/cmd_bootmenu.c new file +7
-0+if (key =='\e' ) { + esc =1 ; + key =0 ; + }else if (key =='\r' ) + key =3 ; +else + key =0 ;
use switch() ?
Quoted 25 lines
common/cmd_bootmenu.c new file +25
-0+if (esc ==0 ) { + +/* Start of ANSI escape sequence */ +if (key =='\e' ) { + esc =1 ; + key =0 ; + } + + }else if (esc ==1 ) { + +if (key =='[' ) { + esc =2 ; + key =0 ; + }else + esc =0 ; + + }else if (esc ==2 || esc ==3 ) { + +if (esc ==2 && key =='1' ) { + esc =3 ; + key =0 ; + }else + esc =0 ; + +/* key up was pressed */
common/cmd_bootmenu.c line 183
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+if (key =='A' ) + key =1 ; +/* key down was pressed */ +else if (key =='B' ) + key =2 ; +/* other key was pressed */ +else + key =0 ; + + }
use switch() ?
Can we please avoid using hard-coded magic constants like 'A', 'B' etc. here?
Quoted 8 lines
common/cmd_bootmenu.c new file +8
-0+/* key up */ +if (key ==1 ) { +if (menu->active >0 ) + --menu->active; +return "" ;/* invalid menu entry, regenerate menu */ +/* key down */ + }else if (key ==2 ) { +if (menu->active < menu->count-1 )
common/cmd_bootmenu.c line 208
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+ ++menu->active; +return "" ;/* invalid menu entry, regenerate menu */ +/* enter */ + }else if (key ==3 ) { +int i; +struct bootmenu_entry *iter = menu->first; +for (i =0 ; i < menu->active; ++i) + iter = iter->next; +return iter->key; + }
use switch() ?
common/cmd_bootmenu.c line 212
Quoted 1 line
common/cmd_bootmenu.c new file +1
-0+/* never happends */
Typo.
common/cmd_bootmenu.c line 240
Quoted 5 lines
common/cmd_bootmenu.c new file +5
-0+while ((option =bootmenu_getoption (i))) { + + sep =strchr (option,'=' ); +if (!sep) +break ;
Is there any specific reason for inventing yet another data format here? Can we not for example re-use what we already have in the hwconfig command, and use common code for parsing the format?
Using a '=' as separator here is not a good idea, IMO.
common/cmd_bootmenu.c line 285
Quoted 2 lines
common/cmd_bootmenu.c new file +2
-0+/* Add U-Boot console entry at the end */ +if (i <100 ) {
Magic constant 100 ?
common/cmd_bootmenu.c line 329
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+cleanup: + iter = menu->first; +while (iter) { + entry = iter->next; +free (iter->title); +free (iter->command); +free (iter); + iter = entry; + } +free (menu);
Make this a separate function?
common/cmd_bootmenu.c line 344
Quoted 12 lines
common/cmd_bootmenu.c new file +12
-0+static void bootmenu_destroy (struct bootmenu_data *menu) +{ +struct bootmenu_entry *iter = menu->first; +struct bootmenu_entry *next; +while (iter) { + next = iter->next; +free (iter->title); +free (iter->command); +free (iter); + iter = next; + } +free (menu);
and use it here again?
common/cmd_bootmenu.c line 365
Quoted 8 lines
common/cmd_bootmenu.c new file +8
-0+/* If delay is 0 do not create menu, just run first entry */ +if (delay ==0 ) { + option =bootmenu_getoption (0 ); +if (!option) +return ; + sep =strchr (option,'=' ); +if (!sep) +return ;
That would be an error condition, would it not? Should this not raise some error message, then?
common/cmd_bootmenu.c line 381
Quoted 3 lines
common/cmd_bootmenu.c new file +3
-0+for (iter = bootmenu->first; iter; iter = iter->next) +if (!menu_item_add (menu, iter->key, iter)) + goto cleanup;
Need braces for multi-line "for".
common/cmd_bootmenu.c line 446
Quoted 5 lines
common/cmd_bootmenu.c new file +5
-0+int menu_show (int bootdelay) +{ +bootmenu_show (bootdelay); +return -1 ;/* -1 - abort boot and run monitor code */ +}
If this function never returns anything else, why do we need the return value at all?
Quoted 7 lines
common/cmd_bootmenu.c new file +7
-0+int do_bootmenu (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ +char *delay_str =NULL ; +int delay =10 ; + +if (argc >=2 ) + delay_str = argv[1 ];
common/cmd_bootmenu.c line 464
Quoted 10 lines
common/cmd_bootmenu.c new file +10
-0+ +if (!delay_str) + delay_str =getenv ("bootmenu_delay" ); + +if (delay_str) + delay = (int )simple_strtol (delay_str,NULL ,10 ); + +bootmenu_show (delay); +return 0 ; +}
Umm... don't we handle any errors at all?
Quoted 1 line
+This is ANSI terminal BootMenu command. It is extension to generic menu,
Please no camel-caps.
Quoted 1 line
+First argument of bootmenu command override
bootmenu_delayenv
I cannot parse this.
Quoted 1 line
+If env
bootmenu_delayor bootmenu arg is not specified, delay is 10 seconds
Why not using CONFIG_BOOTDELAY as default instead?
doc/README.bootmenu line 41
Quoted 2 lines
doc/README.bootmenu new file +2
-0+If delay is 0, no entry will be shown on screen and first will be called +If delay is less then 0, no autoboot delay will be used
What will happen then? How is this different from delay==0 ?
Quoted 1 line
+Boot Menu will stop finding next menu entry if last was not defined
I cannot parse this.
doc/README.bootmenu line 52
Quoted 10 lines
doc/README.bootmenu new file +10
-0+Boot Menu always add menu entry "U-Boot console" at end of all entries + +Example using: + + setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Set first menu entry + setenv bootmenu_1 Boot 2. kernel=bootm 0x83000000 # Set second menu entry + setenv bootmenu_2 Reset board=reset # Set third menu entry + setenv bootmenu_3 U-Boot boot order=boot # Set fourth menu entry + setenv bootmenu_4 # Empty string is end of all bootmenu entries + bootmenu 20 # Run bootmenu with autoboot delay 20s
You might give an example here what the resulting screen will look like.
Quoted 1 line
+To enable ANSI bootmenu comamnd add these definitions to board code:
Typo.
doc/README.bootmenu line 58
Quoted 2 lines
doc/README.bootmenu new file +2
-0+ #define CONFIG_BOOTDELAY 30 + #define CONFIG_AUTOBOOT_KEYED
Do we really need CONFIG_AUTOBOOT_KEYED ?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Wenn das dann in die Hose geht, nehme ich es auf meine Kappe.
-- Rudi V?ller, 15. Nov 2003PATCH v2 2/4 New command bootmenu: ANSI terminal Boot Menu support
Hi, I will fix all mentioned style problems.
Quoted 14 lines · On Tuesday 13 November 2012 09:27:41 Wolfgang Denk wrote:
common/cmd_bootmenu.c line 183
Quoted 11 lines
common/cmd_bootmenu.c new file +11
-0+/* key up was pressed */ +if (key =='A' ) + key =1 ; +/* key down was pressed */ +else if (key =='B' ) + key =2 ; +/* other key was pressed */ +else + key =0 ; + + }use
switch()?
Quoted 3 lines
Can we please avoid using hard-coded magic constants like 'A', 'B' etc. here?
And what to use? ANSI sequence for key up is \e[1A (down is B).
Quoted 12 lines
common/cmd_bootmenu.c line 240
Quoted 6 lines
common/cmd_bootmenu.c new file +5
-0+while ((option =bootmenu_getoption (i))) { + + sep =strchr (option,'=' ); +if (!sep) +break ;Is there any specific reason for inventing yet another data format here? Can we not for example re-use what we already have in the hwconfig command, and use common code for parsing the format?
Quoted 2 lines
Using a '=' as separator here is not a good idea, IMO.
So which char is better for separator? Bootmenu line has config "name=command" and I think '=' is the best char for separating key and value pair.
Quoted 5 lines
common/cmd_bootmenu.c line 285
Quoted 2 lines
common/cmd_bootmenu.c new file +2
-0+/* Add U-Boot console entry at the end */ +if (i <100 ) {Magic constant 100 ?
<i>-th menu entry is stored in env bootmenu_<i> (you can look to README for API). So I need to create string "bootmenu_<i>" and call getenv. I think it is very bad idea to use malloc for very allocating string of size: strlen("bootmenu_") + log10(i) + 2. I'm using array of size strlen("bootmenu_") + 3 allocated at stack which is enught for number less then 100. And I think 100 menu entries in uboot is really a lot of. If you do not think I can increase number to 1000 or 10000 (which increase size of string +2)...
Quoted 4 lines
Quoted 4 lines
common/cmd_bootmenu.c new file +4
-0+cleanup: + iter = menu->first; +while (iter) { + entry = iter->next;
Quoted 9 lines
common/cmd_bootmenu.c line 329
Quoted 6 lines
common/cmd_bootmenu.c new file +6
-0+free (iter->title); +free (iter->command); +free (iter); + iter = entry; + } +free (menu);Make this a separate function?
Same as function bootmenu_destroy, so I changed code to call bootmenu_destroy.
Quoted 14 lines
common/cmd_bootmenu.c line 365
Quoted 10 lines
(quoted diff) +1
-0+ /* If delay is 0 do not create menu, just run first entry*/
common/cmd_bootmenu.c new file +7
-0+if (delay ==0 ) { + option =bootmenu_getoption (0 ); +if (!option) +return ; + sep =strchr (option,'=' ); +if (!sep) +return ;That would be an error condition, would it not? Should this not raise some error message, then?
Ok, I added error message.
Quoted 9 lines
common/cmd_bootmenu.c line 446
Quoted 5 lines
common/cmd_bootmenu.c new file +5
-0+int menu_show (int bootdelay) +{ +bootmenu_show (bootdelay); +return -1 ;/* -1 - abort boot and run monitor code */ +}If this function never returns anything else, why do we need the return value at all?
You can see that this function is not static. Reason is that menu_show is uboot API function which must return int. -1 means abort booting and run monitor code.
Quoted 11 lines
Quoted 11 lines
+int
do_bootmenu(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])+{common/cmd_bootmenu.c new file +9
-0+char *delay_str =NULL ; +int delay =10 ; + +if (argc >=2 ) + delay_str = argv[1 ]; + +if (!delay_str) + delay_str =getenv ("bootmenu_delay" ); +
Quoted 9 lines
common/cmd_bootmenu.c line 464
Quoted 6 lines
common/cmd_bootmenu.c new file +6
-0+if (delay_str) + delay = (int )simple_strtol (delay_str,NULL ,10 ); + +bootmenu_show (delay); +return 0 ; +}Umm... don't we handle any errors at all?
I do not understand what you mean.
Quoted 4 lines
Quoted 2 lines
+First argument of bootmenu command override
bootmenu_delayenvI cannot parse this.
First argument of bootmenu command is delay and override env bootmenu_delay.
Quoted 4 lines
Quoted 2 lines
+If env
bootmenu_delayor bootmenu arg is not specified, delay is 10 secondsWhy not using
CONFIG_BOOTDELAYas default instead?
Ok.
Quoted 5 lines
Quoted 3 lines
+If delay is 0, no entry will be shown on screen and first will be called +If delay is less then 0, no autoboot delay will be used
What will happen then? How is this different from delay==0 ?
If delay is less then 0, bootmenu will be shown and autoboot will be disabled. So there will not be any timer which automatically boot first entry in time $delay.
Quoted 6 lines
Quoted 6 lines
+Boot Menu always add menu entry "U-Boot console" at end of all entries +
doc/README.bootmenu new file +3
-0+Example using: + + setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Setfirst menu entry + setenv
bootmenu_1Boot 2. kernel=bootm
Quoted 9 lines
Quoted 6 lines
0x83000000# Set second menu entry + setenvbootmenu_2
Reset board=reset # Set third menu entry +
setenvbootmenu_3U-Boot boot order=boot # Set
fourth menu entry + setenvbootmenu_4# Empty string is
end of all bootmenu entries + bootmenu 20 # Run
bootmenu with autoboot delay 20sYou might give an example here what the resulting screen will look like.
Ok, I can here text output. If you want to see screenshot from bootmenu rendered to framebuffer (in qemu) here is:
http://atrey.karlin.mff.cuni.cz/~pali/u-boot-bootmenu.png
Quoted 6 lines
doc/README.bootmenu line 58
Quoted 3 lines
doc/README.bootmenu new file +2
-0+ #define CONFIG_BOOTDELAY 30 + #define CONFIG_AUTOBOOT_KEYEDDo we really need
CONFIG_AUTOBOOT_KEYED?
Yes, because menu_show() call in common/main.c is called only of CONFIG_AUTOBOOT_KEYED is defined. You can look at this condition.
Signature · 9 lines
Pali Roh?r pali.rohar at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.denx.de/pipermail/u-boot/attachments/20121114/43f0332a/attachment.pgp>
PATCH v2 3/4 New command clear: Clear the ANSI terminal
In reply to Pali RohárThis patch adding new simple command clear which clear ANSI terminal.
---
This patch was in Nokia RX-51 patch series (v2).
Changes since RX-51 patch v2:
- Removed from include/config_cmd_all.h
- Removed ANSI escape codes (now in BootMenu command patch)
Changes since original version:
- Renamed command clr to clear
- Use puts instead printf
- Move cursor to pos1,1
common/Makefile | 1 + common/cmd_clear.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 common/cmd_clear.c
common/Makefile +1 -0
@@ -70,6 +70,7 @@ COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o +COBJS-$(CONFIG_CMD_CLEAR) += cmd_clear.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
common/cmd_clear.c new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 3/4 New command clear: Clear the ANSI terminal
Dear Pali Roh?r,
Quoted 1 line · In message <[email protected]> you wrote:
This patch adding new simple command clear which clear ANSI terminal.
Please note that this duplicates or affects existing functionality; for example, common/lcd.c implements the "cls" = Clear Screen command.
If we add such more globnal support now, this should be unified (in a backward compatible) way with the existing code.
Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Real Programmers always confuse Christmas and Halloween because OCT 31 == DEC 25 ! - Andrew Rutherford (andrewr at ucs.adelaide.edu.au)
PATCH v2 4/4 RX-51: Add support for bootmenu
In reply to Pali Rohár * default bootmenu entries:
attached kernel, internal eMMC memory, external SD card, u-boot boot order
* in CONFIG_PREBOOT try load bootmenu.scr from first FAT partition of internal eMMC memory (also known as MyDocs) which (should) overwrite default bootmenu entries
* when keyboard slide is closed boot first menu entry
* when keyborad slide is open in show bootmenu
---
This patch was in Nokia RX-51 patch series.
Changes since RX-51 patch:
- Rebased on last Nokia RX-51 patch v5
Changes since original version:
- Fixed name of env variables
include/configs/nokia_rx51.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
include/configs/nokia_rx51.h +22 -3
@@ -148,6 +148,7 @@#define CONFIG_CMDLINE_EDITING /* add command line history */ #define CONFIG_AUTO_COMPLETE /* add autocompletion support */ +#define CONFIG_CMD_BOOTMENU /* ANSI terminal Boot Menu */ #define CONFIG_CMD_CLEAR /* ANSI terminal clear screen command */ #ifdef ONENAND_SUPPORT
@@ -287,8 +288,6 @@ int rx51_kp_getc(void);#endif /* Environment information */ -#define CONFIG_BOOTDELAY 3 -#define CONFIG_EXTRA_ENV_SETTINGS \ "mtdparts=" MTDPARTS_DEFAULT "\0" \ "usbtty=cdc_acm\0" \
@@ -360,10 +359,25 @@ int rx51_kp_getc(void);"fi\0" \"emmcboot=setenv mmcnum 1; run trymmcboot\0" \"sdboot=setenv mmcnum 0; run trymmcboot\0" \ +"menucmd=bootmenu\0" \ +"bootmenu_0=Attached kernel=run attachboot\0" \ +"bootmenu_1=Internal eMMC=run emmcboot\0" \ +"bootmenu_2=External SD card=run sdboot\0" \ +"bootmenu_3=U-Boot boot order=boot\0" \ +"bootmenu_delay=30\0" \ ""#define CONFIG_PREBOOT \ -"if run slide; then true; else run attachboot; fi;" \ + "setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat;" \ + "setenv mmcscriptfile bootmenu.scr;" \ + "run trymmcscriptboot;" \ + "if run slide; then true; else " \ + "setenv bootmenu_delay 0;" \ + "setenv bootdelay 0;" \ + "fi" + +#define CONFIG_POSTBOOTMENU \ + "echo;" \ "echo Extra commands:;" \ "echo run sercon - Use serial port for control.;" \ "echo run usbcon - Use usbtty for control.;" \
@@ -379,6 +393,11 @@ int rx51_kp_getc(void);"run attachboot;" \ "echo" +#define CONFIG_BOOTDELAY 30 +#define CONFIG_AUTOBOOT_KEYED +#define CONFIG_MENU +#define CONFIG_MENU_SHOW +/* * Miscellaneous configurable options */
Signature · 1 line
1.7.10.4
v3 cover ANSI terminal Bootmenu
In reply to Pali RohárThis patch series adds ANSI terminal Bootmenu command. It use generic menu code for creating menu structures, but use own functions for drawing menu on ANSI terminal. First patch modify generic menu code for using other functions for printing and choosing menu entry, second patch is bootmenu command itself. Third and fourth patches were new in v2. Third adding new command clear which clear ANSI terminal and fourth adding bootmenu support to Nokia RX-51 board.
Pali Roh?r (4):
menu: Added support to use user defined functions New command bootmenu: ANSI terminal Boot Menu support New command clear: Clear the ANSI terminal
RX-51: Add support for bootmenu
board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 +- common/Makefile | 2 + common/cmd_bootmenu.c | 515 +++++++++++++++++++++++++++++++++++ common/cmd_clear.c | 43 +++ common/cmd_pxe.c | 3 +- common/menu.c | 43 ++- doc/README.bootmenu | 86 ++++++ include/ansi.h | 42 +++ include/configs/nokia_rx51.h | 25 +- include/menu.h | 6 +- 10 files changed, 747 insertions(+), 23 deletions(-) create mode 100644 common/cmd_bootmenu.c create mode 100644 common/cmd_clear.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
Signature · 1 line
1.7.10.4
PATCH v3 1/4 menu: Added support to use user defined functions
* In menu_interactive_choice can be used user specified function item_data_choice (instead hardcoded function which read input from standard input)
* Added option to specify user data for menu
* menu_display_statusline will pass pointer to user data (instead pointer to menu)
* This patch is needed for creating ANSI bootmenu
---
No changes in v3
Changes in v2:
- Rebased on next
board/ait/cam_enc_4xx/cam_enc_4xx.c | 5 ++-- common/cmd_pxe.c | 3 ++- common/menu.c | 43 +++++++++++++++++++++++------------ include/menu.h | 6 +++-- 4 files changed, 37 insertions(+), 20 deletions(-)
board/ait/cam_enc_4xx/cam_enc_4xx.c +3 -2
@@ -561,7 +561,8 @@ static char *menu_handle(struct menu_display *display)char *s;char temp[6 ][200 ]; - m =menu_create (display->title, display->timeout,1 , ait_menu_print); + m =menu_create (display->title, display->timeout,1 , ait_menu_print, +NULL ,NULL );for (i =0 ; display->menulist[i]; i++) {sprintf (key,"%d" , i +1 );
@@ -1097,7 +1098,7 @@ int menu_show(int bootdelay)return MENU_EXIT ; } -void menu_display_statusline (struct menu *m) +void menu_display_statusline (void *data) {char *s1, *s2;
common/cmd_pxe.c +2 -1
@@ -1280,7 +1280,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)/* * Create a menu and add items for all the labels. */ - m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print); + m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print, +NULL ,NULL );if (!m)return NULL ;
common/menu.c +28 -15
83 lines not on this page · raw message
include/menu.h +4 -2
@@ -21,12 +21,14 @@struct menu ;struct menu *menu_create (char *title,int timeout,int prompt, -void (*item_data_print)(void *)); +void (*item_data_print)(void *), +char *(*item_data_choice)(void *), +void *menu_data);int menu_default_set (struct menu *m,char *item_key);int menu_get_choice (struct menu *m,void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);int menu_destroy (struct menu *m); -void menu_display_statusline (struct menu *m); +void menu_display_statusline (void *menu_data);#if defined(CONFIG_MENU_SHOW )int menu_show (int bootdelay);
Signature · 1 line
1.7.10.4
PATCH v4 1/4 menu: Add support for user defined item choice function
From: Pali Roh?r <[email protected]>
Selecting menu items is currently done in menu_interactive_choice() by reading the user input strings from standard input.
Extend menu_interactive_choice() to support user defined function for selecting menu items. This function and its argument can be specified when creating the menu.
---
Changes in v4:
- slightly rename the new item choice callback and its argument
- add documentation for added item choice callback
- search for menu item key only if the choice callback returned a key (not NULL)
- do not change menu_display_statusline() function argument (previous patch changed this menu API function but didn't update documentation for this change. This change is actually not needed, menu item data can be obtained by exported menu_default_choice())
- revise commit log
No changes in v3
Changes in v2:
- Rebased on next
board/ait/cam_enc_4xx/cam_enc_4xx.c | 3 +- common/cmd_pxe.c | 3 +- common/menu.c | 42 +++++++++++++++++++++++++--------- doc/README.menu | 4 ++- include/menu.h | 4 ++- 5 files changed, 41 insertions(+), 15 deletions(-)
board/ait/cam_enc_4xx/cam_enc_4xx.c +2 -1
@@ -561,7 +561,8 @@ static char *menu_handle(struct menu_display *display)char *s;char temp[6 ][200 ]; - m =menu_create (display->title, display->timeout,1 , ait_menu_print); + m =menu_create (display->title, display->timeout,1 , ait_menu_print, +NULL ,NULL );for (i =0 ; display->menulist[i]; i++) {sprintf (key,"%d" , i +1 );
common/cmd_pxe.c +2 -1
@@ -1280,7 +1280,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)/* * Create a menu and add items for all the labels. */ - m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print); + m =menu_create (cfg->title, cfg->timeout, cfg->prompt, label_print, +NULL ,NULL );if (!m)return NULL ;
common/menu.c +31 -11
72 lines not on this page · raw message
doc/README.menu +3 -1
@@ -51,7 +51,9 @@ struct menu; * menu_create() - Creates a menu handle with default settings */ struct menu *menu_create(char *title, int timeout, int prompt, - void (*item_data_print)(void *)); + void (*item_data_print)(void *), + char *(*item_choice)(void *), + void *item_choice_data); /* * menu_item_add() - Adds or replaces a menu item
include/menu.h +3 -1
@@ -21,7 +21,9 @@struct menu ;struct menu *menu_create (char *title,int timeout,int prompt, -void (*item_data_print)(void *)); +void (*item_data_print)(void *), +char *(*item_choice)(void *), +void *item_choice_data);int menu_default_set (struct menu *m,char *item_key);int menu_get_choice (struct menu *m,void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);
Signature · 1 line
1.7.5.4
PATCH 1/1 menu: export menu_default_choice() function
Checking the default menu item and obtaining its data can be useful in custom menu code. Export menu_default_choice() function which serves this purpose.
--- common/menu.c | 2 +- doc/README.menu | 5 +++++ include/menu.h | 1 + 3 files changed, 7 insertions(+), 1 deletions(-)
common/menu.c +1 -1
@@ -176,7 +176,7 @@ static inline struct menu_item *menu_item_by_key(struct menu *m,* Set *choice to point to the default item's data, if any default item was * set, and returns 1. If no default item was set, returns -ENOENT. */ -static inline int menu_default_choice (struct menu *m,void **choice) +int menu_default_choice (struct menu *m,void **choice) {if (m->default_item) { *choice = m->default_item->data;
doc/README.menu +5 -0
@@ -66,6 +66,11 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data); int menu_default_set(struct menu *m, char *item_key); /* + * menu_default_choice() - Set *choice to point to the default item's data + */ +int menu_default_choice(struct menu *m, void **choice); + +/* * menu_get_choice() - Returns the user's selected menu entry, or the * default if the menu is set to not prompt or the timeout expires. */
include/menu.h +1 -0
@@ -29,6 +29,7 @@ int menu_get_choice(struct menu *m, void **choice);int menu_item_add (struct menu *m,char *item_key,void *item_data);int menu_destroy (struct menu *m);void menu_display_statusline (struct menu *m); +int menu_default_choice (struct menu *m,void **choice);#if defined(CONFIG_MENU_SHOW )int menu_show (int bootdelay);
Signature · 1 line
1.7.5.4
Anatolij Gustschin
AppliedPATCH 1/1 menu: export menu_default_choice() function
Quoted 10 lines · On Sun, 24 Mar 2013 01:52:04 +0100 Anatolij Gustschin <[email protected]> wrote:
Checking the default menu item and obtaining its data can be useful in custom menu code. Export
menu_default_choice()function which serves this purpose.Signed-off-by Anatolij Gustschin <[email protected]>--- common/menu.c | 2 +- doc/README.menu | 5 +++++ include/menu.h | 1 + 3 files changed, 7 insertions(+), 1 deletions(-)
applied to staging/agust at denx.de. Thanks.
Anatolij
Anatolij Gustschin
AppliedPATCH v4 1/4 menu: Add support for user defined item choice function
In reply to Anatolij GustschinQuoted 29 lines · On Sun, 24 Mar 2013 01:50:40 +0100 Anatolij Gustschin <[email protected]> wrote:
From: Pali Roh?r <[email protected]>
Selecting menu items is currently done in
menu_interactive_choice()by reading the user input strings from standard input.Extend
menu_interactive_choice()to support user defined function for selecting menu items. This function and its argument can be specified when creating the menu.Signed-off-by Pali Roh?r <[email protected]>Signed-off-by Anatolij Gustschin <[email protected]>---
Changes in v4:
- slightly rename the new item choice callback and its argument
- add documentation for added item choice callback
- search for menu item key only if the choice callback returned a key (not NULL)
- do not changemenu_display_statusline()function argument (previous patch changed this menu API function but didn't update documentation for this change. This change is actually not needed, menu item data can be obtained by exportedmenu_default_choice())
- revise commit logNo changes in v3
Changes in v2:
- Rebased on next
Quoted 6 lines
board/ait/cam_enc_4xx/cam_enc_4xx.c | 3 +- common/cmd_pxe.c | 3 +- common/menu.c | 42 +++++++++++++++++++++++++--------- doc/README.menu | 4 ++- include/menu.h | 4 ++- 5 files changed, 41 insertions(+), 15 deletions(-)
applied to staging/agust at denx.de. Thanks.
Anatolij
PATCH v3 2/4 New command bootmenu: ANSI terminal Boot Menu support
In reply to Pali RohárThis patch adding ANSI terminal bootmenu command. It is extension to generic menu which provide output for ANSI terminals.
---
Changes in v3:
- Do not use hardcoded numbers, added MAX_COUNT and MAX_ENV_SIZE
- Use unsigned short int for menu number
- Use enum bootmenu_key for key selection
- Separate loop code from function bootmenu_choice_entry to bootmenu_loop and bootmenu_autoboot_loop
- Updated README, added example
- Use switches, added braces, fix style problems
Changes in v2:
- Added commit message
- Removed bootmenu from include/config_cmd_all.h
- Moved ANSI escape codes from include/common.h to include/ansi.h
- Fixed style and indentation problems
- Use mdelay instead udelay
- Removed autoboot delay message when some key is pressed
common/Makefile | 1 + common/cmd_bootmenu.c | 515 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 86 +++++++++ include/ansi.h | 42 ++++ 4 files changed, 644 insertions(+) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
common/Makefile +1 -0
@@ -71,6 +71,7 @@ COBJS-$(CONFIG_CMD_SOURCE) += cmd_source.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o +COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
common/cmd_bootmenu.c new file +515 -0
515 lines not on this page · raw message
doc/README.bootmenu new file +86 -0
86 lines not on this page · raw message
include/ansi.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
From: Pali Roh?r <[email protected]>
The "bootmenu" command uses U-Boot menu interfaces and provides a simple mechanism for creating menus with several boot items. When running this command the menu will be assembled as defined by a set of environment variables which contain a title and command key-value pairs. The "Up" and "Down" keys are used for navigation through the items. Current active menu item is highlighted and can be selected using the "Enter" key.
The command interprets and generates various ANSI escape sequencies, so for proper menu rendering and item selection the used terminal should support them.
---
Changes in v4:
- coding style fixes
- highlight only the menu entry title, not the whole line
- don't return empty strings in bootmenu_choice_entry() to avoid useless searching for menu keys in the menu item list. Empty key strings won't be found anyway, so for down and up keys just return NULL in this function to indicate that no item selection happened yet
- print error message if invalid bootmenu environment variable without title/command separator found
- if number of menu items is equal to MAX_COUNT, the U-Boot console selection entry won't be generated. Fix it so that documented and real behaviour match
- include entry key initialisation fix for proper menu behaviour when running in sandbox (without it the item selection by up/down keys didn't work in sandbox)
- use puts() instead of printf() where appropriate
- always use 1 for prompt argument for menu_create() so that the bootmenu command works as documented when using a negative delay value
- call bootmenu_destroy() in the case if menu_create() fails (avoid memory leaks)
- don't display the title of selected item before running the commands (but do it only if debugging is enabled)
- don't change the argument of menu_display_statusline(), use exported menu_default_choice() instead and obtain the needed bootmenu data pointer in the custom menu_display_statusline() function
- use lower case in menu header
- update documentation in readme file for the command
Changes in v3:
- Do not use hardcoded numbers, added MAX_COUNT and MAX_ENV_SIZE
- Use unsigned short int for menu number
- Use enum bootmenu_key for key selection
- Separate loop code from function bootmenu_choice_entry to bootmenu_loop and bootmenu_autoboot_loop
- Updated README, added example
- Use switches, added braces, fix style problems
Changes in v2:
- Added commit message
- Removed bootmenu from include/config_cmd_all.h
- Moved ANSI escape codes from include/common.h to include/ansi.h
- Fixed style and indentation problems
- Use mdelay instead udelay
- Removed autoboot delay message when some key is pressed
common/Makefile | 1 + common/cmd_bootmenu.c | 517 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 115 +++++++++++ include/ansi.h | 42 ++++ 4 files changed, 675 insertions(+), 0 deletions(-) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
common/Makefile +1 -0
@@ -75,6 +75,7 @@ COBJS-$(CONFIG_CMD_SOURCE) += cmd_source.o COBJS-$(CONFIG_CMD_BDI) += cmd_bdinfo.o COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o +COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
common/cmd_bootmenu.c new file +517 -0
517 lines not on this page · raw message
doc/README.bootmenu new file +115 -0
115 lines not on this page · raw message
include/ansi.h new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Hi,
Quoted 4 lines · On Sun, 24 Mar 2013 01:53:08 +0100 Anatolij Gustschin <[email protected]> wrote:
From: Pali Roh?r <[email protected]>
The "bootmenu" command uses U-Boot menu interfaces and provides a simple mechanism for creating menus with several boot items.
Could you please test v4 patches. I've tested them in sandbox and on a frame buffer device (cfb_console) and didn't see any issues. I'm going to apply these patches in a few days.
Thanks,
Anatolij
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Quoted 11 lines · On Monday 25 March 2013 20:29:23 Anatolij Gustschin wrote:
Hi,
On Sun, 24 Mar 2013 01:53:08 +0100
Quoted 5 lines · Anatolij Gustschin
From: Pali Roh?r <[email protected]>
The "bootmenu" command uses U-Boot menu interfaces and provides a simple mechanism for creating menus with several boot items.
Quoted 7 lines
Could you please test v4 patches. I've tested them in sandbox and on a frame buffer device (
cfb_console) and didn't see any issues. I'm going to apply these patches in a few days.Thanks,
Anatolij
Hi,
I tested them on Nokia N900 and in qemu (hw n900). Working fine.
Signature · 9 lines
Pali Roh?r pali.rohar at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130326/be319d2c/attachment.pgp>
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Hi,
On Tue, 26 Mar 2013 16:19:35 +0100
Pali Roh?r <[email protected]> wrote:
...
Quoted 1 line
I tested them on Nokia N900 and in qemu (hw n900). Working fine.
Thanks for testing!
Anatolij
Anatolij Gustschin
AppliedPATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
In reply to Anatolij GustschinQuoted 67 lines · On Sun, 24 Mar 2013 01:53:08 +0100 Anatolij Gustschin <[email protected]> wrote:
From: Pali Roh?r <[email protected]>
The "bootmenu" command uses U-Boot menu interfaces and provides a simple mechanism for creating menus with several boot items. When running this command the menu will be assembled as defined by a set of environment variables which contain a title and command key-value pairs. The "Up" and "Down" keys are used for navigation through the items. Current active menu item is highlighted and can be selected using the "Enter" key.
The command interprets and generates various ANSI escape sequencies, so for proper menu rendering and item selection the used terminal should support them.
Signed-off-by Pali Roh?r <[email protected]>[agust: various fixes and documentation updates]Signed-off-by Anatolij Gustschin <[email protected]>---
Changes in v4:
- coding style fixes
- highlight only the menu entry title, not the whole line
- don't return empty strings inbootmenu_choice_entry()to avoid useless searching for menu keys in the menu item list. Empty key strings won't be found anyway, so for down and up keys just return NULL in this function to indicate that no item selection happened yet
- print error message if invalid bootmenu environment variable without title/command separator found
- if number of menu items is equal toMAX_COUNT, the U-Boot console selection entry won't be generated. Fix it so that documented and real behaviour match
- include entry key initialisation fix for proper menu behaviour when running in sandbox (without it the item selection by up/down keys didn't work in sandbox)
- useputs()instead ofprintf()where appropriate
- always use 1 for prompt argument formenu_create()so that the bootmenu command works as documented when using a negative delay value
- callbootmenu_destroy()in the case ifmenu_create()fails (avoid memory leaks)
- don't display the title of selected item before running the commands (but do it only if debugging is enabled)
- don't change the argument ofmenu_display_statusline(), use exportedmenu_default_choice()instead and obtain the needed bootmenu data pointer in the custommenu_display_statusline()function
- use lower case in menu header
- update documentation in readme file for the commandChanges in v3:
- Do not use hardcoded numbers, addedMAX_COUNTandMAX_ENV_SIZE
- Use unsigned short int for menu number
- Use enumbootmenu_keyfor key selection
- Separate loop code from functionbootmenu_choice_entrytobootmenu_loopandbootmenu_autoboot_loop
- Updated README, added example
- Use switches, added braces, fix style problemsChanges in v2:
- Added commit message
- Removed bootmenu frominclude/config_cmd_all.h
- Moved ANSI escape codes frominclude/common.htoinclude/ansi.h
- Fixed style and indentation problems
- Use mdelay instead udelay
- Removed autoboot delay message when some key is pressed
Quoted 8 lines
common/Makefile | 1 + common/cmd_bootmenu.c | 517 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.bootmenu | 115 +++++++++++ include/ansi.h | 42 ++++ 4 files changed, 675 insertions(+), 0 deletions(-) create mode 100644 common/cmd_bootmenu.c create mode 100644 doc/README.bootmenu create mode 100644 include/ansi.h
applied to staging/agust at denx.de. Thanks.
Anatolij
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Quoted 18 lines · On Thursday 28 March 2013 16:32:47 Anatolij Gustschin wrote:
On Sun, 24 Mar 2013 01:53:08 +0100
Quoted 15 lines · Anatolij Gustschin
From: Pali Roh?r <[email protected]>
The "bootmenu" command uses U-Boot menu interfaces and provides a simple mechanism for creating menus with several boot items. When running this command the menu will be assembled as defined by a set of environment variables which contain a title and command key-value pairs. The "Up" and "Down" keys are used for navigation through the items. Current active menu item is highlighted and can be selected using the "Enter" key.
The command interprets and generates various ANSI escape sequencies, so for proper menu rendering and item selection the used terminal should support them.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Pali Roh?r <[email protected]>[agust: various fixes and documentation updates]Signed-off-by Anatolij Gustschin <[email protected]>applied to staging/agust at denx.de. Thanks.
Anatolij
Hi, can you include also two next patches from this series?
http://patchwork.ozlabs.org/patch/217492/
http://patchwork.ozlabs.org/patch/225868/
Signature · 9 lines
Pali Roh?r pali.rohar at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130328/c73ef5af/attachment.pgp>
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Hi,
On Thu, 28 Mar 2013 20:18:48 +0100
Pali Roh?r <[email protected]> wrote:
...
Quoted 5 lines
Hi, can you include also two next patches from this series?
http://patchwork.ozlabs.org/patch/217492/
http://patchwork.ozlabs.org/patch/225868/
These patches are in my queue, I didn't forgot about them :-)
Regarding the "clear" command Wolfgang had some reservations since we already have "cls" command for LCDs. Wolfgang suggested to unify with the existing command in a backward compatible way. I'm going to submit a patch which tries to do this.
The v3 4/4 patch can be applied as is, I think.
Thanks,
Anatolij
PATCH v4 2/4 New command bootmenu: ANSI terminal boot menu support
Quoted 19 lines · On Friday 29 March 2013 00:13:30 Anatolij Gustschin wrote:
Hi,
On Thu, 28 Mar 2013 20:18:48 +0100
Pali Roh?r <[email protected]> wrote:
...Quoted 4 lines
Hi, can you include also two next patches from this series?
http://patchwork.ozlabs.org/patch/217492/
http://patchwork.ozlabs.org/patch/225868/These patches are in my queue, I didn't forgot about them :-)
Regarding the "clear" command Wolfgang had some reservations since we already have "cls" command for LCDs. Wolfgang suggested to unify with the existing command in a backward compatible way. I'm going to submit a patch which tries to do this.
Quoted 5 lines
The v3 4/4 patch can be applied as is, I think.
Thanks,
Anatolij
Ok, thanks!
Signature · 9 lines
Pali Roh?r pali.rohar at gmail.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130329/77d62547/attachment.pgp>
PATCH v3 3/4 New command clear: Clear the ANSI terminal
In reply to Pali RohárThis patch adding new simple command clear which clear ANSI terminal.
---
No changes in v3
This patch was in Nokia RX-51 patch series (v2).
Changes since RX-51 patch v2:
- Removed from include/config_cmd_all.h
- Removed ANSI escape codes (now in BootMenu command patch)
Changes since original version:
- Renamed command clr to clear
- Use puts instead printf
- Move cursor to pos1,1
common/Makefile | 1 + common/cmd_clear.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 common/cmd_clear.c
common/Makefile +1 -0
@@ -76,6 +76,7 @@ COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o COBJS-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o COBJS-$(CONFIG_CMD_CBFS) += cmd_cbfs.o +COBJS-$(CONFIG_CMD_CLEAR) += cmd_clear.o COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
common/cmd_clear.c new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 4/4 RX-51: Add support for bootmenu
In reply to Pali Rohár * default bootmenu entries:
attached kernel, internal eMMC memory, external SD card, u-boot boot order
* in CONFIG_PREBOOT try load bootmenu.scr from first FAT partition of internal eMMC memory (also known as MyDocs) which (should) overwrite default bootmenu entries
* when keyboard slide is closed boot first menu entry
* when keyborad slide is open in show bootmenu
---
No changes in v3
This patch was in Nokia RX-51 patch series.
Changes since RX-51 patch:
- Rebased on last Nokia RX-51 patch v5
Changes since original version:
- Fixed name of env variables
include/configs/nokia_rx51.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
include/configs/nokia_rx51.h +22 -3
@@ -148,6 +148,7 @@#define CONFIG_CMDLINE_EDITING /* add command line history */ #define CONFIG_AUTO_COMPLETE /* add autocompletion support */ +#define CONFIG_CMD_BOOTMENU /* ANSI terminal Boot Menu */ #define CONFIG_CMD_CLEAR /* ANSI terminal clear screen command */ #ifdef ONENAND_SUPPORT
@@ -287,8 +288,6 @@ int rx51_kp_getc(void);#endif /* Environment information */ -#define CONFIG_BOOTDELAY 3 -#define CONFIG_EXTRA_ENV_SETTINGS \ "mtdparts=" MTDPARTS_DEFAULT "\0" \ "usbtty=cdc_acm\0" \
@@ -360,10 +359,25 @@ int rx51_kp_getc(void);"fi\0" \"emmcboot=setenv mmcnum 1; run trymmcboot\0" \"sdboot=setenv mmcnum 0; run trymmcboot\0" \ +"menucmd=bootmenu\0" \ +"bootmenu_0=Attached kernel=run attachboot\0" \ +"bootmenu_1=Internal eMMC=run emmcboot\0" \ +"bootmenu_2=External SD card=run sdboot\0" \ +"bootmenu_3=U-Boot boot order=boot\0" \ +"bootmenu_delay=30\0" \ ""#define CONFIG_PREBOOT \ -"if run slide; then true; else run attachboot; fi;" \ + "setenv mmcnum 1; setenv mmcpart 1; setenv mmctype fat;" \ + "setenv mmcscriptfile bootmenu.scr;" \ + "run trymmcscriptboot;" \ + "if run slide; then true; else " \ + "setenv bootmenu_delay 0;" \ + "setenv bootdelay 0;" \ + "fi" + +#define CONFIG_POSTBOOTMENU \ + "echo;" \ "echo Extra commands:;" \ "echo run sercon - Use serial port for control.;" \ "echo run usbcon - Use usbtty for control.;" \
@@ -379,6 +393,11 @@ int rx51_kp_getc(void);"run attachboot;" \ "echo" +#define CONFIG_BOOTDELAY 30 +#define CONFIG_AUTOBOOT_KEYED +#define CONFIG_MENU +#define CONFIG_MENU_SHOW +/* * Miscellaneous configurable options */
Signature · 1 line
1.7.10.4
PATCH v3 4/4 RX-51: Add support for bootmenu
Hi, I'm sending new version of patch which try to use also ext filesystem (not only fat)
PATCH v3 4/4 RX-51: Add support for bootmenu
Hi,
On Thu, 7 Mar 2013 16:15:19 +0100
Pali Roh?r <[email protected]> wrote:
...
Quoted 6 lines
attached kernel, internal eMMC memory, external SD card, u-boot boot order
* in
CONFIG_PREBOOTtry load bootmenu.scr from first partition of internal eMMC memory (also known as MyDocs) which (should) overwrite default bootmenu entries
Quoted 8 lines
* when keyboard slide is closed boot first menu entry
* when keyborad slide is open show bootmenu
Signed-off-by Pali Roh?r <[email protected]>--- include/configs/nokia_rx51.h | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
with slightly revised commit log, applied to staging/agust at denx.de.
Thanks,
Anatolij