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