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