blob: f6c5f82f985b93f3c281767f5663b0eecb0163ab [file] [log] [blame]
Frédéric Danisdf928f82020-03-17 17:59:09 +01001.. SPDX-License-Identifier: GPL-2.0+
2
3Boot Count Limit
4================
5
Michael Opdenackerfc1383a2022-03-02 16:56:02 +01006This is enabled by CONFIG_BOOTCOUNT_LIMIT.
7
Frédéric Danisdf928f82020-03-17 17:59:09 +01008This allows to detect multiple failed attempts to boot Linux.
9
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010010After a power-on reset, the "bootcount" variable will be initialized to 1, and
Frédéric Danisdf928f82020-03-17 17:59:09 +010011each reboot will increment the value by 1.
12
13If, after a reboot, the new value of "bootcount" exceeds the value of
14"bootlimit", then instead of the standard boot action (executing the contents of
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010015"bootcmd"), an alternate boot action will be performed, and the contents of
Frédéric Danisdf928f82020-03-17 17:59:09 +010016"altbootcmd" will be executed.
17
18If the variable "bootlimit" is not defined in the environment, the Boot Count
19Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined,
20then U-Boot will drop into interactive mode and remain there.
21
22It is the responsibility of some application code (typically a Linux
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010023application) to reset the variable "bootcount" to 0 when the system booted
24successfully, thus allowing for more boot cycles.
Frédéric Danisdf928f82020-03-17 17:59:09 +010025
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010026CONFIG_BOOTCOUNT_EXT
27--------------------
Frédéric Danisdf928f82020-03-17 17:59:09 +010028
29This adds support for maintaining boot count in a file on an EXT filesystem.
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010030The file to use is defined by:
Frédéric Danisdf928f82020-03-17 17:59:09 +010031
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010032CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE
33CONFIG_SYS_BOOTCOUNT_EXT_DEVPART
34CONFIG_SYS_BOOTCOUNT_EXT_NAME
Frédéric Danisdf928f82020-03-17 17:59:09 +010035
36The format of the file is:
37
38==== =================
39type entry
40==== =================
41u8 magic
42u8 version
43u8 bootcount
44u8 upgrade_available
45==== =================
46
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010047To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is
Frédéric Danisdf928f82020-03-17 17:59:09 +010048used.
Michael Opdenackerfc1383a2022-03-02 16:56:02 +010049If "upgrade_available" is 0, "bootcount" is not saved.
50If "upgrade_available" is 1, "bootcount" is saved.
51So a userspace application should take care of setting the "upgrade_available"
52and "bootcount" variables to 0, if the system boots successfully.
53This also avoids writing the "bootcount" information on all reboots.