mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-24 22:36:05 +00:00
drivers: bootcount: Add support for ANY filesystem
Add support to save boot count variable in ANY filesystem. Tested with FAT and EXT. Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Heiko Schocher <hs@denx.de> Reviewed-by: Philip Oberfichtner <pro@denx.de> Signed-off-by: Vasileios Amoiridis <vasileios.amoiridis@cern.ch>
This commit is contained in:
parent
c53b344475
commit
1d7e2120af
4 changed files with 31 additions and 31 deletions
|
@ -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
|
application) to reset the variable "bootcount" to 0 when the system booted
|
||||||
successfully, thus allowing for more boot cycles.
|
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.
|
||||||
The file to use is defined by:
|
Supported filesystems are FAT and EXT. The file to use is defined by:
|
||||||
|
|
||||||
CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE
|
CONFIG_SYS_BOOTCOUNT_FS_INTERFACE
|
||||||
CONFIG_SYS_BOOTCOUNT_EXT_DEVPART
|
CONFIG_SYS_BOOTCOUNT_FS_DEVPART
|
||||||
CONFIG_SYS_BOOTCOUNT_EXT_NAME
|
CONFIG_SYS_BOOTCOUNT_FS_NAME
|
||||||
|
|
||||||
The format of the file is:
|
The format of the file is:
|
||||||
|
|
||||||
|
|
|
@ -25,13 +25,13 @@ config BOOTCOUNT_GENERIC
|
||||||
Set to the address where the bootcount and bootcount magic
|
Set to the address where the bootcount and bootcount magic
|
||||||
will be stored.
|
will be stored.
|
||||||
|
|
||||||
config BOOTCOUNT_EXT
|
config BOOTCOUNT_FS
|
||||||
bool "Boot counter on EXT filesystem"
|
bool "Boot counter on a filesystem"
|
||||||
depends on FS_EXT4
|
|
||||||
select EXT4_WRITE
|
|
||||||
help
|
help
|
||||||
Add support for maintaining boot count in a file on an EXT
|
Add support for maintaining boot count in a file on a filesystem.
|
||||||
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
|
config BOOTCOUNT_AM33XX
|
||||||
bool "Boot counter in AM33XX RTC IP block"
|
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
|
This option enables packing boot count magic value and boot count
|
||||||
into single word (32 bits).
|
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"
|
string "Interface on which to find boot counter filesystem"
|
||||||
default "mmc"
|
default "mmc"
|
||||||
depends on BOOTCOUNT_EXT
|
depends on BOOTCOUNT_FS
|
||||||
help
|
help
|
||||||
Set the interface to use when locating the filesystem to use for the
|
Set the interface to use when locating the filesystem to use for the
|
||||||
boot counter.
|
boot counter.
|
||||||
|
|
||||||
config SYS_BOOTCOUNT_EXT_DEVPART
|
config SYS_BOOTCOUNT_FS_DEVPART
|
||||||
string "Partition of the boot counter EXT filesystem"
|
string "Partition of the boot counter filesystem"
|
||||||
default "0:1"
|
default "0:1"
|
||||||
depends on BOOTCOUNT_EXT
|
depends on BOOTCOUNT_FS
|
||||||
help
|
help
|
||||||
Set the partition to use when locating the filesystem to use for the
|
Set the partition to use when locating the filesystem to use for the
|
||||||
boot counter.
|
boot counter.
|
||||||
|
|
||||||
config SYS_BOOTCOUNT_EXT_NAME
|
config SYS_BOOTCOUNT_FS_NAME
|
||||||
string "Path and filename of the EXT filesystem based boot counter"
|
string "Path and filename of the FS filesystem based boot counter"
|
||||||
default "/boot/failures"
|
default "/boot/failures"
|
||||||
depends on BOOTCOUNT_EXT
|
depends on BOOTCOUNT_FS
|
||||||
help
|
help
|
||||||
Set the filename and path of the file used to store the boot counter.
|
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"
|
hex "RAM address used for reading and writing the boot counter"
|
||||||
default 0x44E3E000 if BOOTCOUNT_AM33XX || BOOTCOUNT_AM33XX_NVMEM
|
default 0x44E3E000 if BOOTCOUNT_AM33XX || BOOTCOUNT_AM33XX_NVMEM
|
||||||
default 0xE0115FF8 if ARCH_LS1043A || ARCH_LS1021A
|
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
|
BOOTCOUNT_AM33XX_NVMEM
|
||||||
help
|
help
|
||||||
Set the address used for reading and writing the boot counter.
|
Set the address used for reading and writing the boot counter.
|
||||||
|
|
||||||
config SYS_BOOTCOUNT_MAGIC
|
config SYS_BOOTCOUNT_MAGIC
|
||||||
hex "Magic value for the boot counter"
|
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_AM33XX || BOOTCOUNT_ENV || \
|
||||||
BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT
|
BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT
|
||||||
default 0xB0 if BOOTCOUNT_AM33XX_NVMEM
|
default 0xB0 if BOOTCOUNT_AM33XX_NVMEM
|
||||||
depends on BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
|
depends on BOOTCOUNT_GENERIC || BOOTCOUNT_FS || \
|
||||||
BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
|
BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
|
||||||
BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT || \
|
BOOTCOUNT_RAM || BOOTCOUNT_AT91 || DM_BOOTCOUNT || \
|
||||||
BOOTCOUNT_AM33XX_NVMEM
|
BOOTCOUNT_AM33XX_NVMEM
|
||||||
|
|
|
@ -6,7 +6,7 @@ obj-$(CONFIG_BOOTCOUNT_AT91) += bootcount_at91.o
|
||||||
obj-$(CONFIG_BOOTCOUNT_AM33XX) += bootcount_davinci.o
|
obj-$(CONFIG_BOOTCOUNT_AM33XX) += bootcount_davinci.o
|
||||||
obj-$(CONFIG_BOOTCOUNT_RAM) += bootcount_ram.o
|
obj-$(CONFIG_BOOTCOUNT_RAM) += bootcount_ram.o
|
||||||
obj-$(CONFIG_BOOTCOUNT_ENV) += bootcount_env.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_BOOTCOUNT_AM33XX_NVMEM) += bootcount_nvmem.o
|
||||||
|
|
||||||
obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
|
obj-$(CONFIG_DM_BOOTCOUNT) += bootcount-uclass.o
|
||||||
|
|
|
@ -25,8 +25,8 @@ void bootcount_store(ulong a)
|
||||||
loff_t len;
|
loff_t len;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE,
|
if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_FS_INTERFACE,
|
||||||
CONFIG_SYS_BOOTCOUNT_EXT_DEVPART, FS_TYPE_EXT)) {
|
CONFIG_SYS_BOOTCOUNT_FS_DEVPART, FS_TYPE_ANY)) {
|
||||||
puts("Error selecting device\n");
|
puts("Error selecting device\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void bootcount_store(ulong a)
|
||||||
buf->upgrade_available = upgrade_available;
|
buf->upgrade_available = upgrade_available;
|
||||||
unmap_sysmem(buf);
|
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),
|
CONFIG_SYS_BOOTCOUNT_ADDR, 0, sizeof(bootcount_ext_t),
|
||||||
&len);
|
&len);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
@ -55,13 +55,13 @@ ulong bootcount_load(void)
|
||||||
loff_t len_read;
|
loff_t len_read;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE,
|
if (fs_set_blk_dev(CONFIG_SYS_BOOTCOUNT_FS_INTERFACE,
|
||||||
CONFIG_SYS_BOOTCOUNT_EXT_DEVPART, FS_TYPE_EXT)) {
|
CONFIG_SYS_BOOTCOUNT_FS_DEVPART, FS_TYPE_ANY)) {
|
||||||
puts("Error selecting device\n");
|
puts("Error selecting device\n");
|
||||||
return 0;
|
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);
|
0, sizeof(bootcount_ext_t), &len_read);
|
||||||
if (ret != 0 || len_read != sizeof(bootcount_ext_t)) {
|
if (ret != 0 || len_read != sizeof(bootcount_ext_t)) {
|
||||||
puts("Error loading bootcount\n");
|
puts("Error loading bootcount\n");
|
Loading…
Add table
Reference in a new issue