Pali Rohár | ac91b47 | 2013-03-23 14:53:08 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * (C) Copyright 2011-2012 Pali Rohár <pali.rohar@gmail.com> |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | ANSI terminal bootmenu command |
| 24 | |
| 25 | The "bootmenu" command uses U-Boot menu interfaces and provides |
| 26 | a simple mechanism for creating menus with different boot items. |
| 27 | The cursor keys "Up" and "Down" are used for navigation through |
| 28 | the items. Current active menu item is highlighted and can be |
| 29 | selected using the "Enter" key. The selection of the highlighted |
| 30 | menu entry invokes an U-Boot command (or a list of commands) |
| 31 | associated with this menu entry. |
| 32 | |
| 33 | The "bootmenu" command interprets ANSI escape sequencies, so |
| 34 | an ANSI terminal is required for proper menu rendering and item |
| 35 | selection. |
| 36 | |
| 37 | The assembling of the menu is done via a set of environment variables |
| 38 | "bootmenu_<num>" and "bootmenu_delay", i.e.: |
| 39 | |
| 40 | bootmenu_delay=<delay> |
| 41 | bootmenu_<num>="<title>=<commands>" |
| 42 | |
| 43 | <delay> is the autoboot delay in seconds, after which the first |
| 44 | menu entry will be selected automatically |
| 45 | |
| 46 | <num> is the boot menu entry number, starting from zero |
| 47 | |
| 48 | <title> is the text of the menu entry shown on the console |
| 49 | or on the boot screen |
| 50 | |
| 51 | <commands> are commands which will be executed when a menu |
| 52 | entry is selected |
| 53 | |
| 54 | (title and commands are separated by first appearance of '=' |
| 55 | character in the environment variable) |
| 56 | |
| 57 | First (optional) argument of the "bootmenu" command is a delay specifier |
| 58 | and it overrides the delay value defined by "bootmenu_delay" environment |
| 59 | variable. If the environment variable "bootmenu_delay" is not set or if |
| 60 | the argument of the "bootmenu" command is not specified, the default delay |
| 61 | will be CONFIG_BOOTDELAY. If delay is 0, no menu entries will be shown on |
| 62 | the console (or on the screen) and the command of the first menu entry will |
| 63 | be called immediately. If delay is less then 0, bootmenu will be shown and |
| 64 | autoboot will be disabled. |
| 65 | |
| 66 | Bootmenu always adds menu entry "U-Boot console" at the end of all menu |
| 67 | entries specified by environment variables. When selecting this entry |
| 68 | the bootmenu terminates and the usual U-Boot command prompt is presented |
| 69 | to the user. |
| 70 | |
| 71 | Example environment: |
| 72 | |
| 73 | setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Set first menu entry |
| 74 | setenv bootmenu_1 Boot 2. kernel=bootm 0x83000000 # Set second menu entry |
| 75 | setenv bootmenu_2 Reset board=reset # Set third menu entry |
| 76 | setenv bootmenu_3 U-Boot boot order=boot # Set fourth menu entry |
| 77 | bootmenu 20 # Run bootmenu with autoboot delay 20s |
| 78 | |
| 79 | |
| 80 | The above example will be rendered as below |
| 81 | (without decorating rectangle): |
| 82 | |
| 83 | ┌──────────────────────────────────────────┐ |
| 84 | │ │ |
| 85 | │ *** U-Boot Boot Menu *** │ |
| 86 | │ │ |
| 87 | │ Boot 1. kernel │ |
| 88 | │ Boot 2. kernel │ |
| 89 | │ Reset board │ |
| 90 | │ U-Boot boot order │ |
| 91 | │ U-Boot console │ |
| 92 | │ │ |
| 93 | │ Hit any key to stop autoboot: 20 │ |
| 94 | │ Press UP/DOWN to move, ENTER to select │ |
| 95 | │ │ |
| 96 | └──────────────────────────────────────────┘ |
| 97 | |
| 98 | Selected menu entry will be highlighted - it will have inverted |
| 99 | background and text colors. |
| 100 | |
| 101 | To enable the "bootmenu" command add following definitions to the |
| 102 | board config file: |
| 103 | |
| 104 | #define CONFIG_CMD_BOOTMENU |
| 105 | #define CONFIG_MENU |
| 106 | |
| 107 | To run the bootmenu at startup add these additional definitions: |
| 108 | |
| 109 | #define CONFIG_AUTOBOOT_KEYED |
| 110 | #define CONFIG_BOOTDELAY 30 |
| 111 | #define CONFIG_MENU_SHOW |
| 112 | |
| 113 | When you intend to use the bootmenu on color frame buffer console, |
| 114 | make sure to additionally define CONFIG_CFB_CONSOLE_ANSI in the |
| 115 | board config file. |