Skip to contentSkip to conversation

environment: Support env from file in a file-system via device tree

PATCH In review Trent Piepho 2 participants 5 messages Dec 11, 2015 – Dec 17, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 environment: Support env from file in a file-system via device tree

Current barebox,environment node only allows specifying a raw device or partition to load an environment from. Some boards, like OMAP and SoCFPGA, instead want to use a file located in a FAT filesystem. Extend the device tree bindings with a new property 'file-path' that will trigger this behavior.

This allows any board using this driver to get the env from a file or from a raw device, instead of each machine type being either raw device only or file only.

---
 .../bindings/barebox/barebox,environment.rst       | 15 ++++++-
 drivers/of/Kconfig                                 |  7 ++++
 drivers/of/barebox.c                               | 47 +++++++++++++++++++++-
 3 files changed, 66 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/barebox/barebox,environment.rst +14 -1
index d5e52ea..12b103b 100644
@@ -6,7 +6,10 @@ This driver provides an environment for barebox from the devicetree.
 Required properties:
 
 * ``compatible``: should be ``barebox,environment``
-* ``device-path``: path to the environment
+* ``device-path``: path to the device environment is on
+
+Optional properties:
+* ``file-path``: path to a file in the device named by device-path
 
 The device-path is a multistring property. The first string should contain
 a nodepath to the node containing the physical device of the environment or
@@ -19,9 +22,19 @@ the path to the environment. Supported values for <type>:
   be the label for MTD partitions, the number for DOS
   partitions (beginning with 0) or the name for GPT partitions.
 
+The file-path is the name of a file located in a FAT filesystem on the
+device named in device-path.  This filesystem will be mounted and the
+environment loaded from the file's location in the directory tree.
+
 Example::
 
   environment@0 {
   	compatible = "barebox,environment";
   	device-path = &flash, "partname:barebox-environment";
   };
+
+  environment@1 {
+  	compatible = "barebox,environment";
+  	device-path = &mmc, "partname:1";
+  	file-path = "barebox.env";
+  };
drivers/of/Kconfig +7 -0
index 90475cf..d0a62bd 100644
@@ -43,3 +43,10 @@ config OF_BAREBOX_DRIVERS
 	  support for this feature. This currently allows to configure the
 	  environment path from devicetree and to partition devices. See
 	  Documentation/devicetree/bindings/barebox/ for more information.
+
+config OF_BAREBOX_ENV_IN_FS
+	depends on OF_BAREBOX_DRIVERS
+	bool "Allow environment to come from file"
+	help
+	  Allow the devie tree configuration of the barebox environment path
+	  to specify a file in filesystem, which will be mounted.
drivers/of/barebox.c +45 -2

60 lines not on this page · raw message

Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

From d8f4428244b3c7009a6ef7d5a97a00747cd19472 Mon Sep 17 00:00:00 2001
From: Trent Piepho <[email protected]>
Date: Fri, 11 Dec 2015 14:19:34 -0800
Subject: [PATCH 2/2] socfpga: Find partition with environment via device tree

socfpga would load the environment from a file named "barebox.env" located on the device "/dev/mmc0.1". Both those names are hard-coded in the socfpga code and can't be changed.

Barebox supports selecting the location of the environment using a "barebox,environment" node in device tree's "chosen" node. And recently supports specifying that the env should come from a file on this device.

Change socfpga to use this mechanism by adding the appropriate device node.

---
 arch/arm/configs/socfpga_defconfig |  1 +
 arch/arm/dts/socfpga.dtsi          |  8 ++++++++
 arch/arm/mach-socfpga/generic.c    | 38 --------------------------------------
 3 files changed, 9 insertions(+), 38 deletions(-)
arch/arm/configs/socfpga_defconfig +1 -0
index 0a31de5..7fbe045 100644
@@ -67,6 +67,7 @@ CONFIG_NET=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_RESOLV=y
 CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_OF_BAREBOX_ENV_IN_FS=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_NET_DESIGNWARE=y
 CONFIG_MCI=y
arch/arm/dts/socfpga.dtsi +8 -0
index d4d498b..d16758f 100644
@@ -1,4 +1,12 @@
 / {
+	chosen {
+		environment@0 {
+			compatible = "barebox,environment";
+			device-path = &mmc, "partname:1";
+			file-path = "barebox.env";
+		};
+	};
+
 	aliases {
 		mmc0 = &mmc;
 	};
arch/arm/mach-socfpga/generic.c +0 -38
index 2d4afd0..906bc63 100644
@@ -103,41 +103,3 @@ static int socfpga_init(void)
 	return 0;
 }
 core_initcall(socfpga_init);
