Vasileios Amoiridis | b9733de | 2024-06-28 19:35:42 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | Boot Count Limit |
| 4 | ================ |
| 5 | |
| 6 | This is enabled by CONFIG_BOOTCOUNT_LIMIT. |
| 7 | |
| 8 | This allows to detect multiple failed attempts to boot Linux. |
| 9 | |
| 10 | After a power-on reset, the ``bootcount`` variable will be initialized to 1, and |
| 11 | each reboot will increment the value by 1. |
| 12 | |
| 13 | If, after a reboot, the new value of ``bootcount`` exceeds the value of |
| 14 | ``bootlimit``, then instead of the standard boot action (executing the contents |
| 15 | of ``bootcmd``), an alternate boot action will be performed, and the contents of |
| 16 | ``altbootcmd`` will be executed. |
| 17 | |
| 18 | If the variable ``bootlimit`` is not defined in the environment, the Boot Count |
| 19 | Limit feature is disabled. If it is enabled, but ``altbootcmd`` is not defined, |
| 20 | then U-Boot will drop into interactive mode and remain there. |
| 21 | |
| 22 | It is the responsibility of some application code (typically a Linux |
| 23 | application) to reset the variable ``bootcount`` to 0 when the system booted |
| 24 | successfully, thus allowing for more boot cycles. |
| 25 | |
| 26 | CONFIG_BOOTCOUNT_FS |
| 27 | -------------------- |
| 28 | |
| 29 | This adds support for maintaining boot count in a file on a filesystem. |
| 30 | Tested filesystems are FAT and EXT. The file to use is defined by: |
| 31 | |
| 32 | CONFIG_SYS_BOOTCOUNT_FS_INTERFACE |
| 33 | CONFIG_SYS_BOOTCOUNT_FS_DEVPART |
| 34 | CONFIG_SYS_BOOTCOUNT_FS_NAME |
| 35 | |
| 36 | The format of the file is: |
| 37 | |
| 38 | .. list-table:: |
| 39 | :header-rows: 1 |
| 40 | |
| 41 | * - type |
| 42 | - entry |
| 43 | * - u8 |
| 44 | - magic |
| 45 | * - u8 |
| 46 | - version |
| 47 | * - u8 |
| 48 | - bootcount |
| 49 | * - u8 |
| 50 | - upgrade_available |
| 51 | |
Vasileios Amoiridis | 1e09ae2 | 2024-06-28 19:35:43 +0200 | [diff] [blame] | 52 | To prevent unintended usage of ``altbootcmd``, the ``upgrade_available`` |
Vasileios Amoiridis | b9733de | 2024-06-28 19:35:42 +0200 | [diff] [blame] | 53 | variable is used. |
| 54 | If ``upgrade_available`` is 0, ``bootcount`` is not saved. |
| 55 | If ``upgrade_available`` is 1, ``bootcount`` is saved. |
| 56 | So a userspace application should take care of setting the ``upgrade_available`` |
| 57 | and ``bootcount`` variables to 0, if the system boots successfully. |
| 58 | This also avoids writing the ``bootcount`` information on all reboots. |