drivers: bootcount: Add support for FAT filesystem
cover drivers: bootcount: Add support for FAT filesystem
From: Vasileios Amoiridis <[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
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
Signature · 1 line
2.34.1
Quoted 8 lines · Vasileios Amoiridis
From: Vasileios Amoiridis <[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?
Yeah, lets call it bootcount_fs.c ? It otherwise all looks good to me, thanks!
Signature · 1 line
Tom
RFC PATCH 1/1 drivers: bootcount: Add support for FAT filesystem
In reply to Vasileios AmoiridisFrom: Vasileios Amoiridis <[email protected]>
Add support to save boot count variable in a file in a 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(-)
doc/README.bootcount +7 -5
@@ -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:
drivers/bootcount/Kconfig +36 -13
96 lines not on this page · raw message
drivers/bootcount/Makefile +1 -1
@@ -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
drivers/bootcount/bootcount_ext.c +12 -6
@@ -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
Signature · 1 line
2.34.1
Hi,
Quoted 47 lines · Vasileios Amoiridis
From: Vasileios Amoiridis <[email protected]>
Add support to save boot count variable in a file in a FAT filesystem.
Signed-off-by Vasileios Amoiridis <[email protected]>--- 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(-)doc/README.bootcount +7
-5@@ -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:drivers/bootcount/Kconfig +0
-0@@ -25,10 +25,9 @@ config BOOTCOUNT_GENERIC Set to the address where the bootcount and bootcount magic will be stored.
drivers/bootcount/Kconfig config BOOTCOUNT_GENERIC · line 33
Quoted 10 lines
drivers/bootcount/Kconfig +3
-4-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.
Quoted 32 lines
drivers/bootcount/Kconfig +24
-0@@ -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
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 211
Quoted 6 lines
drivers/bootcount/Kconfig +1
-1@@ -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.
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 219
Quoted 10 lines
drivers/bootcount/Kconfig +2
-2default "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.
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 227
Quoted 10 lines
drivers/bootcount/Kconfig +2
-2default "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
Quoted 99 lines
drivers/bootcount/Kconfig +4
-4default "/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_NVMEMdrivers/bootcount/Makefile +1
-1@@ -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.odrivers/bootcount/bootcount_ext.c +12
-6@@ -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:
c0ea27bccfb7d2d37fd36806ac2a2f7389099420Signature · 1 line
2.34.1
Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
Quoted 50 lines · Philip Oberfichtner
Hi,
Quoted 47 lines · Vasileios Amoiridis
From: Vasileios Amoiridis <[email protected]>
Add support to save boot count variable in a file in a FAT filesystem.
Signed-off-by Vasileios Amoiridis <[email protected]>--- 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(-)doc/README.bootcount +7
-5@@ -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:drivers/bootcount/Kconfig +0
-0@@ -25,10 +25,9 @@ config BOOTCOUNT_GENERIC Set to the address where the bootcount and bootcount magic will be stored.
Quoted 13 lines
drivers/bootcount/Kconfig config BOOTCOUNT_GENERIC · line 33
Quoted 10 lines
drivers/bootcount/Kconfig +3
-4-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.
Quoted 35 lines
Quoted 35 lines
drivers/bootcount/Kconfig +24
-0@@ -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).
Quoted 6 lines
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 211
Quoted 3 lines
drivers/bootcount/Kconfig +1
-1-config SYS_BOOTCOUNT_EXT_INTERFACE +config SYS_BOOTCOUNT_FS_INTERFACE string "Interface on which to find boot counter EXT filesystem"Same here.
Ack.
Quoted 7 lines
Quoted 7 lines
drivers/bootcount/Kconfig +1
-1default "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.
Quoted 6 lines
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 219
Quoted 3 lines
drivers/bootcount/Kconfig +1
-1-config SYS_BOOTCOUNT_EXT_DEVPART +config SYS_BOOTCOUNT_FS_DEVPART string "Partition of the boot counter EXT filesystem"And here.
Ack.
Quoted 7 lines
Quoted 7 lines
drivers/bootcount/Kconfig +1
-1default "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.
Quoted 7 lines
drivers/bootcount/Kconfig config SYS_BOOTCOUNT_SINGLEWORD · line 227
Quoted 3 lines
drivers/bootcount/Kconfig +1
-1-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 <[email protected]>
Ack.
Cheers,
Vasilis
Quoted 106 lines
Quoted 99 lines
drivers/bootcount/Kconfig +4
-4default "/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_NVMEMdrivers/bootcount/Makefile +1
-1@@ -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.odrivers/bootcount/bootcount_ext.c +12
-6@@ -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:
c0ea27bccfb7d2d37fd36806ac2a2f7389099420Signature · 1 line
2.34.1Signature · 5 lines
===================================================================== 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: [email protected] =====================================================================
Hi Vasileios,
Quoted 163 lines · Vasileios Amoiridis
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
From: Vasileios Amoiridis <[email protected]>
Add support to save boot count variable in a file in a FAT filesystem.
Signed-off-by Vasileios Amoiridis <[email protected]>--- 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(-)doc/README.bootcount +7
-5@@ -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:drivers/bootcount/Kconfig +36
-13@@ -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_NVMEMdrivers/bootcount/Makefile +1
-1@@ -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.odrivers/bootcount/bootcount_ext.c +0
-0
drivers/bootcount/bootcount_ext.c typedef struct { · line 27
Quoted 9 lines
drivers/bootcount/bootcount_ext.c +6
-0@@ -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
Quoted 180 lines · Quentin Schulz
Hi Vasileios,
Quoted 163 lines · Vasileios Amoiridis
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
From: Vasileios Amoiridis <[email protected]>
Add support to save boot count variable in a file in a FAT filesystem.
Signed-off-by Vasileios Amoiridis <[email protected]>--- 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(-)doc/README.bootcount +7
-5@@ -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:drivers/bootcount/Kconfig +36
-13@@ -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_NVMEMdrivers/bootcount/Makefile +1
-1@@ -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.odrivers/bootcount/bootcount_ext.c +0
-0drivers/bootcount/bootcount_ext.c typedef struct { · line 27
Quoted 9 lines
drivers/bootcount/bootcount_ext.c +6
-0@@ -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_ANYhere? Do we really need to specify whichFS_TYPEto use? Are there some limitations, etc.?
Quoted 2 lines
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