Skip to contentSkip to conversation

bootcount_ext: Add flag to enable/disable bootcount

PATCH Superseded Frédéric Danis 3 participants 8 messages Mar 17, 2020 – Apr 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

After a successful upgrade, multiple problem during boot sequence may trigger the altbootcmd process.
This patch adds a version and an upgrade_available entries to the bootcount file to enable/disable the bootcount check.
When failing to read the bootcount file it will consider that bootcount is enabled, acting as previously, and update the file accordingly.

The bootcount file is only saved when upgrade_available is true, this allows to save writes to the filesystem.

---
 doc/README.bootcount              | 51 +++++++++++++++++++++++++++++++
 drivers/bootcount/bootcount_ext.c | 46 ++++++++++++++++++++--------
 2 files changed, 85 insertions(+), 12 deletions(-)
 create mode 100644 doc/README.bootcount
doc/README.bootcount new file +51 -0
new file mode 100644
index 0000000000..b1c22905c6
@@ -0,0 +1,51 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+Boot Count Limit
+================
+
+This allows to detect multiple failed attempts to boot Linux.
+
+After a power-on reset, "bootcount" variable will be initialized with 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", thus allowing for more boot
+cycles.
+
+BOOTCOUNT_EXT
+-------------
+
+This adds support for maintaining boot count in a file on an EXT filesystem.
+The file to use is define by:
+
+SYS_BOOTCOUNT_EXT_INTERFACE
+SYS_BOOTCOUNT_EXT_DEVPART
+SYS_BOOTCOUNT_EXT_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 save.
+So the Userspace Application must set the "upgrade_available" and "bootcount"
+variables to 0, if a boot was successfully.
+This also prevents writes on all reboots.
drivers/bootcount/bootcount_ext.c +34 -12

80 lines not on this page · raw message

Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Hi Fr?d?ric,

Quoted 8 lines · Fr?d?ric Danis

After a successful upgrade, multiple problem during boot sequence may trigger the altbootcmd process.
This patch adds a version and an upgrade_available entries to the bootcount file to enable/disable the bootcount check.
When failing to read the bootcount file it will consider that bootcount is enabled, acting as previously, and update the file accordingly.

Quoted 4 lines

The bootcount file is only saved when upgrade_available is true, this allows to save writes to the filesystem.

Is there a change log? I see that this is v2.

Regards,
Simon

#2 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Hi Simon,

Sorry I missed to add the change log.

Since v1:
- Add doc/README.bootcount
- Add version number in bootcount_ext file and change Magic byte

Regards,
Fred

Quoted 19 lines · Simon Glass

Hi Fr?d?ric,

Quoted 11 lines · Fr?d?ric Danis

After a successful upgrade, multiple problem during boot sequence may trigger the altbootcmd process.
This patch adds a version and an upgrade_available entries to the bootcount file to enable/disable the bootcount check.
When failing to read the bootcount file it will consider that bootcount is enabled, acting as previously, and update the file accordingly.

The bootcount file is only saved when upgrade_available is true, this allows to save writes to the filesystem.

Is there a change log? I see that this is v2.

Regards,
Simon

#3 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Quoted 8 lines · Fr?d?ric Danis

Hi Simon,

Sorry I missed to add the change log.

Since v1:
- Add doc/README.bootcount
- Add version number in bootcount_ext file and change Magic byte

Quoted 25 lines

Regards,
Fred

Quoted 19 lines · Simon Glass

Hi Fr?d?ric,

Quoted 11 lines · Fr?d?ric Danis

After a successful upgrade, multiple problem during boot sequence may trigger the altbootcmd process.
This patch adds a version and an upgrade_available entries to the bootcount file to enable/disable the bootcount check.
When failing to read the bootcount file it will consider that bootcount is enabled, acting as previously, and update the file accordingly.

The bootcount file is only saved when upgrade_available is true, this allows to save writes to the filesystem.

Is there a change log? I see that this is v2.

Regards,
Simon

#4 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Hi Simon,

Quoted 10 lines · Simon Glass
Quoted 7 lines · Fr?d?ric Danis

Hi Simon,

Sorry I missed to add the change log.

Since v1:
- Add doc/README.bootcount
- Add version number in bootcount_ext file and change Magic byte

Thanks for the review.
What should be the next steps to get this commit merged? Should I need to send a new version with your Reviewed-By, or should it need to be reviewed by someone else?

Best regards,

Fred

#5 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Hi Fred,

Quoted 13 lines · Fr?d?ric Danis

Hi Simon,

Quoted 9 lines · Simon Glass
Quoted 7 lines · Fr?d?ric Danis

Hi Simon,

Sorry I missed to add the change log.

Since v1:
- Add doc/README.bootcount
- Add version number in bootcount_ext file and change Magic byte

Quoted 6 lines
Quoted 1 line

Thanks for the review.
What should be the next steps to get this commit merged? Should I need to send a new version with your Reviewed-By, or should it need to be reviewed by someone else?

I'm not sure if anyone else will review it. Tom may pull it into his next branch, or otherwise it will be merged when the merge window opens.

Regards,
Simon

#6 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

Hi Tom,

Quoted 21 lines · Simon Glass

Hi Fred,

Quoted 9 lines · Fr?d?ric Danis

Hi Simon,

Quoted 6 lines · Simon Glass
Quoted 4 lines · Fr?d?ric Danis

Hi Simon,

Sorry I missed to add the change log.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Since v1:
- Add doc/README.bootcount
- Add version number in bootcount_ext file and change Magic byte

Thanks for the review.
What should be the next steps to get this commit merged? Should I need to send a new version with your Reviewed-By, or should it need to be reviewed by someone else?

Quoted 6 lines

I'm not sure if anyone else will review it. Tom may pull it into his next branch, or otherwise it will be merged when the merge window opens.

Regards,
Simon

Can I hope this is merged in next version?

Best regards,

Fr?d?ric Danis

#7 lore raw

PATCH v2 1/1 bootcount_ext: Add flag to enable/disable bootcount

In reply to Frédéric Danis
Quoted 7 lines · Fr?d?ric Danis

After a successful upgrade, multiple problem during boot sequence may trigger the altbootcmd process.
This patch adds a version and an upgrade_available entries to the bootcount file to enable/disable the bootcount check.
When failing to read the bootcount file it will consider that bootcount is enabled, acting as previously, and update the file accordingly.

Quoted 5 lines

The bootcount file is only saved when upgrade_available is true, this allows to save writes to the filesystem.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/9f7c93c2/attachment.sig>