* [RFC PATCH 0/1] drivers: bootcount: Add support for FAT filesystem
@ 2024-06-05 18:10 Vasileios Amoiridis
2024-06-05 18:10 ` [RFC PATCH] " Vasileios Amoiridis
2024-06-05 18:48 ` [RFC PATCH 0/1] " Tom Rini
0 siblings, 2 replies; 7+ messages in thread
From: Vasileios Amoiridis @ 2024-06-05 18:10 UTC (permalink / raw)
To: trini, hs, pro; +Cc: vasileios.amoiridis, u-boot
From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
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
P.S: Documentation has not been modified yet, I will submit in the v2 (if any).
Vasileios Amoiridis (1):
drivers: bootcount: Add support for FAT filesystem
doc/README.bootcount | 12 ++++----
drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
drivers/bootcount/Makefile | 2 +-
drivers/bootcount/bootcount_ext.c | 18 ++++++++----
4 files changed, 56 insertions(+), 25 deletions(-)
base-commit: c0ea27bccfb7d2d37fd36806ac2a2f7389099420
--
2.34.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [RFC PATCH] drivers: bootcount: Add support for FAT filesystem
2024-06-05 18:10 [RFC PATCH 0/1] drivers: bootcount: Add support for FAT filesystem Vasileios Amoiridis
@ 2024-06-05 18:10 ` Vasileios Amoiridis
2024-06-06 7:58 ` Philip Oberfichtner
2024-06-06 15:34 ` Quentin Schulz
2024-06-05 18:48 ` [RFC PATCH 0/1] " Tom Rini
1 sibling, 2 replies; 7+ messages in thread
From: Vasileios Amoiridis @ 2024-06-05 18:10 UTC (permalink / raw)
To: trini, hs, pro; +Cc: vasileios.amoiridis, u-boot
From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
Add support to save boot count variable in a file in a FAT filesystem.
Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
---
doc/README.bootcount | 12 ++++----
drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
drivers/bootcount/Makefile | 2 +-
drivers/bootcount/bootcount_ext.c | 18 ++++++++----
4 files changed, 56 insertions(+), 25 deletions(-)
diff --git a/doc/README.bootcount b/doc/README.bootcount
index f6c5f82f98..cce66d4d70 100644
--- a/doc/README.bootcount
+++ b/doc/README.bootcount
@@ -23,15 +23,17 @@ 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.
+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:
diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
index 3c56253b1e..a39a7556bb 100644
--- a/drivers/bootcount/Kconfig
+++ b/drivers/bootcount/Kconfig
@@ -25,10 +25,9 @@ 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 filesystem"
+ depends on FS_EXT4 || FS_FAT
help
Add support for maintaining boot count in a file on an EXT
filesystem.
@@ -177,6 +176,30 @@ config BOOTCOUNT_BOOTLIMIT
counter being cleared.
If set to 0, do not set a boot limit in the environment.
+if BOOTCOUNT_FS
+choice
+ prompt "Filesystem type"
+ default BOOTCOUNT_EXT
+
+config BOOTCOUNT_EXT
+ bool "Boot counter on EXT filesystem"
+ depends on FS_EXT4
+ select EXT4_WRITE
+ help
+ Add support for maintaining boot count in a file on an EXT
+ filesystem.
+
+config BOOTCOUNT_FAT
+ bool "Boot counter on FAT filesystem"
+ depends on FS_FAT
+ select FAT_WRITE
+ help
+ Add support for maintaining boot count in a file on a FAT
+ filesystem.
+
+endchoice
+endif
+
config SYS_BOOTCOUNT_SINGLEWORD
bool "Use single word to pack boot count and magic value"
depends on BOOTCOUNT_GENERIC
@@ -184,26 +207,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
+config SYS_BOOTCOUNT_FS_INTERFACE
string "Interface on which to find boot counter EXT 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
+config SYS_BOOTCOUNT_FS_DEVPART
string "Partition of the boot counter EXT 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
+config SYS_BOOTCOUNT_FS_NAME
string "Path and filename of the EXT 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 +234,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
diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
index e7771f5b36..c0427434d7 100644
--- a/drivers/bootcount/Makefile
+++ b/drivers/bootcount/Makefile
@@ -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_ext.o
obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
index 9639e638e9..660bea2db2 100644
--- a/drivers/bootcount/bootcount_ext.c
+++ b/drivers/bootcount/bootcount_ext.c
@@ -19,14 +19,20 @@ typedef struct {
static u8 upgrade_available = 1;
+#ifdef BOOTCOUNT_EXT
+static u8 bootcount_fstype = FS_TYPE_EXT;
+#else
+static u8 bootcount_fstype = FS_TYPE_FAT;
+#endif
+
void bootcount_store(ulong a)
{
bootcount_ext_t *buf;
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, bootcount_fstype)) {
puts("Error selecting device\n");
return;
}
@@ -42,7 +48,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 +61,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, bootcount_fstype)) {
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");
base-commit: c0ea27bccfb7d2d37fd36806ac2a2f7389099420
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC PATCH 0/1] drivers: bootcount: Add support for FAT filesystem
2024-06-05 18:10 [RFC PATCH 0/1] drivers: bootcount: Add support for FAT filesystem Vasileios Amoiridis
2024-06-05 18:10 ` [RFC PATCH] " Vasileios Amoiridis
@ 2024-06-05 18:48 ` Tom Rini
1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2024-06-05 18:48 UTC (permalink / raw)
To: Vasileios Amoiridis; +Cc: hs, pro, vasileios.amoiridis, u-boot
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
On Wed, Jun 05, 2024 at 08:10:40PM +0200, Vasileios Amoiridis wrote:
> From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
>
> 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?
Yeah, lets call it bootcount_fs.c ? It otherwise all looks good to me,
thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] drivers: bootcount: Add support for FAT filesystem
2024-06-05 18:10 ` [RFC PATCH] " Vasileios Amoiridis
@ 2024-06-06 7:58 ` Philip Oberfichtner
2024-06-06 17:11 ` Vasileios Amoiridis
2024-06-06 15:34 ` Quentin Schulz
1 sibling, 1 reply; 7+ messages in thread
From: Philip Oberfichtner @ 2024-06-06 7:58 UTC (permalink / raw)
To: Vasileios Amoiridis; +Cc: trini, hs, vasileios.amoiridis, u-boot
Hi,
On Wed, Jun 05, 2024 at 08:10:41PM +0200, Vasileios Amoiridis wrote:
> From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
>
> Add support to save boot count variable in a file in a FAT filesystem.
>
> Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> ---
> doc/README.bootcount | 12 ++++----
> drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
> drivers/bootcount/Makefile | 2 +-
> drivers/bootcount/bootcount_ext.c | 18 ++++++++----
> 4 files changed, 56 insertions(+), 25 deletions(-)
>
> diff --git a/doc/README.bootcount b/doc/README.bootcount
> index f6c5f82f98..cce66d4d70 100644
> --- a/doc/README.bootcount
> +++ b/doc/README.bootcount
> @@ -23,15 +23,17 @@ 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.
> +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:
>
> diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
> index 3c56253b1e..a39a7556bb 100644
> --- a/drivers/bootcount/Kconfig
> +++ b/drivers/bootcount/Kconfig
> @@ -25,10 +25,9 @@ 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 filesystem"
> + depends on FS_EXT4 || FS_FAT
> help
> Add support for maintaining boot count in a file on an EXT
> filesystem.
The help message refers to EXT only, not mentioning FAT.
> @@ -177,6 +176,30 @@ config BOOTCOUNT_BOOTLIMIT
> counter being cleared.
> If set to 0, do not set a boot limit in the environment.
>
> +if BOOTCOUNT_FS
> +choice
> + prompt "Filesystem type"
> + default BOOTCOUNT_EXT
> +
> +config BOOTCOUNT_EXT
> + bool "Boot counter on EXT filesystem"
> + depends on FS_EXT4
> + select EXT4_WRITE
> + help
> + Add support for maintaining boot count in a file on an EXT
> + filesystem.
> +
> +config BOOTCOUNT_FAT
> + bool "Boot counter on FAT filesystem"
> + depends on FS_FAT
> + select FAT_WRITE
> + help
> + Add support for maintaining boot count in a file on a FAT
> + filesystem.
> +
> +endchoice
> +endif
> +
> config SYS_BOOTCOUNT_SINGLEWORD
> bool "Use single word to pack boot count and magic value"
> depends on BOOTCOUNT_GENERIC
> @@ -184,26 +207,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
> +config SYS_BOOTCOUNT_FS_INTERFACE
> string "Interface on which to find boot counter EXT filesystem"
Same here.
> 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
> +config SYS_BOOTCOUNT_FS_DEVPART
> string "Partition of the boot counter EXT filesystem"
And here.
> 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
> +config SYS_BOOTCOUNT_FS_NAME
> string "Path and filename of the EXT filesystem based boot counter"
And here. Other than that
Reviewed-by: Philip Oberfichtner <pro@denx.de>
> 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 +234,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
> diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
> index e7771f5b36..c0427434d7 100644
> --- a/drivers/bootcount/Makefile
> +++ b/drivers/bootcount/Makefile
> @@ -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_ext.o
> obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
>
> obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
> diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
> index 9639e638e9..660bea2db2 100644
> --- a/drivers/bootcount/bootcount_ext.c
> +++ b/drivers/bootcount/bootcount_ext.c
> @@ -19,14 +19,20 @@ typedef struct {
>
> static u8 upgrade_available = 1;
>
> +#ifdef BOOTCOUNT_EXT
> +static u8 bootcount_fstype = FS_TYPE_EXT;
> +#else
> +static u8 bootcount_fstype = FS_TYPE_FAT;
> +#endif
> +
> void bootcount_store(ulong a)
> {
> bootcount_ext_t *buf;
> 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, bootcount_fstype)) {
> puts("Error selecting device\n");
> return;
> }
> @@ -42,7 +48,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 +61,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, bootcount_fstype)) {
> 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");
>
> base-commit: c0ea27bccfb7d2d37fd36806ac2a2f7389099420
> --
> 2.34.1
>
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-22 Fax: +49-8142-66989-80 Email: pro@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] drivers: bootcount: Add support for FAT filesystem
2024-06-05 18:10 ` [RFC PATCH] " Vasileios Amoiridis
2024-06-06 7:58 ` Philip Oberfichtner
@ 2024-06-06 15:34 ` Quentin Schulz
2024-06-06 17:33 ` Vasileios Amoiridis
1 sibling, 1 reply; 7+ messages in thread
From: Quentin Schulz @ 2024-06-06 15:34 UTC (permalink / raw)
To: Vasileios Amoiridis, trini, hs, pro; +Cc: vasileios.amoiridis, u-boot
Hi Vasileios,
On 6/5/24 8:10 PM, Vasileios Amoiridis wrote:
> [You don't often get email from vassilisamir@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
>
> Add support to save boot count variable in a file in a FAT filesystem.
>
> Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> ---
> doc/README.bootcount | 12 ++++----
> drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
> drivers/bootcount/Makefile | 2 +-
> drivers/bootcount/bootcount_ext.c | 18 ++++++++----
> 4 files changed, 56 insertions(+), 25 deletions(-)
>
> diff --git a/doc/README.bootcount b/doc/README.bootcount
> index f6c5f82f98..cce66d4d70 100644
> --- a/doc/README.bootcount
> +++ b/doc/README.bootcount
> @@ -23,15 +23,17 @@ 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.
> +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:
>
> diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
> index 3c56253b1e..a39a7556bb 100644
> --- a/drivers/bootcount/Kconfig
> +++ b/drivers/bootcount/Kconfig
> @@ -25,10 +25,9 @@ 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 filesystem"
> + depends on FS_EXT4 || FS_FAT
> help
> Add support for maintaining boot count in a file on an EXT
> filesystem.
> @@ -177,6 +176,30 @@ config BOOTCOUNT_BOOTLIMIT
> counter being cleared.
> If set to 0, do not set a boot limit in the environment.
>
> +if BOOTCOUNT_FS
> +choice
> + prompt "Filesystem type"
> + default BOOTCOUNT_EXT
> +
> +config BOOTCOUNT_EXT
> + bool "Boot counter on EXT filesystem"
> + depends on FS_EXT4
> + select EXT4_WRITE
> + help
> + Add support for maintaining boot count in a file on an EXT
> + filesystem.
> +
> +config BOOTCOUNT_FAT
> + bool "Boot counter on FAT filesystem"
> + depends on FS_FAT
> + select FAT_WRITE
> + help
> + Add support for maintaining boot count in a file on a FAT
> + filesystem.
> +
> +endchoice
> +endif
> +
> config SYS_BOOTCOUNT_SINGLEWORD
> bool "Use single word to pack boot count and magic value"
> depends on BOOTCOUNT_GENERIC
> @@ -184,26 +207,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
> +config SYS_BOOTCOUNT_FS_INTERFACE
> string "Interface on which to find boot counter EXT 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
> +config SYS_BOOTCOUNT_FS_DEVPART
> string "Partition of the boot counter EXT 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
> +config SYS_BOOTCOUNT_FS_NAME
> string "Path and filename of the EXT 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 +234,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
> diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
> index e7771f5b36..c0427434d7 100644
> --- a/drivers/bootcount/Makefile
> +++ b/drivers/bootcount/Makefile
> @@ -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_ext.o
> obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
>
> obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
> diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
> index 9639e638e9..660bea2db2 100644
> --- a/drivers/bootcount/bootcount_ext.c
> +++ b/drivers/bootcount/bootcount_ext.c
> @@ -19,14 +19,20 @@ typedef struct {
>
> static u8 upgrade_available = 1;
>
> +#ifdef BOOTCOUNT_EXT
> +static u8 bootcount_fstype = FS_TYPE_EXT;
> +#else
> +static u8 bootcount_fstype = FS_TYPE_FAT;
> +#endif
> +
I know nothing about filesystems, but I was wondering if we couldn't
just use FS_TYPE_ANY here? Do we really need to specify which FS_TYPE to
use? Are there some limitations, etc.?
Cheers,
Quentin
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] drivers: bootcount: Add support for FAT filesystem
2024-06-06 7:58 ` Philip Oberfichtner
@ 2024-06-06 17:11 ` Vasileios Amoiridis
0 siblings, 0 replies; 7+ messages in thread
From: Vasileios Amoiridis @ 2024-06-06 17:11 UTC (permalink / raw)
To: Philip Oberfichtner
Cc: Vasileios Amoiridis, trini, hs, vasileios.amoiridis, u-boot
On Thu, Jun 06, 2024 at 09:58:36AM +0200, Philip Oberfichtner wrote:
> Hi,
>
> On Wed, Jun 05, 2024 at 08:10:41PM +0200, Vasileios Amoiridis wrote:
> > From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> >
> > Add support to save boot count variable in a file in a FAT filesystem.
> >
> > Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> > ---
> > doc/README.bootcount | 12 ++++----
> > drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
> > drivers/bootcount/Makefile | 2 +-
> > drivers/bootcount/bootcount_ext.c | 18 ++++++++----
> > 4 files changed, 56 insertions(+), 25 deletions(-)
> >
> > diff --git a/doc/README.bootcount b/doc/README.bootcount
> > index f6c5f82f98..cce66d4d70 100644
> > --- a/doc/README.bootcount
> > +++ b/doc/README.bootcount
> > @@ -23,15 +23,17 @@ 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.
> > +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:
> >
> > diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
> > index 3c56253b1e..a39a7556bb 100644
> > --- a/drivers/bootcount/Kconfig
> > +++ b/drivers/bootcount/Kconfig
> > @@ -25,10 +25,9 @@ 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 filesystem"
> > + depends on FS_EXT4 || FS_FAT
> > help
> > Add support for maintaining boot count in a file on an EXT
> > filesystem.
>
> The help message refers to EXT only, not mentioning FAT.
>
Ack.
> > @@ -177,6 +176,30 @@ config BOOTCOUNT_BOOTLIMIT
> > counter being cleared.
> > If set to 0, do not set a boot limit in the environment.
> >
> > +if BOOTCOUNT_FS
> > +choice
> > + prompt "Filesystem type"
> > + default BOOTCOUNT_EXT
> > +
> > +config BOOTCOUNT_EXT
> > + bool "Boot counter on EXT filesystem"
> > + depends on FS_EXT4
> > + select EXT4_WRITE
> > + help
> > + Add support for maintaining boot count in a file on an EXT
> > + filesystem.
> > +
> > +config BOOTCOUNT_FAT
> > + bool "Boot counter on FAT filesystem"
> > + depends on FS_FAT
> > + select FAT_WRITE
> > + help
> > + Add support for maintaining boot count in a file on a FAT
> > + filesystem.
> > +
> > +endchoice
> > +endif
> > +
> > config SYS_BOOTCOUNT_SINGLEWORD
> > bool "Use single word to pack boot count and magic value"
> > depends on BOOTCOUNT_GENERIC
> > @@ -184,26 +207,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
> > +config SYS_BOOTCOUNT_FS_INTERFACE
> > string "Interface on which to find boot counter EXT filesystem"
>
> Same here.
>
Ack.
> > 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
> > +config SYS_BOOTCOUNT_FS_DEVPART
> > string "Partition of the boot counter EXT filesystem"
>
> And here.
>
Ack.
> > 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
> > +config SYS_BOOTCOUNT_FS_NAME
> > string "Path and filename of the EXT filesystem based boot counter"
>
> And here. Other than that
> Reviewed-by: Philip Oberfichtner <pro@denx.de>
>
Ack.
Cheers,
Vasilis
> > 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 +234,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
> > diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
> > index e7771f5b36..c0427434d7 100644
> > --- a/drivers/bootcount/Makefile
> > +++ b/drivers/bootcount/Makefile
> > @@ -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_ext.o
> > obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
> >
> > obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
> > diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
> > index 9639e638e9..660bea2db2 100644
> > --- a/drivers/bootcount/bootcount_ext.c
> > +++ b/drivers/bootcount/bootcount_ext.c
> > @@ -19,14 +19,20 @@ typedef struct {
> >
> > static u8 upgrade_available = 1;
> >
> > +#ifdef BOOTCOUNT_EXT
> > +static u8 bootcount_fstype = FS_TYPE_EXT;
> > +#else
> > +static u8 bootcount_fstype = FS_TYPE_FAT;
> > +#endif
> > +
> > void bootcount_store(ulong a)
> > {
> > bootcount_ext_t *buf;
> > 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, bootcount_fstype)) {
> > puts("Error selecting device\n");
> > return;
> > }
> > @@ -42,7 +48,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 +61,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, bootcount_fstype)) {
> > 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");
> >
> > base-commit: c0ea27bccfb7d2d37fd36806ac2a2f7389099420
> > --
> > 2.34.1
> >
>
> --
> =====================================================================
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-22 Fax: +49-8142-66989-80 Email: pro@denx.de
> =====================================================================
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [RFC PATCH] drivers: bootcount: Add support for FAT filesystem
2024-06-06 15:34 ` Quentin Schulz
@ 2024-06-06 17:33 ` Vasileios Amoiridis
0 siblings, 0 replies; 7+ messages in thread
From: Vasileios Amoiridis @ 2024-06-06 17:33 UTC (permalink / raw)
To: Quentin Schulz
Cc: Vasileios Amoiridis, trini, hs, pro, vasileios.amoiridis, u-boot
On Thu, Jun 06, 2024 at 05:34:55PM +0200, Quentin Schulz wrote:
> Hi Vasileios,
>
> On 6/5/24 8:10 PM, Vasileios Amoiridis wrote:
> > [You don't often get email from vassilisamir@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> >
> > From: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> >
> > Add support to save boot count variable in a file in a FAT filesystem.
> >
> > Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
> > ---
> > doc/README.bootcount | 12 ++++----
> > drivers/bootcount/Kconfig | 49 +++++++++++++++++++++++--------
> > drivers/bootcount/Makefile | 2 +-
> > drivers/bootcount/bootcount_ext.c | 18 ++++++++----
> > 4 files changed, 56 insertions(+), 25 deletions(-)
> >
> > diff --git a/doc/README.bootcount b/doc/README.bootcount
> > index f6c5f82f98..cce66d4d70 100644
> > --- a/doc/README.bootcount
> > +++ b/doc/README.bootcount
> > @@ -23,15 +23,17 @@ 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.
> > +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:
> >
> > diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig
> > index 3c56253b1e..a39a7556bb 100644
> > --- a/drivers/bootcount/Kconfig
> > +++ b/drivers/bootcount/Kconfig
> > @@ -25,10 +25,9 @@ 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 filesystem"
> > + depends on FS_EXT4 || FS_FAT
> > help
> > Add support for maintaining boot count in a file on an EXT
> > filesystem.
> > @@ -177,6 +176,30 @@ config BOOTCOUNT_BOOTLIMIT
> > counter being cleared.
> > If set to 0, do not set a boot limit in the environment.
> >
> > +if BOOTCOUNT_FS
> > +choice
> > + prompt "Filesystem type"
> > + default BOOTCOUNT_EXT
> > +
> > +config BOOTCOUNT_EXT
> > + bool "Boot counter on EXT filesystem"
> > + depends on FS_EXT4
> > + select EXT4_WRITE
> > + help
> > + Add support for maintaining boot count in a file on an EXT
> > + filesystem.
> > +
> > +config BOOTCOUNT_FAT
> > + bool "Boot counter on FAT filesystem"
> > + depends on FS_FAT
> > + select FAT_WRITE
> > + help
> > + Add support for maintaining boot count in a file on a FAT
> > + filesystem.
> > +
> > +endchoice
> > +endif
> > +
> > config SYS_BOOTCOUNT_SINGLEWORD
> > bool "Use single word to pack boot count and magic value"
> > depends on BOOTCOUNT_GENERIC
> > @@ -184,26 +207,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
> > +config SYS_BOOTCOUNT_FS_INTERFACE
> > string "Interface on which to find boot counter EXT 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
> > +config SYS_BOOTCOUNT_FS_DEVPART
> > string "Partition of the boot counter EXT 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
> > +config SYS_BOOTCOUNT_FS_NAME
> > string "Path and filename of the EXT 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 +234,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
> > diff --git a/drivers/bootcount/Makefile b/drivers/bootcount/Makefile
> > index e7771f5b36..c0427434d7 100644
> > --- a/drivers/bootcount/Makefile
> > +++ b/drivers/bootcount/Makefile
> > @@ -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_ext.o
> > obj-$(CONFIG_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
> >
> > obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
> > diff --git a/drivers/bootcount/bootcount_ext.c b/drivers/bootcount/bootcount_ext.c
> > index 9639e638e9..660bea2db2 100644
> > --- a/drivers/bootcount/bootcount_ext.c
> > +++ b/drivers/bootcount/bootcount_ext.c
> > @@ -19,14 +19,20 @@ typedef struct {
> >
> > static u8 upgrade_available = 1;
> >
> > +#ifdef BOOTCOUNT_EXT
> > +static u8 bootcount_fstype = FS_TYPE_EXT;
> > +#else
> > +static u8 bootcount_fstype = FS_TYPE_FAT;
> > +#endif
> > +
>
> I know nothing about filesystems, but I was wondering if we couldn't just
> use FS_TYPE_ANY here? Do we really need to specify which FS_TYPE to use? Are
> there some limitations, etc.?
>
> Cheers,
> Quentin
Well, I am not very accustomed to the U-Boot code yet but by looking at the
fs_set_blk_dev() and fs_write() code, you might be right. I will test with
FS_TYPE_ANY and I will let you know.
Cheers,
Vasilis
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-06-07 6:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-05 18:10 [RFC PATCH 0/1] drivers: bootcount: Add support for FAT filesystem Vasileios Amoiridis
2024-06-05 18:10 ` [RFC PATCH] " Vasileios Amoiridis
2024-06-06 7:58 ` Philip Oberfichtner
2024-06-06 17:11 ` Vasileios Amoiridis
2024-06-06 15:34 ` Quentin Schulz
2024-06-06 17:33 ` Vasileios Amoiridis
2024-06-05 18:48 ` [RFC PATCH 0/1] " Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.