-
-#if defined(CONFIG_ENV_HANDLING)
-#define ENV_PATH "/boot/barebox.env"
-static int socfpga_env_init(void)
-{
-	struct stat s;
-	char *diskdev, *partname;
-	int ret;
-
-	diskdev = "mmc0";
-
-	device_detect_by_name(diskdev);
-
-	partname = asprintf("/dev/%s.1", diskdev);
-
-	ret = stat(partname, &s);
-
-	if (ret) {
-		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) {
-		pr_err("Failed to load environment: mount %s failed (%d)\n", partname, ret);
-		goto out_free;
-	}
-
-	pr_debug("Loading default env from %s on device %s\n", ENV_PATH, diskdev);
-	default_environment_path_set(ENV_PATH);
-
-out_free:
-	free(partname);
-	return 0;
-}
-late_initcall(socfpga_env_init);
-#endif
Signature · 7 lines
1.8.3.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw
Quoted 4 lines · Trent Piepho

From d8f4428244b3c7009a6ef7d5a97a00747cd19472 Mon Sep 17 00:00:00 2001
From: Trent Piepho <[email protected]>
Date: Fri, 11 Dec 2015 14:19:34 -0800
Subject: [PATCH 2/2] socfpga: Find partition with environment via device tree

The subject in this mail is wrong. The correct subject is here, but 'git am' takes the one from the mail.

I thought over it and I am fine with the approach of putting the filename as an additional property into the barebox,environment node.

Also I am fine with the "of_path: Fix bug with partitions, simply code" patch, only I can not find the commitish that broke the partition code.

I somewhat lost track over your outstanding patches. Could you resend all of them in a single series?

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
Quoted 8 lines · Sascha Hauer
Quoted 4 lines · Trent Piepho

From d8f4428244b3c7009a6ef7d5a97a00747cd19472 Mon Sep 17 00:00:00 2001
From: Trent Piepho <[email protected]>
Date: Fri, 11 Dec 2015 14:19:34 -0800
Subject: [PATCH 2/2] socfpga: Find partition with environment via device tree

The subject in this mail is wrong. The correct subject is here, but 'git am' takes the one from the mail.

IMAP and POP aren't supported at work so I can't use git send-email and must instead manually import the patches into a mailer that supports EWS. I must have forgotten to copy the subject on that one.

Quoted 5 lines

I thought over it and I am fine with the approach of putting the filename as an additional property into the barebox,environment node.

Also I am fine with the "of_path: Fix bug with partitions, simply code" patch, only I can not find the commitish that broke the partition code.

I used my local rebased branch by mistake, it should have been 75b682795eafb2385556a9642f09e0af96a1264a

Quoted 2 lines

I somewhat lost track over your outstanding patches. Could you resend all of them in a single series?

Ok. Have you considered using patchwork for this list? I've found it pretty useful for keeping track of patches.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#4 lore raw
Quoted 20 lines · Trent Piepho
Quoted 8 lines · Sascha Hauer
Quoted 4 lines · Trent Piepho

From d8f4428244b3c7009a6ef7d5a97a00747cd19472 Mon Sep 17 00:00:00 2001
From: Trent Piepho <[email protected]>
Date: Fri, 11 Dec 2015 14:19:34 -0800
Subject: [PATCH 2/2] socfpga: Find partition with environment via device tree

The subject in this mail is wrong. The correct subject is here, but 'git am' takes the one from the mail.

IMAP and POP aren't supported at work so I can't use git send-email and must instead manually import the patches into a mailer that supports EWS. I must have forgotten to copy the subject on that one.

Quoted 5 lines

I thought over it and I am fine with the approach of putting the filename as an additional property into the barebox,environment node.

Also I am fine with the "of_path: Fix bug with partitions, simply code" patch, only I can not find the commitish that broke the partition code.

Quoted 8 lines

I used my local rebased branch by mistake, it should have been 75b682795eafb2385556a9642f09e0af96a1264a

Quoted 2 lines

I somewhat lost track over your outstanding patches. Could you resend all of them in a single series?

Ok. Have you considered using patchwork for this list? I've found it pretty useful for keeping track of patches.

I have tried it a few years ago, but never got really warm with it. patchwork requires some maintenance and usually I am quite happy with my workflow. Only sometimes when there are several updates to a patch, patches that do not really depend on each other but are still somehow related with each other it feels better when everything is resent freshly.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox