mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Trent Piepho <tpiepho@kymetacorp.com>
To: barebox <barebox@lists.infradead.org>
Subject: [PATCH] omap socfpga: Switch in flash env loading to use different config
Date: Wed, 4 Nov 2015 21:10:20 +0000	[thread overview]
Message-ID: <1446671421.4553.5.camel@rtred1test09.kymeta.local> (raw)

On these systems, the base arch has code to load the in flash
environment from a file located in a FAT filesystem.  This was
controlled by the config option DEFAULT_ENVIRONMENT.  However, that
option turns on compiling the env into the barebox binary itself, as a
backup if the in flash env can't be loaded.

Most other boards have in flash env support unconditionally.  But omap
and socfpga also have xloader configurations, which aren't supposed to
have environment support, either in flash or compiled in.  If the in
flash env code were unconditional, then the xloaders would gain it.

So the code depends on ENV_HANDLING, which is only set on those boards
that are supposed to have an in flash env and not set on all the
boards that aren't supposed to have it.

If someone wanted to create a board that did have a saved env, but
used an alternate to this generic omap/socfpga file in FAT method,
then they'd probably want to create a new config option to control
this code and have it not be enabled for their board.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
---

I tested all existing OMAP defconfigs, and omap_env_init's presence or
absence is unchanged after this patch.

 arch/arm/mach-omap/omap_generic.c | 10 ++++++----
 arch/arm/mach-socfpga/generic.c   | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap/omap_generic.c b/arch/arm/mach-omap/omap_generic.c
index 165487c..071a1bf 100644
--- a/arch/arm/mach-omap/omap_generic.c
+++ b/arch/arm/mach-omap/omap_generic.c
@@ -107,7 +107,8 @@ const char *omap_get_bootmmc_devname(void)
 	return omap_bootmmc_dev;
 }
 
-#if defined(CONFIG_DEFAULT_ENVIRONMENT)
+#if defined(CONFIG_ENV_HANDLING)
+#define ENV_PATH "/boot/barebox.env"
 static int omap_env_init(void)
 {
 	struct stat s;
@@ -132,18 +133,19 @@ static int omap_env_init(void)
 	free(partname);
 
 	if (ret) {
-		printf("no %s. using default env\n", diskdev);
+		pr_err("Failed to load environment: no device '%s'\n", diskdev);
 		return 0;
 	}
 
 	mkdir("/boot", 0666);
 	ret = mount(diskdev, "fat", "/boot", NULL);
 	if (ret) {
-		printf("failed to mount %s\n", diskdev);
+		pr_err("Failed to load environment: mount %s failed (%d)\n", diskdev, ret);
 		return 0;
 	}
 
-	default_environment_path_set("/boot/barebox.env");
+	pr_debug("Loading default env from %s on device %s\n", ENV_PATH, diskdev);
+	default_environment_path_set(ENV_PATH);
 
 	return 0;
 }
diff --git a/arch/arm/mach-socfpga/generic.c b/arch/arm/mach-socfpga/generic.c
index 6259354..234dc52 100644
--- a/arch/arm/mach-socfpga/generic.c
+++ b/arch/arm/mach-socfpga/generic.c
@@ -76,7 +76,8 @@ static int socfpga_init(void)
 }
 core_initcall(socfpga_init);
 
-#if defined(CONFIG_DEFAULT_ENVIRONMENT)
+#if defined(CONFIG_ENV_HANDLING)
+#define ENV_PATH "/boot/barebox.env"
 static int socfpga_env_init(void)
 {
 	struct stat s;
@@ -92,18 +93,19 @@ static int socfpga_env_init(void)
 	ret = stat(partname, &s);
 
 	if (ret) {
-		printf("no %s. using default env\n", diskdev);
+		pr_err("Failed to load environment: no device '%s'\n", diskdev);
 		goto out_free;
 	}
 
 	mkdir("/boot", 0666);
 	ret = mount(partname, "fat", "/boot", NULL);
 	if (ret) {
-		printf("failed to mount %s\n", diskdev);
+		pr_err("Failed to load environment: mount %s failed (%d)\n", partname, ret);
 		goto out_free;
 	}
 
-	default_environment_path_set("/boot/barebox.env");
+	pr_debug("Loading default env from %s on device %s\n", ENV_PATH, diskdev);
+	default_environment_path_set(ENV_PATH);
 
 out_free:
 	free(partname);
-- 
1.8.3.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-11-04 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 21:10 Trent Piepho [this message]
2015-11-05  8:03 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446671421.4553.5.camel@rtred1test09.kymeta.local \
    --to=tpiepho@kymetacorp.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox