[PATCH 2/2] ARM OMAP: add support for loading Environment from UBI

Christoph Fritz chf.fritz at googlemail.com
Fri Jun 21 05:55:56 EDT 2013


This patch adds support to load environment from a static
UBI volume.

Signed-off-by: Christoph Fritz <chf.fritz at googlemail.com>
---
 common/Kconfig   |   34 ++++++++++++++++++++++++++++++++++
 common/startup.c |   17 +++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index d36ed13..058eb21 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -103,6 +103,40 @@ config MEMINFO
 config ENVIRONMENT_VARIABLES
 	bool "environment variables support"
 
+config ENVIRONMENT_IN_UBI
+	bool "Load Environment from an UBI static volume"
+	depends on UBI
+	depends on ENV_HANDLING
+	help
+	  Say Y here if you would like to attach UBI and load
+	  the environment from an UBI volume.
+
+if ENVIRONMENT_IN_UBI
+
+menu "Configure Loading Environment from UBI"
+
+config ENV_IN_UBI_PARTITION
+	string
+	default "/dev/root"
+	prompt "Filepath of mtd partition holding UBI volumes"
+	help
+	  Filepath of mtd partition holding UBI static volume with Barebox
+	  environment inside.  This value depends on your board partition
+	  layout. Default string value is "/dev/root".
+
+config ENV_IN_UBI_VOLNAME
+	string
+	default "/dev/ubi0.bareboxenv_0"
+	prompt "Filepath of UBI static volume holding environment"
+	help
+	  Filepath of UBI static volume holding Barebox environment inside the
+	  partition. This string value depends on your UBI volume name
+	  configuration scheme. Default string is "/dev/ubi0.bareboxenv_0".
+
+endmenu
+
+endif
+
 menu "memory layout"
 
 source "pbl/Kconfig"
diff --git a/common/startup.c b/common/startup.c
index ff00ca7..01c0e1d 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -117,6 +117,23 @@ void __noreturn start_barebox(void)
 	if (IS_ENABLED(CONFIG_ENV_HANDLING)) {
 		int ret;
 
+		if (IS_ENABLED(CONFIG_ENVIRONMENT_IN_UBI)) {
+#ifdef CONFIG_ENVIRONMENT_IN_UBI
+			char s[PATH_MAX + 32];
+			sprintf(s, "%s%s ", "ubiattach ",
+				CONFIG_ENV_IN_UBI_PARTITION);
+			ret = run_command(s, 0);
+			if (ret) {
+				sprintf(s, "%s%s ", "unable to ubiattach ",
+					CONFIG_ENV_IN_UBI_PARTITION);
+				pr_err(s);
+			} else {
+				default_environment_path =
+					CONFIG_ENV_IN_UBI_VOLNAME;
+			}
+#endif
+		}
+
 		ret = envfs_load(default_environment_path, "/env", 0);
 
 		if (ret && IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT)) {
-- 
1.7.10.4





More information about the barebox mailing list