Skip to contentSkip to conversation

drivers: bootcount: Add support for ANY filesystem

PATCH Superseded Vasileios Amoiridis 4 participants 8 messages Jun 13, 2024 – Jun 17, 2024

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover drivers: bootcount: Add support for ANY filesystem

Changes in v3:
- Remove specific CONFIGs for filesystems
- Add message to prompt user to enable required write function
- Use tags from previous rounds
- Move documentation to rST

v2: https://lore.kernel.org/u-boot/[email protected]

Changes in v2:
- Use generic code by utilizing FS_TYPE_ANY
- Change filename from bootcount_ext.c to bootcount_fs.c

v1: https://lore.kernel.org/u-boot/[email protected]/

This patch adds support to save the bootcount variable in a file located in FAT filesystem. Up to now, there was support only for EXT filesystem.

The reason I put this as RFC is because the file "bootcount_ext.c" will no longer represent the implementation for the EXT filesystem, but also for the FAT filesystem. Should it be renamed? If not, wouldn't it be inconsistent?

Cheers,
Vasilis

Vasileios Amoiridis (2):
drivers: bootcount: Add support for ANY filesystem
doc: api: bootcount: Convert to rST documentation

 doc/README.bootcount                          | 53 -----------------
 doc/api/bootcount.rst                         | 58 +++++++++++++++++++
 drivers/bootcount/Kconfig                     | 36 ++++++------
 drivers/bootcount/Makefile                    |  2 +-
 .../{bootcount_ext.c => bootcount_fs.c}       | 12 ++--
 5 files changed, 83 insertions(+), 78 deletions(-)
 delete mode 100644 doc/README.bootcount
 create mode 100644 doc/api/bootcount.rst
 rename drivers/bootcount/{bootcount_ext.c => bootcount_fs.c} (81%)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/2 drivers: bootcount: Add support for ANY filesystem

Add support to save boot count variable in ANY filesystem. Tested with FAT and EXT.

---
 doc/README.bootcount                          | 12 +++----
 drivers/bootcount/Kconfig                     | 36 +++++++++----------
 drivers/bootcount/Makefile                    |  2 +-
 .../{bootcount_ext.c => bootcount_fs.c}       | 12 +++----
 4 files changed, 31 insertions(+), 31 deletions(-)
 rename drivers/bootcount/{bootcount_ext.c => bootcount_fs.c} (81%)
doc/README.bootcount +6 -6
index f6c5f82f98..0f4ffb6828 100644
@@ -23,15 +23,15 @@ It is the responsibility of some application code (typically a Linux
 application) to reset the variable "bootcount" to 0 when the system booted
 successfully, thus allowing for more boot cycles.
 
-CONFIG_BOOTCOUNT_EXT
+CONFIG_BOOTCOUNT_FS
 --------------------
 
-This adds support for maintaining boot count in a file on an EXT filesystem.
-The file to use is defined by:
+This adds support for maintaining boot count in a file on a filesystem.
+Supported filesystems are FAT and EXT. The file to use is defined by:
 
-CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE
-CONFIG_SYS_BOOTCOUNT_EXT_DEVPART
-CONFIG_SYS_BOOTCOUNT_EXT_NAME
+CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
+CONFIG_SYS_BOOTCOUNT_FS_DEVPART
+CONFIG_SYS_BOOTCOUNT_FS_NAME
 
 The format of the file is:
 
drivers/bootcount/Kconfig +18 -18
index 3c56253b1e..fbf3c56b41 100644
@@ -25,13 +25,13 @@ config BOOTCOUNT_GENERIC
 	    Set to the address where the bootcount and bootcount magic
 	    will be stored.
 
-config BOOTCOUNT_EXT
-	bool "Boot counter on EXT filesystem"
-	depends on FS_EXT4
-	select EXT4_WRITE
+config BOOTCOUNT_FS
+	bool "Boot counter on a filesystem"
 	help
-	  Add support for maintaining boot count in a file on an EXT
-	  filesystem.
+	  Add support for maintaining boot count in a file on a filesystem.
+	  This requires that you have enabled write support for the filesystem
+	  that you will be used by the partition that you configure this feature
+	  for.
 
 config BOOTCOUNT_AM33XX
 	bool "Boot counter in AM33XX RTC IP block"
