1*4882a593Smuzhiyun/* 2*4882a593Smuzhiyun * (C) Copyright 2001 3*4882a593Smuzhiyun * Dave Ellis, SIXNET, dge@sixnetio.com 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+ 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593SmuzhiyunUsing autoboot configuration options 9*4882a593Smuzhiyun==================================== 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunThe basic autoboot configuration options are documented in the main 12*4882a593SmuzhiyunU-Boot README. See it for details. They are: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun bootdelay 15*4882a593Smuzhiyun bootcmd 16*4882a593Smuzhiyun CONFIG_BOOTDELAY 17*4882a593Smuzhiyun CONFIG_BOOTCOMMAND 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunSome additional options that make autoboot safer in a production 20*4882a593Smuzhiyunproduct are documented here. 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunWhy use them? 23*4882a593Smuzhiyun------------- 24*4882a593Smuzhiyun 25*4882a593SmuzhiyunThe basic autoboot feature allows a system to automatically boot to 26*4882a593Smuzhiyunthe real application (such as Linux) without a user having to enter 27*4882a593Smuzhiyunany commands. If any key is pressed before the boot delay time 28*4882a593Smuzhiyunexpires, U-Boot stops the autoboot process, gives a U-Boot prompt 29*4882a593Smuzhiyunand waits forever for a command. That's a good thing if you pressed a 30*4882a593Smuzhiyunkey because you wanted to get the prompt. 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunIt's not so good if the key press was a stray character on the 33*4882a593Smuzhiyunconsole serial port, say because a user who knows nothing about 34*4882a593SmuzhiyunU-Boot pressed a key before the system had time to boot. It's even 35*4882a593Smuzhiyunworse on an embedded product that doesn't have a console during 36*4882a593Smuzhiyunnormal use. The modem plugged into that console port sends a 37*4882a593Smuzhiyuncharacter at the wrong time and the system hangs, with no clue as to 38*4882a593Smuzhiyunwhy it isn't working. 39*4882a593Smuzhiyun 40*4882a593SmuzhiyunYou might want the system to autoboot to recover after an external 41*4882a593Smuzhiyunconfiguration program stops autoboot. If the configuration program 42*4882a593Smuzhiyundies or loses its connection (modems can disconnect at the worst 43*4882a593Smuzhiyuntime) U-Boot will patiently wait forever for it to finish. 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunThese additional configuration options can help provide a system that 46*4882a593Smuzhiyunboots when it should, but still allows access to U-Boot. 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunWhat they do 49*4882a593Smuzhiyun------------ 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun CONFIG_BOOT_RETRY_TIME 52*4882a593Smuzhiyun CONFIG_BOOT_RETRY_MIN 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun "bootretry" environment variable 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun These options determine what happens after autoboot is 57*4882a593Smuzhiyun stopped and U-Boot is waiting for commands. 58*4882a593Smuzhiyun 59*4882a593Smuzhiyun CONFIG_BOOT_RETRY_TIME must be defined to enable the boot 60*4882a593Smuzhiyun retry feature. If the environment variable "bootretry" is 61*4882a593Smuzhiyun found then its value is used, otherwise the retry timeout is 62*4882a593Smuzhiyun CONFIG_BOOT_RETRY_TIME. CONFIG_BOOT_RETRY_MIN is optional and 63*4882a593Smuzhiyun defaults to CONFIG_BOOT_RETRY_TIME. All times are in seconds. 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun If the retry timeout is negative, the U-Boot command prompt 66*4882a593Smuzhiyun never times out. Otherwise it is forced to be at least 67*4882a593Smuzhiyun CONFIG_BOOT_RETRY_MIN seconds. If no valid U-Boot command is 68*4882a593Smuzhiyun entered before the specified time the boot delay sequence is 69*4882a593Smuzhiyun restarted. Each command that U-Boot executes restarts the 70*4882a593Smuzhiyun timeout. 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun If CONFIG_BOOT_RETRY_TIME < 0 the feature is there, but 73*4882a593Smuzhiyun doesn't do anything unless the environment variable 74*4882a593Smuzhiyun "bootretry" is >= 0. 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun CONFIG_AUTOBOOT_KEYED 77*4882a593Smuzhiyun CONFIG_AUTOBOOT_KEYED_CTRLC 78*4882a593Smuzhiyun CONFIG_AUTOBOOT_PROMPT 79*4882a593Smuzhiyun CONFIG_AUTOBOOT_DELAY_STR 80*4882a593Smuzhiyun CONFIG_AUTOBOOT_STOP_STR 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun "bootdelaykey" environment variable 83*4882a593Smuzhiyun "bootstopkey" environment variable 84*4882a593Smuzhiyun 85*4882a593Smuzhiyun These options give more control over stopping autoboot. When 86*4882a593Smuzhiyun they are used a specific character or string is required to 87*4882a593Smuzhiyun stop or delay autoboot. 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun Define CONFIG_AUTOBOOT_KEYED (no value required) to enable 90*4882a593Smuzhiyun this group of options. CONFIG_AUTOBOOT_DELAY_STR, 91*4882a593Smuzhiyun CONFIG_AUTOBOOT_STOP_STR or both should be specified (or 92*4882a593Smuzhiyun specified by the corresponding environment variable), 93*4882a593Smuzhiyun otherwise there is no way to stop autoboot. 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun CONFIG_AUTOBOOT_PROMPT is displayed before the boot delay 96*4882a593Smuzhiyun selected by CONFIG_BOOTDELAY starts. If it is not defined 97*4882a593Smuzhiyun there is no output indicating that autoboot is in progress. 98*4882a593Smuzhiyun 99*4882a593Smuzhiyun Note that CONFIG_AUTOBOOT_PROMPT is used as the (only) 100*4882a593Smuzhiyun argument to a printf() call, so it may contain '%' format 101*4882a593Smuzhiyun specifications, provided that it also includes, sepearated by 102*4882a593Smuzhiyun commas exactly like in a printf statement, the required 103*4882a593Smuzhiyun arguments. It is the responsibility of the user to select only 104*4882a593Smuzhiyun such arguments that are valid in the given context. A 105*4882a593Smuzhiyun reasonable prompt could be defined as 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun #define CONFIG_AUTOBOOT_PROMPT \ 108*4882a593Smuzhiyun "autoboot in %d seconds\n",bootdelay 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun If CONFIG_AUTOBOOT_DELAY_STR or "bootdelaykey" is specified 111*4882a593Smuzhiyun and this string is received from console input before 112*4882a593Smuzhiyun autoboot starts booting, U-Boot gives a command prompt. The 113*4882a593Smuzhiyun U-Boot prompt will time out if CONFIG_BOOT_RETRY_TIME is 114*4882a593Smuzhiyun used, otherwise it never times out. 115*4882a593Smuzhiyun 116*4882a593Smuzhiyun If CONFIG_AUTOBOOT_STOP_STR or "bootstopkey" is specified and 117*4882a593Smuzhiyun this string is received from console input before autoboot 118*4882a593Smuzhiyun starts booting, U-Boot gives a command prompt. The U-Boot 119*4882a593Smuzhiyun prompt never times out, even if CONFIG_BOOT_RETRY_TIME is 120*4882a593Smuzhiyun used. 121*4882a593Smuzhiyun 122*4882a593Smuzhiyun The string recognition is not very sophisticated. If a 123*4882a593Smuzhiyun partial match is detected, the first non-matching character 124*4882a593Smuzhiyun is checked to see if starts a new match. There is no check 125*4882a593Smuzhiyun for a shorter partial match, so it's best if the first 126*4882a593Smuzhiyun character of a key string does not appear in the rest of the 127*4882a593Smuzhiyun string. 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun The CONFIG_AUTOBOOT_KEYED_CTRLC #define allows for the boot 130*4882a593Smuzhiyun sequence to be interrupted by ctrl-c, in addition to the 131*4882a593Smuzhiyun "bootdelaykey" and "bootstopkey". Setting this variable 132*4882a593Smuzhiyun provides an escape sequence from the limited "password" 133*4882a593Smuzhiyun strings. 134*4882a593Smuzhiyun 135*4882a593Smuzhiyun CONFIG_RESET_TO_RETRY 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun (Only effective when CONFIG_BOOT_RETRY_TIME is also set) 138*4882a593Smuzhiyun After the countdown timed out, the board will be reset to restart 139*4882a593Smuzhiyun again. 140