Heinrich Schuchardt | d2c0a05 | 2020-12-12 10:53:17 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | .. (C) Copyright 2011-2012 Pali Rohรกr <pali@kernel.org> |
| 3 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 4 | .. index:: |
| 5 | single: bootmenu (command) |
| 6 | |
Heinrich Schuchardt | d2c0a05 | 2020-12-12 10:53:17 +0100 | [diff] [blame] | 7 | bootmenu command |
| 8 | ================ |
| 9 | |
Masahisa Kojima | 3511024 | 2022-09-12 17:33:57 +0900 | [diff] [blame] | 10 | Synopsis |
| 11 | -------- |
| 12 | :: |
| 13 | |
| 14 | bootmenu [delay] |
| 15 | |
| 16 | Description |
| 17 | ----------- |
| 18 | |
Heinrich Schuchardt | d2c0a05 | 2020-12-12 10:53:17 +0100 | [diff] [blame] | 19 | The "bootmenu" command uses U-Boot menu interfaces and provides |
| 20 | a simple mechanism for creating menus with different boot items. |
| 21 | The cursor keys "Up" and "Down" are used for navigation through |
| 22 | the items. Current active menu item is highlighted and can be |
| 23 | selected using the "Enter" key. The selection of the highlighted |
| 24 | menu entry invokes an U-Boot command (or a list of commands) |
| 25 | associated with this menu entry. |
| 26 | |
Heinrich Schuchardt | 37581cf | 2022-04-29 22:01:54 +0200 | [diff] [blame] | 27 | The "bootmenu" command interprets ANSI escape sequences, so |
Heinrich Schuchardt | d2c0a05 | 2020-12-12 10:53:17 +0100 | [diff] [blame] | 28 | an ANSI terminal is required for proper menu rendering and item |
| 29 | selection. |
| 30 | |
| 31 | The assembling of the menu is done via a set of environment variables |
| 32 | "bootmenu_<num>" and "bootmenu_delay", i.e.:: |
| 33 | |
| 34 | bootmenu_delay=<delay> |
| 35 | bootmenu_<num>="<title>=<commands>" |
| 36 | |
| 37 | <delay> |
| 38 | is the autoboot delay in seconds, after which the first |
| 39 | menu entry will be selected automatically |
| 40 | |
| 41 | <num> |
| 42 | is the boot menu entry number, starting from zero |
| 43 | |
| 44 | <title> |
| 45 | is the text of the menu entry shown on the console |
| 46 | or on the boot screen |
| 47 | |
| 48 | <commands> |
| 49 | are commands which will be executed when a menu |
| 50 | entry is selected |
| 51 | |
| 52 | Title and commands are separated by the first appearance of a '=' |
| 53 | character in the value of the environment variable. |
| 54 | |
| 55 | The first (optional) argument of the "bootmenu" command is a delay specifier |
| 56 | and it overrides the delay value defined by "bootmenu_delay" environment |
| 57 | variable. If the environment variable "bootmenu_delay" is not set or if |
| 58 | the argument of the "bootmenu" command is not specified, the default delay |
| 59 | will be CONFIG_BOOTDELAY. If delay is 0, no menu entries will be shown on |
| 60 | the console (or on the screen) and the command of the first menu entry will |
| 61 | be called immediately. If delay is less then 0, bootmenu will be shown and |
| 62 | autoboot will be disabled. |
| 63 | |
| 64 | Bootmenu always adds menu entry "U-Boot console" at the end of all menu |
| 65 | entries specified by environment variables. When selecting this entry |
| 66 | the bootmenu terminates and the usual U-Boot command prompt is presented |
| 67 | to the user. |
| 68 | |
| 69 | Example environment:: |
| 70 | |
| 71 | setenv bootmenu_0 Boot 1. kernel=bootm 0x82000000 # Set first menu entry |
| 72 | setenv bootmenu_1 Boot 2. kernel=bootm 0x83000000 # Set second menu entry |
| 73 | setenv bootmenu_2 Reset board=reset # Set third menu entry |
| 74 | setenv bootmenu_3 U-Boot boot order=boot # Set fourth menu entry |
| 75 | bootmenu 20 # Run bootmenu with autoboot delay 20s |
| 76 | |
| 77 | |
| 78 | The above example will be rendered as below:: |
| 79 | |
| 80 | *** U-Boot Boot Menu *** |
| 81 | |
| 82 | Boot 1. kernel |
| 83 | Boot 2. kernel |
| 84 | Reset board |
| 85 | U-Boot boot order |
| 86 | U-Boot console |
| 87 | |
| 88 | Hit any key to stop autoboot: 20 |
| 89 | Press UP/DOWN to move, ENTER to select |
| 90 | |
| 91 | The selected menu entry will be highlighted - it will have inverted |
| 92 | background and text colors. |
| 93 | |
Masahisa Kojima | 3511024 | 2022-09-12 17:33:57 +0900 | [diff] [blame] | 94 | UEFI boot variable enumeration |
| 95 | '''''''''''''''''''''''''''''' |
| 96 | If enabled, the bootmenu command will automatically generate and add |
| 97 | UEFI-related boot menu entries for the following items. |
| 98 | |
| 99 | * possible bootable media with default file names |
| 100 | * user-defined UEFI boot options |
| 101 | |
| 102 | The bootmenu automatically enumerates the possible bootable |
| 103 | media devices supporting EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. |
| 104 | This auto generated entry is named as "<interface> <devnum>:<part>" format. |
| 105 | (e.g. "usb 0:1") |
| 106 | |
| 107 | The bootmenu displays the UEFI-related menu entries in order of "BootOrder". |
| 108 | When the user selects the UEFI boot menu entry, the bootmenu sets |
| 109 | the selected boot variable index to "BootNext" without non-volatile attribute, |
| 110 | then call the uefi boot manager with the command "bootefi bootmgr". |
| 111 | |
| 112 | Example bootmenu is as below:: |
| 113 | |
| 114 | *** U-Boot Boot Menu *** |
| 115 | |
| 116 | mmc 0:1 |
| 117 | mmc 0:2 |
| 118 | debian |
| 119 | nvme 0:1 |
| 120 | ubuntu |
| 121 | nvme 0:2 |
| 122 | usb 0:2 |
| 123 | U-Boot console |
| 124 | |
| 125 | Default behavior when user exits from the bootmenu |
| 126 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 127 | User can exit from bootmenu by selecting the last entry |
Masahisa Kojima | 3a9eb07 | 2023-02-02 18:24:43 +0900 | [diff] [blame] | 128 | "U-Boot console"/"Quit" or ESC key. |
Masahisa Kojima | 3511024 | 2022-09-12 17:33:57 +0900 | [diff] [blame] | 129 | |
| 130 | When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is disabled, |
| 131 | user exits from the bootmenu and returns to the U-Boot console. |
| 132 | |
| 133 | When the CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE is enabled, user can not |
| 134 | enter the U-Boot console. When the user exits from the bootmenu, |
| 135 | the bootmenu invokes the following default behavior. |
| 136 | |
| 137 | * if CONFIG_CMD_BOOTEFI_BOOTMGR is enabled, execute "bootefi bootmgr" command |
| 138 | * "bootefi bootmgr" fails or is not enabled, then execute "run bootcmd" command. |
| 139 | |
| 140 | Configuration |
| 141 | ------------- |
| 142 | |
Heinrich Schuchardt | 37581cf | 2022-04-29 22:01:54 +0200 | [diff] [blame] | 143 | The "bootmenu" command is enabled by:: |
Heinrich Schuchardt | d2c0a05 | 2020-12-12 10:53:17 +0100 | [diff] [blame] | 144 | |
| 145 | CONFIG_CMD_BOOTMENU=y |
| 146 | |
| 147 | To run the bootmenu at startup add these additional settings:: |
| 148 | |
| 149 | CONFIG_AUTOBOOT_KEYED=y |
| 150 | CONFIG_BOOTDELAY=30 |
| 151 | CONFIG_AUTOBOOT_MENU_SHOW=y |
Masahisa Kojima | 3511024 | 2022-09-12 17:33:57 +0900 | [diff] [blame] | 152 | |
| 153 | UEFI boot variable enumeration is enabled by:: |
| 154 | |
| 155 | CONFIG_CMD_BOOTEFI_BOOTMGR=y |
| 156 | |
| 157 | To improve the product security, entering U-Boot console from bootmenu |
| 158 | can be disabled by:: |
| 159 | |
| 160 | CONFIG_BOOTMENU_DISABLE_UBOOT_CONSOLE=y |
| 161 | |
| 162 | To scan the discoverable devices connected to the buses such as |
| 163 | USB and PCIe prior to bootmenu showing up, CONFIG_PREBOOT can be |
| 164 | used to run the command before showing the bootmenu, i.e.:: |
| 165 | |
| 166 | CONFIG_USE_PREBOOT=y |
| 167 | CONFIG_PREBOOT="pci enum; usb start; scsi scan; nvme scan; virtio scan" |