@@ -184,26 +184,26 @@ config SYS_BOOTCOUNT_SINGLEWORD
 	  This option enables packing boot count magic value and boot count
 	  into single word (32 bits).
 
-config SYS_BOOTCOUNT_EXT_INTERFACE
-	string "Interface on which to find boot counter EXT filesystem"
+config SYS_BOOTCOUNT_FS_INTERFACE
+	string "Interface on which to find boot counter filesystem"
 	default "mmc"
-	depends on BOOTCOUNT_EXT
+	depends on BOOTCOUNT_FS
 	help
 	  Set the interface to use when locating the filesystem to use for the
 	  boot counter.
 
-config SYS_BOOTCOUNT_EXT_DEVPART
-	string "Partition of the boot counter EXT filesystem"
+config SYS_BOOTCOUNT_FS_DEVPART
+	string "Partition of the boot counter filesystem"
 	default "0:1"
-	depends on BOOTCOUNT_EXT
+	depends on BOOTCOUNT_FS
 	help
 	  Set the partition to use when locating the filesystem to use for the
 	  boot counter.
 
-config SYS_BOOTCOUNT_EXT_NAME
-	string "Path and filename of the EXT filesystem based boot counter"
+config SYS_BOOTCOUNT_FS_NAME
+	string "Path and filename of the FS filesystem based boot counter"
 	default "/boot/failures"
-	depends on BOOTCOUNT_EXT
+	depends on BOOTCOUNT_FS
 	help
 	  Set the filename and path of the file used to store the boot counter.
 
@@ -211,18 +211,18 @@ config SYS_BOOTCOUNT_ADDR
 	hex "RAM address used for reading and writing the boot counter"
 	default 0x44E3E000 if BOOTCOUNT_AM33XX || BOOTCOUNT_AM33XX_NVMEM
 	default 0xE0115FF8 if ARCH_LS1043A || ARCH_LS1021A
-	depends on BOOTCOUNT_AM33XX || BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
+	depends on BOOTCOUNT_AM33XX || BOOTCOUNT_GENERIC || BOOTCOUNT_FS || \
 		   BOOTCOUNT_AM33XX_NVMEM
 	help
 	  Set the address used for reading and writing the boot counter.
 
 config SYS_BOOTCOUNT_MAGIC
 	hex "Magic value for the boot counter"
-	default 0xB001C041 if BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
+	default 0xB001C041 if BOOTCOUNT_GENERIC || BOOTCOUNT_FS || \
 			      BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
 			      BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT
 	default 0xB0 if BOOTCOUNT_AM33XX_NVMEM
-	depends on BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
+	depends on BOOTCOUNT_GENERIC || BOOTCOUNT_FS || \
 		   BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
 		   BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT || \
 		   BOOTCOUNT_AM33XX_NVMEM
drivers/bootcount/Makefile +1 -1
index e7771f5b36..245f879633 100644
@@ -6,7 +6,7 @@ obj-$(CONFIG_BOOTCOUNT_AT91)	+= bootcount_at91.o
 obj-$(CONFIG_BOOTCOUNT_AM33XX)	+= bootcount_davinci.o
 obj-$(CONFIG_BOOTCOUNT_RAM)	+= bootcount_ram.o
 obj-$(CONFIG_BOOTCOUNT_ENV)	+= bootcount_env.o
-obj-$(CONFIG_BOOTCOUNT_EXT)	+= bootcount_ext.o
+obj-$(CONFIG_BOOTCOUNT_FS)	+= bootcount_fs.o
 obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM)	+= bootcount_nvmem.o
 
 obj-$(CONFIG_DM_BOOTCOUNT)      += bootcount-uclass.o
drivers/bootcount/bootcount_fs.c renamed from drivers/bootcount/bootcount_ext.c +6 -6
similarity index 81%
rename from drivers/bootcount/bootcount_ext.c
rename to drivers/bootcount/bootcount_fs.c
index 9639e638e9..569592d8aa 100644
@@ -25,8 +25,8 @@ void bootcount_store(ulong a)
 	loff_t len;
 	int ret;
 
-	if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE,
-			   CONFIG_SYS_BOOTCOUNT_EXT_DEVPART, FS_TYPE_EXT)) {
+	if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_FS_INTERFACE,
+			   CONFIG_SYS_BOOTCOUNT_FS_DEVPART, FS_TYPE_ANY)) {
 		puts("Error selecting device\n");
 		return;
 	}
