Pali Rohár | e7abe91 | 2013-03-23 14:53:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2011-2012 Pali Rohár <pali.rohar@gmail.com> |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Pali Rohár | e7abe91 | 2013-03-23 14:53:08 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | ANSI terminal bootmenu command |
| 8 | |
| 9 | The "bootmenu" command uses U-Boot menu interfaces and provides |
| 10 | a simple mechanism for creating menus with different boot items. |
| 11 | The cursor keys "Up" and "Down" are used for navigation through |
| 12 | the items. Current active menu item is highlighted and can be |
| 13 | selected using the "Enter" key. The selection of the highlighted |
| 14 | menu entry invokes an U-Boot command (or a list of commands) |
| 15 | associated with this menu entry. |
| 16 | |
| 17 | The "bootmenu" command interprets ANSI escape sequencies, so |
| 18 | an ANSI terminal is required for proper menu rendering and item |
| 19 | selection. |
| 20 | |
| 21 | The assembling of the menu is done via a set of environment variables |
| 22 | "bootmenu_<num>" and "bootmenu_delay", i.e.: |
| 23 | |
| 24 | bootmenu_delay=<delay> |
| 25 | bootmenu_<num>="<title>=<commands>" |
| 26 | |
| 27 | <delay> is the autoboot delay in seconds, after which the first |
| 28 | menu entry will be selected automatically |
| 29 | |
| 30 | <num> is the boot menu entry number, starting from zero |
| 31 | |
| 32 | <title> is the text of the menu entry shown on the console |
| 33 | or on the boot screen |
| 34 | |
| 35 | <commands> are commands which will be executed when a menu |
| 36 | entry is selected |
| 37 | |
| 38 | (title and commands are separated by first appearance of '=' |
| 39 | character in the environment variable) |
| 40 | |
| 41 | First (optional) argument of the "bootmenu" command is a delay specifier |
| 42 | and it overrides the delay value defined by "bootmenu_delay" environment |
| 43 | variable. If the environment variable "bootmenu_delay" is not set or if |
| 44 | the argument of the "bootmenu" command is not specified, the default delay |
| 45 | will be CONFIG_BOOTDELAY. If delay is 0, no menu entries will be shown on |
| 46 | the console (or on the screen) and the command of the first menu entry will |
| 47 | be called immediately. If delay is less then 0, bootmenu will be shown and |
| 48 | autoboot will be disabled. |
| 49 | |
| 50 | Bootmenu always adds menu entry "U-Boot console" at the end of all menu |
| 51 | entries specified by environment variables. When selecting this entry |
| 52 | the bootmenu terminates and the usual U-Boot command prompt is presented |
| 53 | to the user. |
| 54 | |
| 55 | Example environment: |
| 56 | |
| 57 | setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Set first menu entry |
| 58 | setenv bootmenu_1 Boot 2. kernel=bootm 0x83000000 # Set second menu entry |
| 59 | setenv bootmenu_2 Reset board=reset # Set third menu entry |
| 60 | setenv bootmenu_3 U-Boot boot order=boot # Set fourth menu entry |
| 61 | bootmenu 20 # Run bootmenu with autoboot delay 20s |
| 62 | |
| 63 | |
| 64 | The above example will be rendered as below |
| 65 | (without decorating rectangle): |
| 66 | |
| 67 | ┌──────────────────────────────────────────┐ |
| 68 | │ │ |
| 69 | │ *** U-Boot Boot Menu *** │ |
| 70 | │ │ |
| 71 | │ Boot 1. kernel │ |
| 72 | │ Boot 2. kernel │ |
| 73 | │ Reset board │ |
| 74 | │ U-Boot boot order │ |
| 75 | │ U-Boot console │ |
| 76 | │ │ |
| 77 | │ Hit any key to stop autoboot: 20 │ |
| 78 | │ Press UP/DOWN to move, ENTER to select │ |
| 79 | │ │ |
| 80 | └──────────────────────────────────────────┘ |
| 81 | |
| 82 | Selected menu entry will be highlighted - it will have inverted |
| 83 | background and text colors. |
| 84 | |
| 85 | To enable the "bootmenu" command add following definitions to the |
| 86 | board config file: |
| 87 | |
| 88 | #define CONFIG_CMD_BOOTMENU |
| 89 | #define CONFIG_MENU |
| 90 | |
| 91 | To run the bootmenu at startup add these additional definitions: |
| 92 | |
| 93 | #define CONFIG_AUTOBOOT_KEYED |
| 94 | #define CONFIG_BOOTDELAY 30 |
| 95 | #define CONFIG_MENU_SHOW |
| 96 | |
| 97 | When you intend to use the bootmenu on color frame buffer console, |
| 98 | make sure to additionally define CONFIG_CFB_CONSOLE_ANSI in the |
| 99 | board config file. |