aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorHamish Guthrie <hamish.guthrie@kistler.com>2019-05-15 15:15:59 +0200
committerHeiko Schocher <hs@denx.de>2019-07-09 07:00:25 +0200
commit6ea31cce0b63398e2a5228d685175bbc63e9072c (patch)
treec2c228967160253bdbc3413abac1e6ab4faf9add /common
parent4bae76d7331cf959af2c35254260476d098d2846 (diff)
downloadu-boot-6ea31cce0b63398e2a5228d685175bbc63e9072c.zip
u-boot-6ea31cce0b63398e2a5228d685175bbc63e9072c.tar.gz
u-boot-6ea31cce0b63398e2a5228d685175bbc63e9072c.tar.bz2
ubispl: add support for loading volumes by name
The motivation is to use the UBI atomic volume rename functionality to allow double copy software updates on UBI. To that end the SPL is configured to always load the same volume name (e.g. "u-boot"), whereas a software updater always installs into the secondary volume "u-boot_r". After successful installation, these two volume names are switched. This extension is protected by #ifdefs as it will somewhat slow down loading of volumes by id. This is because the code needs to disable the optimization of ignoring all volume ids which are not to-be-loaded, since these can only be resolved after attaching. This adds two vtbl related functions from Linux, which are taken from the same kernel version as the current main U-Boot UBI code (Linux 4.2 64291f7db5bd8). Signed-off-by: Hamish Guthrie <hamish.guthrie@kistler.com> Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com> Reviewed-by: Heiko Schocher <hs@denx.de> Cc: Kyungmin Park <kmpark@infradead.org>
Diffstat (limited to 'common')
-rw-r--r--common/spl/Kconfig13
-rw-r--r--common/spl/spl_ubi.c7
2 files changed, 20 insertions, 0 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 31eac5a..716b1ec 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -620,6 +620,13 @@ config SPL_UBI
README.ubispl for more info.
if SPL_UBI
+config SPL_UBI_LOAD_BY_VOLNAME
+ bool "Support loading volumes by name"
+ help
+ This enables support for loading UBI volumes by name. When this
+ is set, CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME can be used to
+ configure the volume name from which to load U-Boot.
+
config SPL_UBI_MAX_VOL_LEBS
int "Maximum number of LEBs per volume"
depends on SPL_UBI
@@ -677,6 +684,12 @@ config SPL_UBI_LOAD_MONITOR_ID
help
The UBI volume id from which to load U-Boot
+config SPL_UBI_LOAD_MONITOR_VOLNAME
+ string "volume name of U-Boot volume"
+ depends on SPL_UBI_LOAD_BY_VOLNAME
+ help
+ The UBI volume name from which to load U-Boot
+
config SPL_UBI_LOAD_KERNEL_ID
int "id of kernel volume"
depends on SPL_OS_BOOT && SPL_UBI
diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index 67e5fad..0cb5080 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -62,7 +62,14 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
}
#endif
header = spl_get_load_buffer(-sizeof(*header), sizeof(header));
+#ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME
+ volumes[0].vol_id = -1;
+ strncpy(volumes[0].name,
+ CONFIG_SPL_UBI_LOAD_MONITOR_VOLNAME,
+ UBI_VOL_NAME_MAX + 1);
+#else
volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_MONITOR_ID;
+#endif
volumes[0].load_addr = (void *)header;
ret = ubispl_load_volumes(&info, volumes, 1);