@@ -42,7 +42,7 @@ void bootcount_store(ulong a)
 	buf->upgrade_available = upgrade_available;
 	unmap_sysmem(buf);
 
-	ret = fs_write(CONFIG_SYS_BOOTCOUNT_EXT_NAME,
+	ret = fs_write(CONFIG_SYS_BOOTCOUNT_FS_NAME,
 		       CONFIG_SYS_BOOTCOUNT_ADDR, 0, sizeof(bootcount_ext_t),
 		       &len);
 	if (ret != 0)
@@ -55,13 +55,13 @@ ulong bootcount_load(void)
 	loff_t len_read;
 	int ret;
 
-	if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE,
-			   CONFIG_SYS_BOOTCOUNT_EXT_DEVPART, FS_TYPE_EXT)) {
+	if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_FS_INTERFACE,
+			   CONFIG_SYS_BOOTCOUNT_FS_DEVPART, FS_TYPE_ANY)) {
 		puts("Error selecting device\n");
 		return 0;
 	}
 
-	ret = fs_read(CONFIG_SYS_BOOTCOUNT_EXT_NAME, CONFIG_SYS_BOOTCOUNT_ADDR,
+	ret = fs_read(CONFIG_SYS_BOOTCOUNT_FS_NAME, CONFIG_SYS_BOOTCOUNT_ADDR,
 		      0, sizeof(bootcount_ext_t), &len_read);
 	if (ret != 0 || len_read != sizeof(bootcount_ext_t)) {
 		puts("Error loading bootcount\n");
Signature · 1 line
2.25.1
#2 lore raw

Hi Vasileios,

Quoted 53 lines · Vasileios Amoiridis

Add support to save boot count variable in ANY filesystem. Tested with FAT and EXT.

---
  doc/README.bootcount                          | 12 +++----
  drivers/bootcount/Kconfig                     | 36 +++++++++----------
  drivers/bootcount/Makefile                    |  2 +-
  .../{bootcount_ext.c => bootcount_fs.c}       | 12 +++----
  4 files changed, 31 insertions(+), 31 deletions(-)

rename drivers/bootcount/{bootcount_ext.c => bootcount_fs.c} (81%)

doc/README.bootcount +6 -6
index f6c5f82f98..0f4ffb6828 100644
@@ -23,15 +23,15 @@ It is the responsibility of some application code (typically a Linux
  application) to reset the variable "bootcount" to 0 when the system booted
  successfully, thus allowing for more boot cycles.
 
-CONFIG_BOOTCOUNT_EXT
+CONFIG_BOOTCOUNT_FS
  --------------------
 
-This adds support for maintaining boot count in a file on an EXT filesystem.
-The file to use is defined by:
+This adds support for maintaining boot count in a file on a filesystem.
+Supported filesystems are FAT and EXT. The file to use is defined by:
 
-CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE
-CONFIG_SYS_BOOTCOUNT_EXT_DEVPART
-CONFIG_SYS_BOOTCOUNT_EXT_NAME
+CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
+CONFIG_SYS_BOOTCOUNT_FS_DEVPART
+CONFIG_SYS_BOOTCOUNT_FS_NAME
 
  The format of the file is:
 
drivers/bootcount/Kconfig +0 -4
index 3c56253b1e..fbf3c56b41 100644
@@ -25,13 +25,13 @@ config BOOTCOUNT_GENERIC
  	    Set to the address where the bootcount and bootcount magic
  	    will be stored.
 
-config BOOTCOUNT_EXT
-	bool "Boot counter on EXT filesystem"
-	depends on FS_EXT4
-	select EXT4_WRITE

drivers/bootcount/Kconfig config BOOTCOUNT_GENERIC · line 35

Quoted 10 lines
drivers/bootcount/Kconfig +6 -2
+config BOOTCOUNT_FS
+	bool "Boot counter on a filesystem"
  	help
-	  Add support for maintaining boot count in a file on an EXT
-	  filesystem.
+	  Add support for maintaining boot count in a file on a filesystem.
+	  This requires that you have enabled write support for the filesystem
+	  that you will be used by the partition that you configure this feature
+	  for.
 

Some English issue here I think, I can suggest:

"""
This requires that write support for the filesystem maintaining the boot count file is enabled. """

I think this kind of change can be made while applying the patch, so if I were you I wouldn't send a v4 just for that unless the maintainer asks you to.

Looking good to me otherwise,
Cheers,
Quentin

#3 lore raw

PATCH v3 2/2 doc: api: bootcount: Convert to rST documentation

In reply to Vasileios Amoiridis

Move to the new documentation style with rST formatting.

---
 doc/README.bootcount  | 53 ---------------------------------------
 doc/api/bootcount.rst | 58 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 53 deletions(-)
 delete mode 100644 doc/README.bootcount
 create mode 100644 doc/api/bootcount.rst
doc/README.bootcount deleted +0 -53
deleted file mode 100644
index 0f4ffb6828..0000000000
@@ -1,53 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0+
-
-Boot Count Limit
-================
-
-This is enabled by CONFIG_BOOTCOUNT_LIMIT.
-
-This allows to detect multiple failed attempts to boot Linux.
-
-After a power-on reset, the "bootcount" variable will be initialized to 1, and
-each reboot will increment the value by 1.
-
-If, after a reboot, the new value of "bootcount" exceeds the value of
-"bootlimit", then instead of the standard boot action (executing the contents of
-"bootcmd"), an alternate boot action will be performed, and the contents of
-"altbootcmd" will be executed.
-
-If the variable "bootlimit" is not defined in the environment, the Boot Count
-Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined,
-then U-Boot will drop into interactive mode and remain there.
-
-It is the responsibility of some application code (typically a Linux
-application) to reset the variable "bootcount" to 0 when the system booted
-successfully, thus allowing for more boot cycles.
-
-CONFIG_BOOTCOUNT_FS
---------------------
-
-This adds support for maintaining boot count in a file on a filesystem.
-Supported filesystems are FAT and EXT. The file to use is defined by:
-
-CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
-CONFIG_SYS_BOOTCOUNT_FS_DEVPART
-CONFIG_SYS_BOOTCOUNT_FS_NAME
-
-The format of the file is:
-
-==== =================
-type entry
-==== =================
-u8   magic
-u8   version
-u8   bootcount
-u8   upgrade_available
-==== =================
-
-To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is
-used.
-If "upgrade_available" is 0, "bootcount" is not saved.
-If "upgrade_available" is 1, "bootcount" is saved.
-So a userspace application should take care of setting the "upgrade_available"
-and "bootcount" variables to 0, if the system boots successfully.
-This also avoids writing the "bootcount" information on all reboots.
doc/api/bootcount.rst new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

Hi Vasileios,

Quoted 117 lines · Vasileios Amoiridis

Move to the new documentation style with rST formatting.

---
  doc/README.bootcount  | 53 ---------------------------------------
  doc/api/bootcount.rst | 58 +++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 58 insertions(+), 53 deletions(-)

delete mode 100644 doc/README.bootcount
create mode 100644 doc/api/bootcount.rst

doc/README.bootcount deleted +0 -53
deleted file mode 100644
index 0f4ffb6828..0000000000
@@ -1,53 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0+
-
-Boot Count Limit
-================
-
-This is enabled by CONFIG_BOOTCOUNT_LIMIT.
-
-This allows to detect multiple failed attempts to boot Linux.
-
-After a power-on reset, the "bootcount" variable will be initialized to 1, and
-each reboot will increment the value by 1.
-
-If, after a reboot, the new value of "bootcount" exceeds the value of
-"bootlimit", then instead of the standard boot action (executing the contents of
-"bootcmd"), an alternate boot action will be performed, and the contents of
-"altbootcmd" will be executed.
-
-If the variable "bootlimit" is not defined in the environment, the Boot Count
-Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined,
-then U-Boot will drop into interactive mode and remain there.
-
-It is the responsibility of some application code (typically a Linux
-application) to reset the variable "bootcount" to 0 when the system booted
-successfully, thus allowing for more boot cycles.
-
-CONFIG_BOOTCOUNT_FS
---------------------
-
-This adds support for maintaining boot count in a file on a filesystem.
-Supported filesystems are FAT and EXT. The file to use is defined by:
-
-CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
-CONFIG_SYS_BOOTCOUNT_FS_DEVPART
-CONFIG_SYS_BOOTCOUNT_FS_NAME
-
-The format of the file is:
-
-==== =================
-type entry
-==== =================
-u8   magic
-u8   version
-u8   bootcount
-u8   upgrade_available
-==== =================
-
-To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is
-used.
-If "upgrade_available" is 0, "bootcount" is not saved.
-If "upgrade_available" is 1, "bootcount" is saved.
-So a userspace application should take care of setting the "upgrade_available"
-and "bootcount" variables to 0, if the system boots successfully.
-This also avoids writing the "bootcount" information on all reboots.
doc/api/bootcount.rst new file +42 -0
new file mode 100644
index 0000000000..9435a7ef15
@@ -0,0 +1,58 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Boot Count Limit
+================
+
+This is enabled by CONFIG_BOOTCOUNT_LIMIT.
+
+This allows to detect multiple failed attempts to boot Linux.
+
+After a power-on reset, the ``bootcount`` variable will be initialized to 1, and
+each reboot will increment the value by 1.
+
+If, after a reboot, the new value of ``bootcount`` exceeds the value of
+``bootlimit``, then instead of the standard boot action (executing the contents
+of ``bootcmd``), an alternate boot action will be performed, and the contents of
+``altbootcmd`` will be executed.
+
+If the variable ``bootlimit`` is not defined in the environment, the Boot Count
+Limit feature is disabled. If it is enabled, but ``altbootcmd`` is not defined,
+then U-Boot will drop into interactive mode and remain there.
+
+It is the responsibility of some application code (typically a Linux
+application) to reset the variable ``bootcount`` to 0 when the system booted
+successfully, thus allowing for more boot cycles.
+
+CONFIG_BOOTCOUNT_FS
+--------------------
+
+This adds support for maintaining boot count in a file on a filesystem.
+Tested filesystems are FAT and EXT. The file to use is defined by:
+
+CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
+CONFIG_SYS_BOOTCOUNT_FS_DEVPART
+CONFIG_SYS_BOOTCOUNT_FS_NAME
+
+The format of the file is:
+
+.. list-table::
+   :header-rows: 1
+
+   * - type
+     - entry

doc/api/bootcount.rst line 52

Quoted 10 lines
doc/api/bootcount.rst new file +10 -0
+   * - u8
+     - magic
+   * - u8
+     - version
+   * - u8
+     - bootcount
+   * - u8
+     - upgrade_available
+
+To prevent unattended usage of ``altbootcmd``, the ``upgrade_available``

I think what was meant here is likely "unintended" (not deliberate) rather than "unattended" (unsupervised)?

I understand you didn't introduce this and just migrated it to rST, so free patch to whoever feels like sending one :)

Thanks!
Quentin

#5 lore raw

Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

Quoted 134 lines · Quentin Schulz

Hi Vasileios,

Quoted 117 lines · Vasileios Amoiridis

Move to the new documentation style with rST formatting.

---
  doc/README.bootcount  | 53 ---------------------------------------
  doc/api/bootcount.rst | 58 +++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 58 insertions(+), 53 deletions(-)

delete mode 100644 doc/README.bootcount
create mode 100644 doc/api/bootcount.rst

doc/README.bootcount deleted +0 -53
deleted file mode 100644
index 0f4ffb6828..0000000000
@@ -1,53 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0+
-
-Boot Count Limit
-================
-
-This is enabled by CONFIG_BOOTCOUNT_LIMIT.
-
-This allows to detect multiple failed attempts to boot Linux.
-
-After a power-on reset, the "bootcount" variable will be initialized to 1, and
-each reboot will increment the value by 1.
-
-If, after a reboot, the new value of "bootcount" exceeds the value of
-"bootlimit", then instead of the standard boot action (executing the contents of
-"bootcmd"), an alternate boot action will be performed, and the contents of
-"altbootcmd" will be executed.
-
-If the variable "bootlimit" is not defined in the environment, the Boot Count
-Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined,
-then U-Boot will drop into interactive mode and remain there.
-
-It is the responsibility of some application code (typically a Linux
-application) to reset the variable "bootcount" to 0 when the system booted
-successfully, thus allowing for more boot cycles.
-
-CONFIG_BOOTCOUNT_FS
---------------------
-
-This adds support for maintaining boot count in a file on a filesystem.
-Supported filesystems are FAT and EXT. The file to use is defined by:
-
-CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
-CONFIG_SYS_BOOTCOUNT_FS_DEVPART
-CONFIG_SYS_BOOTCOUNT_FS_NAME
-
-The format of the file is:
-
-==== =================
-type entry
-==== =================
-u8   magic
-u8   version
-u8   bootcount
-u8   upgrade_available
-==== =================
-
-To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is
-used.
-If "upgrade_available" is 0, "bootcount" is not saved.
-If "upgrade_available" is 1, "bootcount" is saved.
-So a userspace application should take care of setting the "upgrade_available"
-and "bootcount" variables to 0, if the system boots successfully.
-This also avoids writing the "bootcount" information on all reboots.
doc/api/bootcount.rst new file +42 -0
new file mode 100644
index 0000000000..9435a7ef15
@@ -0,0 +1,58 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Boot Count Limit
+================
+
+This is enabled by CONFIG_BOOTCOUNT_LIMIT.
+
+This allows to detect multiple failed attempts to boot Linux.
+
+After a power-on reset, the ``bootcount`` variable will be initialized to 1, and
+each reboot will increment the value by 1.
+
+If, after a reboot, the new value of ``bootcount`` exceeds the value of
+``bootlimit``, then instead of the standard boot action (executing the contents
+of ``bootcmd``), an alternate boot action will be performed, and the contents of
+``altbootcmd`` will be executed.
+
+If the variable ``bootlimit`` is not defined in the environment, the Boot Count
+Limit feature is disabled. If it is enabled, but ``altbootcmd`` is not defined,
+then U-Boot will drop into interactive mode and remain there.
+
+It is the responsibility of some application code (typically a Linux
+application) to reset the variable ``bootcount`` to 0 when the system booted
+successfully, thus allowing for more boot cycles.
+
+CONFIG_BOOTCOUNT_FS
+--------------------
+
+This adds support for maintaining boot count in a file on a filesystem.
+Tested filesystems are FAT and EXT. The file to use is defined by:
+
+CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
+CONFIG_SYS_BOOTCOUNT_FS_DEVPART
+CONFIG_SYS_BOOTCOUNT_FS_NAME
+
+The format of the file is:
+
+.. list-table::
+   :header-rows: 1
+
+   * - type
+     - entry

doc/api/bootcount.rst line 52

Quoted 10 lines
doc/api/bootcount.rst new file +10 -0
+   * - u8
+     - magic
+   * - u8
+     - version
+   * - u8
+     - bootcount
+   * - u8
+     - upgrade_available
+
+To prevent unattended usage of ``altbootcmd``, the ``upgrade_available``

I think what was meant here is likely "unintended" (not deliberate) rather than "unattended" (unsupervised)?

Quoted 7 lines

I understand you didn't introduce this and just migrated it to rST, so free patch to whoever feels like sending one :)

Thanks!
Quentin

Well if Tom agrees also with the previous patch then maybe I can send a v4 correcting those 2 issues it's fine for me!

Cheers,
Vasilis

#6 lore raw

Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

Quoted 138 lines · Vasileios Amoiridis
Quoted 137 lines · Quentin Schulz

Hi Vasileios,

Quoted 117 lines · Vasileios Amoiridis

Move to the new documentation style with rST formatting.

---
  doc/README.bootcount  | 53 ---------------------------------------
  doc/api/bootcount.rst | 58 +++++++++++++++++++++++++++++++++++++++++++
  2 files changed, 58 insertions(+), 53 deletions(-)

delete mode 100644 doc/README.bootcount
create mode 100644 doc/api/bootcount.rst

doc/README.bootcount deleted +0 -53
deleted file mode 100644
index 0f4ffb6828..0000000000
@@ -1,53 +0,0 @@
-.. SPDX-License-Identifier: GPL-2.0+
-
-Boot Count Limit
-================
-
-This is enabled by CONFIG_BOOTCOUNT_LIMIT.
-
-This allows to detect multiple failed attempts to boot Linux.
-
-After a power-on reset, the "bootcount" variable will be initialized to 1, and
-each reboot will increment the value by 1.
-
-If, after a reboot, the new value of "bootcount" exceeds the value of
-"bootlimit", then instead of the standard boot action (executing the contents of
-"bootcmd"), an alternate boot action will be performed, and the contents of
-"altbootcmd" will be executed.
-
-If the variable "bootlimit" is not defined in the environment, the Boot Count
-Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined,
-then U-Boot will drop into interactive mode and remain there.
-
-It is the responsibility of some application code (typically a Linux
-application) to reset the variable "bootcount" to 0 when the system booted
-successfully, thus allowing for more boot cycles.
-
-CONFIG_BOOTCOUNT_FS
---------------------
-
-This adds support for maintaining boot count in a file on a filesystem.
-Supported filesystems are FAT and EXT. The file to use is defined by:
-
-CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
-CONFIG_SYS_BOOTCOUNT_FS_DEVPART
-CONFIG_SYS_BOOTCOUNT_FS_NAME
-
-The format of the file is:
-
-==== =================
-type entry
-==== =================
-u8   magic
-u8   version
-u8   bootcount
-u8   upgrade_available
-==== =================
-
-To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is
-used.
-If "upgrade_available" is 0, "bootcount" is not saved.
-If "upgrade_available" is 1, "bootcount" is saved.
-So a userspace application should take care of setting the "upgrade_available"
-and "bootcount" variables to 0, if the system boots successfully.
-This also avoids writing the "bootcount" information on all reboots.
doc/api/bootcount.rst new file +42 -0
new file mode 100644
index 0000000000..9435a7ef15
@@ -0,0 +1,58 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Boot Count Limit
+================
+
+This is enabled by CONFIG_BOOTCOUNT_LIMIT.
+
+This allows to detect multiple failed attempts to boot Linux.
+
+After a power-on reset, the ``bootcount`` variable will be initialized to 1, and
+each reboot will increment the value by 1.
+
+If, after a reboot, the new value of ``bootcount`` exceeds the value of
+``bootlimit``, then instead of the standard boot action (executing the contents
+of ``bootcmd``), an alternate boot action will be performed, and the contents of
+``altbootcmd`` will be executed.
+
+If the variable ``bootlimit`` is not defined in the environment, the Boot Count
+Limit feature is disabled. If it is enabled, but ``altbootcmd`` is not defined,
+then U-Boot will drop into interactive mode and remain there.
+
+It is the responsibility of some application code (typically a Linux
+application) to reset the variable ``bootcount`` to 0 when the system booted
+successfully, thus allowing for more boot cycles.
+
+CONFIG_BOOTCOUNT_FS
+--------------------
+
+This adds support for maintaining boot count in a file on a filesystem.
+Tested filesystems are FAT and EXT. The file to use is defined by:
+
+CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
+CONFIG_SYS_BOOTCOUNT_FS_DEVPART
+CONFIG_SYS_BOOTCOUNT_FS_NAME
+
+The format of the file is:
+
+.. list-table::
+   :header-rows: 1
+
+   * - type
+     - entry

doc/api/bootcount.rst line 52

Quoted 10 lines
doc/api/bootcount.rst new file +10 -0
+   * - u8
+     - magic
+   * - u8
+     - version
+   * - u8
+     - bootcount
+   * - u8
+     - upgrade_available
+
+To prevent unattended usage of ``altbootcmd``, the ``upgrade_available``

I think what was meant here is likely "unintended" (not deliberate) rather than "unattended" (unsupervised)?

I understand you didn't introduce this and just migrated it to rST, so free patch to whoever feels like sending one :)

Quoted 7 lines
Quoted 4 lines

Thanks!
Quentin

Well if Tom agrees also with the previous patch then maybe I can send a v4 correcting those 2 issues it's fine for me!

Yes, please do a v4 with that and adding this to the index in doc/api/index.rst so that CI will not fail.

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH v3 2/2] doc: api: bootcount: Convert to rST documentation

In reply to Vasileios Amoiridis

Hi Vasileios,

Quoted 10 lines · Vasileios Amoiridis

Move to the new documentation style with rST formatting.

---
 doc/README.bootcount  | 53 ---------------------------------------
 doc/api/bootcount.rst | 58 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 53 deletions(-)
 delete mode 100644 doc/README.bootcount
 create mode 100644 doc/api/bootcount.rst

Thanks for doing this. Can you please add it to an index file so it can be navigated to? You can check it with 'make htmldocs'.

Regards,
Simon