From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] ARM: k3: implement environment handling
Date: Tue, 12 Nov 2024 10:01:25 +0100 [thread overview]
Message-ID: <20241112090125.3457278-1-s.hauer@pengutronix.de> (raw)
When booting from SD/eMMC TI SoCs start from a FAT partition. mount this
partition to /boot and put the barebox environment there.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-k3/common.c | 60 +++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 0da6f76ae4..13f3f5e169 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -3,6 +3,10 @@
#include <io.h>
#include <deep-probe.h>
#include <init.h>
+#include <envfs.h>
+#include <fs.h>
+#include <xfuncs.h>
+#include <malloc.h>
#include <pm_domain.h>
#include <bootsource.h>
#include <linux/bits.h>
@@ -183,3 +187,59 @@ static int am625_init(void)
return 0;
}
postcore_initcall(am625_init);
+
+#if defined(CONFIG_ENV_HANDLING)
+static int omap_env_init(void)
+{
+ char *partname, *cdevname, *envpath;
+ struct cdev *cdev;
+ const char *rootpath;
+ int instance;
+
+ if (!of_machine_is_compatible("ti,am625"))
+ return 0;
+
+ if (bootsource_get() != BOOTSOURCE_MMC)
+ return 0;
+
+ instance = bootsource_get_instance();
+
+ cdevname = xasprintf("mmc%d", instance);
+ partname = xasprintf("mmc%d.0", instance);
+
+ device_detect_by_name(cdevname);
+
+ cdev = cdev_open_by_name(partname, O_RDONLY);
+ if (!cdev) {
+ pr_err("Failed to get device %s\n", partname);
+ goto out;
+ }
+
+ rootpath = cdev_mount_default(cdev, NULL);
+
+ cdev_close(cdev);
+
+ if (IS_ERR(rootpath)) {
+ pr_err("Failed to load environment: mount %s failed (%ld)\n",
+ cdev->name, PTR_ERR(rootpath));
+ goto out;
+ }
+
+ symlink(rootpath, "/boot");
+
+ envpath = xasprintf("%s/barebox.env", rootpath);
+
+ pr_debug("Loading default env from %s on device %s\n",
+ envpath, partname);
+
+ default_environment_path_set(envpath);
+
+ free(envpath);
+out:
+ free(partname);
+ free(cdevname);
+
+ return 0;
+}
+late_initcall(omap_env_init);
+#endif
--
2.39.5
next reply other threads:[~2024-11-12 9:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-12 9:01 Sascha Hauer [this message]
2024-11-13 11:33 ` 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=20241112090125.3457278-1-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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