All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
@ 2017-09-04 20:12 Pantelis Antoniou
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
                   ` (14 more replies)
  0 siblings, 15 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

This patchset allows uboot to handle overlays in a manner that uses
a base DT blob and an arbitrary number of DT overlays blobs.

While it is intended to be used with FIT images since handling a multitude
of device tree blobs manually is a chore, manual fdt overlay application
is supported and described.

Changes since v2:
* Addressed review comments by splitting patches and documenting methods.
* Patch preserving extra configuration on fit-load

The patchset is available at

	https://github.com/pantoniou/u-boot/tree/uboot-overlays

and is against mainline u-boot as pulled today, 4/9/2017.

Franklin S Cooper Jr (1):
  doc: overlays: Tweak documentation regarding overlays

Pantelis Antoniou (13):
  Introduce fdt_setprop_placeholder() method
  fdt: Introduce helper method fdt_overlay_apply_verbose()
  fdt: Switch to using the verbose overlay application method
  fdt: Allow stacked overlays phandle references
  fit: Allow multiple images per property
  fit: Do not throw away extra configuration on fit_image_load()
  fit: Introduce methods for applying overlays on fit-load
  fit: fdt overlays doc
  doc: Document how to apply fdt overlays
  dtbo: make dtbos special
  config: sandbox: Add unit tests
  ut: fix fdt_getprop_u32() change
  test: overlay: Add unit test for stacked overlay

 cmd/fdt.c                                    |   7 +-
 common/fdt_support.c                         |  31 ++++
 common/image-fdt.c                           |   7 +-
 common/image-fit.c                           | 210 ++++++++++++++++++++++--
 configs/sandbox_defconfig                    |   2 +
 doc/README.fdt-overlays                      | 114 ++++++++++++++
 doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
 doc/uImage.FIT/overlay-fdt-boot.txt          | 225 ++++++++++++++++++++++++++
 doc/uImage.FIT/source_file_format.txt        |   6 +-
 include/fdt_support.h                        |   2 +
 include/image.h                              |  25 +++
 lib/libfdt/fdt_overlay.c                     | 228 ++++++++++++++++++++++++---
 lib/libfdt/fdt_rw.c                          |  20 ++-
 lib/libfdt/libfdt.h                          |  31 ++++
 scripts/Makefile.lib                         |  17 ++
 test/overlay/Makefile                        |   1 +
 test/overlay/cmd_ut_overlay.c                |  50 ++++--
 test/overlay/test-fdt-overlay-stacked.dts    |  21 +++
 18 files changed, 953 insertions(+), 56 deletions(-)
 create mode 100644 doc/README.fdt-overlays
 create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
 create mode 100644 test/overlay/test-fdt-overlay-stacked.dts

-- 
2.1.4

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:25   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose() Pantelis Antoniou
                   ` (13 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

In some cases you need to add a property but the contents of it
are not known at creation time, merely the extend of it.

This method allows you to create a property of a given size (filled
with garbage) while a pointer to the property data will be provided.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[dwg: Corrected commit message]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 lib/libfdt/fdt_rw.c | 20 +++++++++++++++++---
 lib/libfdt/libfdt.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index 80a3212..3dc7752 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -228,8 +228,8 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name)
 	return 0;
 }
 
-int fdt_setprop(void *fdt, int nodeoffset, const char *name,
-		const void *val, int len)
+int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
+			    int len, void **prop_data)
 {
 	struct fdt_property *prop;
 	int err;
@@ -242,8 +242,22 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 	if (err)
 		return err;
 
+	*prop_data = prop->data;
+	return 0;
+}
+
+int fdt_setprop(void *fdt, int nodeoffset, const char *name,
+		const void *val, int len)
+{
+	void *prop_data;
+	int err;
+
+	err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data);
+	if (err)
+		return err;
+
 	if (len)
-		memcpy(prop->data, val, len);
+		memcpy(prop_data, val, len);
 	return 0;
 }
 
diff --git a/lib/libfdt/libfdt.h b/lib/libfdt/libfdt.h
index f3f9cad..6af94cb 100644
--- a/lib/libfdt/libfdt.h
+++ b/lib/libfdt/libfdt.h
@@ -1405,6 +1405,37 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 		const void *val, int len);
 
 /**
+ * fdt_setprop _placeholder - allocate space for a property
+ * @fdt: pointer to the device tree blob
+ * @nodeoffset: offset of the node whose property to change
+ * @name: name of the property to change
+ * @len: length of the property value
+ * @prop_data: return pointer to property data
+ *
+ * fdt_setprop_placeholer() allocates the named property in the given node.
+ * If the property exists it is resized. In either case a pointer to the
+ * property data is returned.
+ *
+ * This function may insert or delete data from the blob, and will
+ * therefore change the offsets of some existing nodes.
+ *
+ * returns:
+ *	0, on success
+ *	-FDT_ERR_NOSPACE, there is insufficient free space in the blob to
+ *		contain the new property value
+ *	-FDT_ERR_BADOFFSET, nodeoffset did not point to FDT_BEGIN_NODE tag
+ *	-FDT_ERR_BADLAYOUT,
+ *	-FDT_ERR_BADMAGIC,
+ *	-FDT_ERR_BADVERSION,
+ *	-FDT_ERR_BADSTATE,
+ *	-FDT_ERR_BADSTRUCTURE,
+ *	-FDT_ERR_BADLAYOUT,
+ *	-FDT_ERR_TRUNCATED, standard meanings
+ */
+int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name,
+			    int len, void **prop_data);
+
+/**
  * fdt_setprop_u32 - set a property to a 32-bit integer
  * @fdt: pointer to the device tree blob
  * @nodeoffset: offset of the node whose property to change
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose()
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:25   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method Pantelis Antoniou
                   ` (12 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Introduce fdt_overlay_apply_verbose, a method that applies an
overlay but in the case of an error produces a helpful message.

In addition if a base tree is found to be missing the __symbols__
node the message will point out that the probable reason is that
the base tree was miscompiled without the -@ option.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 common/fdt_support.c  | 31 +++++++++++++++++++++++++++++++
 include/fdt_support.h |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 916a448..f4f9543 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -1655,3 +1655,34 @@ int fdt_fixup_display(void *blob, const char *path, const char *display)
 	}
 	return toff;
 }
+
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+/**
+ * fdt_overlay_apply_verbose - Apply an overlay with verbose error reporting
+ *
+ * @fdt: ptr to device tree
+ * @fdto: ptr to device tree overlay
+ *
+ * Convenience function to apply an overlay and display helpful messages
+ * in the case of an error
+ */
+int fdt_overlay_apply_verbose(void *fdt, void *fdto)
+{
+	int err;
+	bool has_symbols;
+
+	err = fdt_path_offset(fdt, "/__symbols__");
+	has_symbols = err >= 0;
+
+	err = fdt_overlay_apply(fdt, fdto);
+	if (err < 0) {
+		printf("failed on fdt_overlay_apply(): %s\n",
+				fdt_strerror(err));
+		if (!has_symbols) {
+			printf("base fdt does did not have a /__symbols__ node\n");
+			printf("make sure you've compiled with -@\n");
+		}
+	}
+	return err;
+}
+#endif
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 5ef78cc..2bca4d7 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -264,6 +264,8 @@ int arch_fixup_memory_node(void *blob);
 int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
 			    u32 height, u32 stride, const char *format);
 
+int fdt_overlay_apply_verbose(void *fdt, void *fdto);
+
 #endif /* ifdef CONFIG_OF_LIBFDT */
 
 #ifdef USE_HOSTCC
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose() Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references Pantelis Antoniou
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

The verbose overlay application method prints out more helpful
messages, so switch to it.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 cmd/fdt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 118613f..362a621 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -669,11 +669,10 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (!fdt_valid(&blob))
 			return CMD_RET_FAILURE;
 
-		ret = fdt_overlay_apply(working_fdt, blob);
-		if (ret) {
-			printf("fdt_overlay_apply(): %s\n", fdt_strerror(ret));
+		/* apply method prints messages on error */
+		ret = fdt_overlay_apply_verbose(working_fdt, blob);
+		if (ret)
 			return CMD_RET_FAILURE;
-		}
 	}
 #endif
 	/* resize the fdt */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (2 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property Pantelis Antoniou
                   ` (10 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

This patch enables an overlay to refer to a previous overlay's
labels by performing a merge of symbol information at application
time.

In a nutshell it allows an overlay to refer to a symbol that a previous
overlay has defined. It requires both the base and all the overlays
to be compiled with the -@ command line switch so that symbol
information is included.

base.dts
--------

	/dts-v1/;
	/ {
		foo: foonode {
			foo-property;
		};
	};

	$ dtc -@ -I dts -O dtb -o base.dtb base.dts

bar.dts
-------

	/dts-v1/;
	/plugin/;
	/ {
		fragment at 1 {
			target = <&foo>;
			__overlay__ {
				overlay-1-property;
				bar: barnode {
					bar-property;
				};
			};
		};
	};

	$ dtc -@ -I dts -O dtb -o bar.dtb bar.dts

baz.dts
-------

	/dts-v1/;
	/plugin/;
	/ {
		fragment at 1 {
			target = <&bar>;
			__overlay__ {
				overlay-2-property;
				baz: baznode {
					baz-property;
				};
			};
		};
	};

	$ dtc -@ -I dts -O dtb -o baz.dtb baz.dts

Applying the overlays:

	$ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb

Dumping:

	$ fdtdump target.dtb
	/ {
            foonode {
                overlay-1-property;
                foo-property;
                linux,phandle = <0x00000001>;
                phandle = <0x00000001>;
                barnode {
                    overlay-2-property;
                    phandle = <0x00000002>;
                    linux,phandle = <0x00000002>;
                    bar-property;
                    baznode {
                        phandle = <0x00000003>;
                        linux,phandle = <0x00000003>;
                        baz-property;
                    };
                };
            };
            __symbols__ {
                baz = "/foonode/barnode/baznode";
                bar = "/foonode/barnode";
                foo = "/foonode";
            };
	};

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 lib/libfdt/fdt_overlay.c | 228 ++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 206 insertions(+), 22 deletions(-)

diff --git a/lib/libfdt/fdt_overlay.c b/lib/libfdt/fdt_overlay.c
index ceb9687..bd81241 100644
--- a/lib/libfdt/fdt_overlay.c
+++ b/lib/libfdt/fdt_overlay.c
@@ -39,6 +39,7 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
  * @fdt: Base device tree blob
  * @fdto: Device tree overlay blob
  * @fragment: node offset of the fragment in the overlay
+ * @pathp: pointer which receives the path of the target (or NULL)
  *
  * overlay_get_target() retrieves the target offset in the base
  * device tree of a fragment, no matter how the actual targetting is
@@ -49,37 +50,47 @@ static uint32_t overlay_get_target_phandle(const void *fdto, int fragment)
  *      Negative error code on error
  */
 static int overlay_get_target(const void *fdt, const void *fdto,
-			      int fragment)
+			      int fragment, char const **pathp)
 {
 	uint32_t phandle;
-	const char *path;
-	int path_len;
+	const char *path = NULL;
+	int path_len = 0, ret;
 
 	/* Try first to do a phandle based lookup */
 	phandle = overlay_get_target_phandle(fdto, fragment);
 	if (phandle == (uint32_t)-1)
 		return -FDT_ERR_BADPHANDLE;
 
-	if (phandle)
-		return fdt_node_offset_by_phandle(fdt, phandle);
+	/* no phandle, try path */
+	if (!phandle) {
+		/* And then a path based lookup */
+		path = fdt_getprop(fdto, fragment, "target-path", &path_len);
+		if (path)
+			ret = fdt_path_offset(fdt, path);
+		else
+			ret = path_len;
+	} else
+		ret = fdt_node_offset_by_phandle(fdt, phandle);
 
-	/* And then a path based lookup */
-	path = fdt_getprop(fdto, fragment, "target-path", &path_len);
-	if (!path) {
-		/*
-		 * If we haven't found either a target or a
-		 * target-path property in a node that contains a
-		 * __overlay__ subnode (we wouldn't be called
-		 * otherwise), consider it a improperly written
-		 * overlay
-		 */
-		if (path_len == -FDT_ERR_NOTFOUND)
-			return -FDT_ERR_BADOVERLAY;
+	/*
+	* If we haven't found either a target or a
+	* target-path property in a node that contains a
+	* __overlay__ subnode (we wouldn't be called
+	* otherwise), consider it a improperly written
+	* overlay
+	*/
+	if (ret < 0 && path_len == -FDT_ERR_NOTFOUND)
+		ret = -FDT_ERR_BADOVERLAY;
+
+	/* return on error */
+	if (ret < 0)
+		return ret;
 
-		return path_len;
-	}
+	/* return pointer to path (if available) */
+	if (pathp)
+		*pathp = path ? path : NULL;
 
-	return fdt_path_offset(fdt, path);
+	return ret;
 }
 
 /**
@@ -590,7 +601,7 @@ static int overlay_apply_node(void *fdt, int target,
  *
  * overlay_merge() merges an overlay into its base device tree.
  *
- * This is the final step in the device tree overlay application
+ * This is the next to last step in the device tree overlay application
  * process, when all the phandles have been adjusted and resolved and
  * you just have to merge overlay into the base device tree.
  *
@@ -618,7 +629,7 @@ static int overlay_merge(void *fdt, void *fdto)
 		if (overlay < 0)
 			return overlay;
 
-		target = overlay_get_target(fdt, fdto, fragment);
+		target = overlay_get_target(fdt, fdto, fragment, NULL);
 		if (target < 0)
 			return target;
 
@@ -630,6 +641,175 @@ static int overlay_merge(void *fdt, void *fdto)
 	return 0;
 }
 
+static int get_path_len(const void *fdt, int nodeoffset)
+{
+	int len = 0, namelen;
+	const char *name;
+
+	FDT_CHECK_HEADER(fdt);
+
+	for (;;) {
+		name = fdt_get_name(fdt, nodeoffset, &namelen);
+		if (!name)
+			return namelen;
+
+		/* root? we're done */
+		if (namelen == 0)
+			break;
+
+		nodeoffset = fdt_parent_offset(fdt, nodeoffset);
+		if (nodeoffset < 0)
+			return nodeoffset;
+		len += namelen + 1;
+	}
+
+	/* in case of root pretend it's "/" */
+	if (len == 0)
+		len++;
+	return len;
+}
+
+/**
+ * overlay_symbol_update - Update the symbols of base tree after a merge
+ * @fdt: Base Device Tree blob
+ * @fdto: Device tree overlay blob
+ *
+ * overlay_symbol_update() updates the symbols of the base tree with the
+ * symbols of the applied overlay
+ *
+ * This is the last step in the device tree overlay application
+ * process, allowing the reference of overlay symbols by subsequent
+ * overlay operations.
+ *
+ * returns:
+ *      0 on success
+ *      Negative error code on failure
+ */
+static int overlay_symbol_update(void *fdt, void *fdto)
+{
+	int root_sym, ov_sym, prop, path_len, fragment, target;
+	int len, frag_name_len, ret, rel_path_len;
+	const char *s, *e;
+	const char *path;
+	const char *name;
+	const char *frag_name;
+	const char *rel_path;
+	const char *target_path;
+	char *buf;
+	void *p;
+
+	ov_sym = fdt_subnode_offset(fdto, 0, "__symbols__");
+
+	/* if no overlay symbols exist no problem */
+	if (ov_sym < 0)
+		return 0;
+
+	root_sym = fdt_subnode_offset(fdt, 0, "__symbols__");
+
+	/* it no root symbols exist we should create them */
+	if (root_sym == -FDT_ERR_NOTFOUND)
+		root_sym = fdt_add_subnode(fdt, 0, "__symbols__");
+
+	/* any error is fatal now */
+	if (root_sym < 0)
+		return root_sym;
+
+	/* iterate over each overlay symbol */
+	fdt_for_each_property_offset(prop, fdto, ov_sym) {
+		path = fdt_getprop_by_offset(fdto, prop, &name, &path_len);
+		if (!path)
+			return path_len;
+
+		/* verify it's a string property (terminated by a single \0) */
+		if (path_len < 1 || memchr(path, '\0', path_len) != &path[path_len - 1])
+			return -FDT_ERR_BADVALUE;
+
+		/* keep end marker to avoid strlen() */
+		e = path + path_len;
+
+		/* format: /<fragment-name>/__overlay__/<relative-subnode-path> */
+
+		if (*path != '/')
+			return -FDT_ERR_BADVALUE;
+
+		/* get fragment name first */
+		s = strchr(path + 1, '/');
+		if (!s)
+			return -FDT_ERR_BADOVERLAY;
+
+		frag_name = path + 1;
+		frag_name_len = s - path - 1;
+
+		/* verify format; safe since "s" lies in \0 terminated prop */
+		len = sizeof("/__overlay__/") - 1;
+		if ((e - s) < len || memcmp(s, "/__overlay__/", len))
+			return -FDT_ERR_BADOVERLAY;
+
+		rel_path = s + len;
+		rel_path_len = e - rel_path;
+
+		/* find the fragment index in which the symbol lies */
+		ret = fdt_subnode_offset_namelen(fdto, 0, frag_name,
+					       frag_name_len);
+		/* not found? */
+		if (ret < 0)
+			return -FDT_ERR_BADOVERLAY;
+		fragment = ret;
+
+		/* an __overlay__ subnode must exist */
+		ret = fdt_subnode_offset(fdto, fragment, "__overlay__");
+		if (ret < 0)
+			return -FDT_ERR_BADOVERLAY;
+
+		/* get the target of the fragment */
+		ret = overlay_get_target(fdt, fdto, fragment, &target_path);
+		if (ret < 0)
+			return ret;
+		target = ret;
+
+		/* if we have a target path use */
+		if (!target_path) {
+			ret = get_path_len(fdt, target);
+			if (ret < 0)
+				return ret;
+			len = ret;
+		} else {
+			len = strlen(target_path);
+		}
+
+		ret = fdt_setprop_placeholder(fdt, root_sym, name,
+				len + (len > 1) + rel_path_len + 1, &p);
+		if (ret < 0)
+			return ret;
+
+		if (!target_path) {
+			/* again in case setprop_placeholder changed it */
+			ret = overlay_get_target(fdt, fdto, fragment, &target_path);
+			if (ret < 0)
+				return ret;
+			target = ret;
+		}
+
+		buf = p;
+		if (len > 1) { /* target is not root */
+			if (!target_path) {
+				ret = fdt_get_path(fdt, target, buf, len + 1);
+				if (ret < 0)
+					return ret;
+			} else
+				memcpy(buf, target_path, len + 1);
+
+		} else
+			len--;
+
+		buf[len] = '/';
+		memcpy(buf + len + 1, rel_path, rel_path_len);
+		buf[len + 1 + rel_path_len] = '\0';
+	}
+
+	return 0;
+}
+
 int fdt_overlay_apply(void *fdt, void *fdto)
 {
 	uint32_t delta = fdt_get_max_phandle(fdt);
@@ -654,6 +834,10 @@ int fdt_overlay_apply(void *fdt, void *fdto)
 	if (ret)
 		goto err;
 
+	ret = overlay_symbol_update(fdt, fdto);
+	if (ret)
+		goto err;
+
 	/*
 	 * The overlay has been damaged, erase its magic.
 	 */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (3 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load() Pantelis Antoniou
                   ` (9 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

As part of the fdt overlay support which need it, allow
a list of configurations per property.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 common/image-fit.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 109ecfa..74e5557 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1484,20 +1484,32 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)
 	return noffset;
 }
 
-int fit_conf_get_prop_node(const void *fit, int noffset,
+int fit_conf_get_prop_node_count(const void *fit, int noffset,
 		const char *prop_name)
 {
-	char *uname;
+	return fdt_stringlist_count(fit, noffset, prop_name);
+}
+
+int fit_conf_get_prop_node_index(const void *fit, int noffset,
+		const char *prop_name, int index)
+{
+	const char *uname;
 	int len;
 
 	/* get kernel image unit name from configuration kernel property */
-	uname = (char *)fdt_getprop(fit, noffset, prop_name, &len);
+	uname = fdt_stringlist_get(fit, noffset, prop_name, index, &len);
 	if (uname == NULL)
 		return len;
 
 	return fit_image_get_node(fit, uname);
 }
 
+int fit_conf_get_prop_node(const void *fit, int noffset,
+		const char *prop_name)
+{
+	return fit_conf_get_prop_node_index(fit, noffset, prop_name, 0);
+}
+
 /**
  * fit_conf_print - prints out the FIT configuration details
  * @fit: pointer to the FIT format image header
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load()
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (4 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
                   ` (8 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

fit_image_load() threw away the extra configuration parts when
loading. We need them around for applying extra overlays for
building the boot fdt.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 common/image-fit.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 74e5557..e75cb64 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1653,6 +1653,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	int cfg_noffset, noffset;
 	const char *fit_uname;
 	const char *fit_uname_config;
+	const char *fit_base_uname_config;
 	const void *fit;
 	const void *buf;
 	size_t size;
@@ -1668,6 +1669,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	fit = map_sysmem(addr, 0);
 	fit_uname = fit_unamep ? *fit_unamep : NULL;
 	fit_uname_config = fit_uname_configp ? *fit_uname_configp : NULL;
+	fit_base_uname_config = NULL;
 	prop_name = fit_get_image_type_property(image_type);
 	printf("## Loading %s from FIT Image at %08lx ...\n", prop_name, addr);
 
@@ -1701,11 +1703,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 					BOOTSTAGE_SUB_NO_UNIT_NAME);
 			return -ENOENT;
 		}
-		fit_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
-		printf("   Using '%s' configuration\n", fit_uname_config);
+		fit_base_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
+		printf("   Using '%s' configuration\n", fit_base_uname_config);
 		if (image_type == IH_TYPE_KERNEL) {
 			/* Remember (and possibly verify) this config */
-			images->fit_uname_cfg = fit_uname_config;
+			images->fit_uname_cfg = fit_base_uname_config;
 			if (IMAGE_ENABLE_VERIFY && images->verify) {
 				puts("   Verifying Hash Integrity ... ");
 				if (fit_config_verify(fit, cfg_noffset)) {
@@ -1861,7 +1863,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 	if (fit_unamep)
 		*fit_unamep = (char *)fit_uname;
 	if (fit_uname_configp)
-		*fit_uname_configp = (char *)fit_uname_config;
+		*fit_uname_configp = (char *)(fit_uname_config ? :
+					      fit_base_uname_config);
 
 	return noffset;
 }
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (5 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load() Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
                   ` (7 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Introduce an overlay based method for constructing a base DT blob
to pass to the kernel.

It is based on a specific method now to get the FDT from a FIT image
named boot_get_fdt_fit().

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 common/image-fdt.c |   7 +--
 common/image-fit.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 include/image.h    |  25 ++++++++
 3 files changed, 205 insertions(+), 8 deletions(-)

diff --git a/common/image-fdt.c b/common/image-fdt.c
index da4d007..a2ef409 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -356,17 +356,16 @@ int boot_get_fdt(int flag, int argc, char * const argv[], uint8_t arch,
 			if (fit_check_format(buf)) {
 				ulong load, len;
 
-				fdt_noffset = fit_image_load(images,
+				fdt_noffset = boot_get_fdt_fit(images,
 					fdt_addr, &fit_uname_fdt,
 					&fit_uname_config,
-					arch, IH_TYPE_FLATDT,
-					BOOTSTAGE_ID_FIT_FDT_START,
-					FIT_LOAD_OPTIONAL, &load, &len);
+					arch, &load, &len);
 
 				images->fit_hdr_fdt = map_sysmem(fdt_addr, 0);
 				images->fit_uname_fdt = fit_uname_fdt;
 				images->fit_noffset_fdt = fdt_noffset;
 				fdt_addr = load;
+
 				break;
 			} else
 #endif
diff --git a/common/image-fit.c b/common/image-fit.c
index e75cb64..7f17fd1 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <mapmem.h>
 #include <asm/io.h>
+#include <malloc.h>
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 
@@ -434,6 +435,10 @@ void fit_image_print(const void *fit, int image_noffset, const char *p)
 			printf("0x%08lx\n", load);
 	}
 
+	/* optional load address for FDT */
+	if (type == IH_TYPE_FLATDT && !fit_image_get_load(fit, image_noffset, &load))
+		printf("%s  Load Address: 0x%08lx\n", p, load);
+
 	if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_STANDALONE) ||
 	    (type == IH_TYPE_RAMDISK)) {
 		ret = fit_image_get_entry(fit, image_noffset, &entry);
@@ -1454,6 +1459,8 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)
 {
 	int noffset, confs_noffset;
 	int len;
+	const char *s;
+	char *conf_uname_copy = NULL;
 
 	confs_noffset = fdt_path_offset(fit, FIT_CONFS_PATH);
 	if (confs_noffset < 0) {
@@ -1475,12 +1482,29 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)
 		debug("Found default configuration: '%s'\n", conf_uname);
 	}
 
+	s = strchr(conf_uname, '#');
+	if (s) {
+		len = s - conf_uname;
+		conf_uname_copy = malloc(len + 1);
+		if (!conf_uname_copy) {
+			debug("Can't allocate uname copy: '%s'\n",
+					conf_uname);
+			return -ENOMEM;
+		}
+		memcpy(conf_uname_copy, conf_uname, len);
+		conf_uname_copy[len] = '\0';
+		conf_uname = conf_uname_copy;
+	}
+
 	noffset = fdt_subnode_offset(fit, confs_noffset, conf_uname);
 	if (noffset < 0) {
 		debug("Can't get node offset for configuration unit name: '%s' (%s)\n",
 		      conf_uname, fdt_strerror(noffset));
 	}
 
+	if (conf_uname_copy)
+		free(conf_uname_copy);
+
 	return noffset;
 }
 
@@ -1527,7 +1551,7 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
 	char *desc;
 	const char *uname;
 	int ret;
-	int loadables_index;
+	int fdt_index, loadables_index;
 
 	/* Mandatory properties */
 	ret = fit_get_desc(fit, noffset, &desc);
@@ -1549,9 +1573,17 @@ void fit_conf_print(const void *fit, int noffset, const char *p)
 	if (uname)
 		printf("%s  Init Ramdisk: %s\n", p, uname);
 
-	uname = fdt_getprop(fit, noffset, FIT_FDT_PROP, NULL);
-	if (uname)
-		printf("%s  FDT:          %s\n", p, uname);
+	for (fdt_index = 0;
+	     uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP,
+					fdt_index, NULL), uname;
+	     fdt_index++) {
+
+		if (fdt_index == 0)
+			printf("%s  FDT:          ", p);
+		else
+			printf("%s                ", p);
+		printf("%s\n", uname);
+	}
 
 	uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL);
 	if (uname)
@@ -1888,3 +1920,144 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
 
 	return ret;
 }
+
+#ifndef USE_HOSTCC
+int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
+		   const char **fit_unamep, const char **fit_uname_configp,
+		   int arch, ulong *datap, ulong *lenp)
+{
+	int fdt_noffset, cfg_noffset, count;
+	const void *fit;
+	const char *fit_uname = NULL;
+	const char *fit_uname_config = NULL;
+	char *fit_uname_config_copy = NULL;
+	char *next_config = NULL;
+	ulong load, len;
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	ulong image_start, image_end;
+	ulong ovload, ovlen;
+	const char *uconfig;
+	const char *uname;
+	void *base, *ov;
+	int i, err, noffset, ov_noffset;
+#endif
+
+	fit_uname = fit_unamep ? *fit_unamep : NULL;
+
+	if (fit_uname_configp && *fit_uname_configp) {
+		fit_uname_config_copy = strdup(*fit_uname_configp);
+		if (!fit_uname_config_copy)
+			return -ENOMEM;
+
+		next_config = strchr(fit_uname_config_copy, '#');
+		if (next_config)
+			*next_config++ = '\0';
+		if (next_config - 1 > fit_uname_config_copy)
+			fit_uname_config = fit_uname_config_copy;
+	}
+
+	fdt_noffset = fit_image_load(images,
+		addr, &fit_uname, &fit_uname_config,
+		arch, IH_TYPE_FLATDT,
+		BOOTSTAGE_ID_FIT_FDT_START,
+		FIT_LOAD_OPTIONAL, &load, &len);
+
+	if (fdt_noffset < 0)
+		goto out;
+
+	debug("fit_uname=%s, fit_uname_config=%s\n",
+			fit_uname ? fit_uname : "<NULL>",
+			fit_uname_config ? fit_uname_config : "<NULL>");
+
+	fit = map_sysmem(addr, 0);
+
+	cfg_noffset = fit_conf_get_node(fit, fit_uname_config);
+
+	/* single blob, or error just return as well */
+	count = fit_conf_get_prop_node_count(fit, cfg_noffset, FIT_FDT_PROP);
+	if (count <= 1 && !next_config)
+		goto out;
+
+	/* we need to apply overlays */
+
+#ifdef CONFIG_OF_LIBFDT_OVERLAY
+	image_start = addr;
+	image_end = addr + fit_get_size(fit);
+	/* verify that relocation took place by load address not being in fit */
+	if (load >= image_start && load < image_end) {
+		/* check is simplified; fit load checks for overlaps */
+		printf("Overlayed FDT requires relocation\n");
+		fdt_noffset = -EBADF;
+		goto out;
+	}
+
+	base = map_sysmem(load, len);
+
+	/* apply extra configs in FIT first, followed by args */
+	for (i = 1; ; i++) {
+		if (i < count) {
+			noffset = fit_conf_get_prop_node_index(fit, cfg_noffset,
+							       FIT_FDT_PROP, i);
+			uname = fit_get_name(fit, noffset, NULL);
+			uconfig = NULL;
+		} else {
+			if (!next_config)
+				break;
+			uconfig = next_config;
+			next_config = strchr(next_config, '#');
+			if (next_config)
+				*next_config++ = '\0';
+			uname = NULL;
+		}
+
+		debug("%d: using uname=%s uconfig=%s\n", i, uname, uconfig);
+
+		ov_noffset = fit_image_load(images,
+			addr, &uname, &uconfig,
+			arch, IH_TYPE_FLATDT,
+			BOOTSTAGE_ID_FIT_FDT_START,
+			FIT_LOAD_REQUIRED, &ovload, &ovlen);
+		if (ov_noffset < 0) {
+			printf("load of %s failed\n", uname);
+			continue;
+		}
+		debug("%s loaded at 0x%08lx len=0x%08lx\n",
+				uname, ovload, ovlen);
+		ov = map_sysmem(ovload, ovlen);
+
+		base = map_sysmem(load, len + ovlen);
+		err = fdt_open_into(base, base, len + ovlen);
+		if (err < 0) {
+			printf("failed on fdt_open_into\n");
+			fdt_noffset = err;
+			goto out;
+		}
+		/* the verbose method prints out messages on error */
+		err = fdt_overlay_apply_verbose(base, ov);
+		if (err < 0) {
+			fdt_noffset = err;
+			goto out;
+		}
+		fdt_pack(base);
+		len = fdt_totalsize(base);
+	}
+#else
+	printf("config with overlays but CONFIG_OF_LIBFDT_OVERLAY not set\n");
+	fdt_noffset = -EBADF;
+#endif
+
+out:
+	if (datap)
+		*datap = load;
+	if (lenp)
+		*lenp = len;
+	if (fit_unamep)
+		*fit_unamep = fit_uname;
+	if (fit_uname_configp)
+		*fit_uname_configp = fit_uname_config;
+
+	if (fit_uname_config_copy)
+		free(fit_uname_config_copy);
+	return fdt_noffset;
+}
+#endif
diff --git a/include/image.h b/include/image.h
index 1f4bfda..eca9b46 100644
--- a/include/image.h
+++ b/include/image.h
@@ -593,6 +593,31 @@ int boot_get_setup_fit(bootm_headers_t *images, uint8_t arch,
 		       ulong *setup_start, ulong *setup_len);
 
 /**
+ * boot_get_fdt_fit() - load a DTB from a FIT file (applying overlays)
+ *
+ * This deals with all aspects of loading an DTB from a FIT.
+ * The correct base image based on configuration will be selected, and
+ * then any overlays specified will be applied (as present in fit_uname_configp).
+ *
+ * @param images	Boot images structure
+ * @param addr		Address of FIT in memory
+ * @param fit_unamep	On entry this is the requested image name
+ *			(e.g. "kernel at 1") or NULL to use the default. On exit
+ *			points to the selected image name
+ * @param fit_uname_configp	On entry this is the requested configuration
+ *			name (e.g. "conf@1") or NULL to use the default. On
+ *			exit points to the selected configuration name.
+ * @param arch		Expected architecture (IH_ARCH_...)
+ * @param datap		Returns address of loaded image
+ * @param lenp		Returns length of loaded image
+ *
+ * @return node offset of base image, or -ve error code on error
+ */
+int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,
+		   const char **fit_unamep, const char **fit_uname_configp,
+		   int arch, ulong *datap, ulong *lenp);
+
+/**
  * fit_image_load() - load an image from a FIT
  *
  * This deals with all aspects of loading an image from a FIT, including
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (6 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-06 19:06   ` Łukasz Majewski
                     ` (2 more replies)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
                   ` (6 subsequent siblings)
  14 siblings, 3 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
 doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++
 doc/uImage.FIT/source_file_format.txt        |   6 +-
 3 files changed, 236 insertions(+), 3 deletions(-)
 create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt

diff --git a/doc/uImage.FIT/command_syntax_extensions.txt b/doc/uImage.FIT/command_syntax_extensions.txt
index 6c99b1c..676f992 100644
--- a/doc/uImage.FIT/command_syntax_extensions.txt
+++ b/doc/uImage.FIT/command_syntax_extensions.txt
@@ -36,7 +36,7 @@ Old uImage:
 New uImage:
 8.  bootm <addr1>
 9.  bootm [<addr1>]:<subimg1>
-10. bootm [<addr1>]#<conf>
+10. bootm [<addr1>]#<conf>[#<extra-conf[#...]]
 11. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2>
 12. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> [<addr3>]:<subimg3>
 13. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> <addr3>
@@ -129,6 +129,12 @@ following syntax:
 - new uImage configuration specification
 <addr>#<configuration unit_name>
 
+- new uImage configuration specification with extra configuration components
+<addr>#<configuration unit_name>[#<extra configuration unit_name>[#..]]
+
+The extra configuration currently is supported only for additional device tree
+overlays to apply on the base device tree supplied by the first configuration
+unit.
 
 Examples:
 
@@ -138,6 +144,10 @@ bootm 200000:kernel at 1
 - boot configuration "cfg at 1" from a new uImage located at 200000:
 bootm 200000#cfg at 1
 
+- boot configuration "cfg at 1" with extra "cfg at 2" from a new uImage located
+  at 200000:
+bootm 200000#cfg at 1#cfg at 2
+
 - boot "kernel at 1" from a new uImage at 200000 with initrd "ramdisk at 2" found in
   some other new uImage stored at address 800000:
 bootm 200000:kernel at 1 800000:ramdisk at 2
diff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt
new file mode 100644
index 0000000..dbdf2a1
--- /dev/null
+++ b/doc/uImage.FIT/overlay-fdt-boot.txt
@@ -0,0 +1,221 @@
+U-Boot FDT Overlay usage
+========================
+
+Introduction
+------------
+In many cases it is desirable to have a single FIT image support a multitude
+of similar boards and their expansion options. The same kernel on DT enabled
+platforms can support this easily enough by providing a DT blob upon boot
+that matches the desired configuration.
+
+Configuration without overlays
+------------------------------
+
+Take a hypothetical board named 'foo' where there are different supported
+revisions, reva and revb. Assume that both board revisions can use add a bar
+add-on board, while only the revb board can use a baz add-on board.
+
+Without using overlays the configuration would be as follows for every case.
+
+	/dts-v1/;
+	/ {
+		images {
+			kernel at 1 {
+				data = /incbin/("./zImage");
+				type = "kernel";
+				arch = "arm";
+				os = "linux";
+				load = <0x82000000>;
+				entry = <0x82000000>;
+			};
+			fdt at 1 {
+				data = /incbin/("./foo-reva.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+			fdt at 2 {
+				data = /incbin/("./foo-revb.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+			fdt at 3 {
+				data = /incbin/("./foo-reva-bar.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+			fdt at 4 {
+				data = /incbin/("./foo-revb-bar.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+			fdt at 5 {
+				data = /incbin/("./foo-revb-baz.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+			fdt at 6 {
+				data = /incbin/("./foo-revb-bar-baz.dtb");
+				type = "flat_dt";
+				arch = "arm";
+			};
+		};
+
+		configurations {
+			default = "foo-reva.dtb;
+			foo-reva.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1";
+			};
+			foo-revb.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 2";
+			};
+			foo-reva-bar.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 3";
+			};
+			foo-revb-bar.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 4";
+			};
+			foo-revb-baz.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 5";
+			};
+			foo-revb-bar-baz.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 6";
+			};
+		};
+	};
+
+Note the blob needs to be compiled for each case and the combinatorial explosion of
+configurations. A typical device tree blob is in the low hunderds of kbytes so a
+multitude of configuration grows the image quite a bit.
+
+Booting this image is done by using
+
+	# bootm <addr>#<config>
+
+Where config is one of:
+	foo-reva.dtb, foo-revb.dtb, foo-reva-bar.dtb, foo-revb-bar.dtb,
+	foo-revb-baz.dtb, foo-revb-bar-baz.dtb
+
+This selects the DTB to use when booting.
+
+Configuration using overlays
+----------------------------
+
+Device tree overlays can be applied to a base DT and result in the same blob
+being passed to the booting kernel. This saves on space and avoid the combinatorial
+explosion problem.
+
+	/dts-v1/;
+	/ {
+		images {
+			kernel at 1 {
+				data = /incbin/("./zImage");
+				type = "kernel";
+				arch = "arm";
+				os = "linux";
+				load = <0x82000000>;
+				entry = <0x82000000>;
+			};
+			fdt at 1 {
+				data = /incbin/("./foo.dtb");
+				type = "flat_dt";
+				arch = "arm";
+				load = <0x87f00000>;
+			};
+			fdt at 2 {
+				data = /incbin/("./reva.dtbo");
+				type = "flat_dt";
+				arch = "arm";
+				load = <0x87fc0000>;
+			};
+			fdt at 3 {
+				data = /incbin/("./revb.dtbo");
+				type = "flat_dt";
+				arch = "arm";
+				load = <0x87fc0000>;
+			};
+			fdt at 4 {
+				data = /incbin/("./bar.dtbo");
+				type = "flat_dt";
+				arch = "arm";
+				load = <0x87fc0000>;
+			};
+			fdt at 5 {
+				data = /incbin/("./baz.dtbo");
+				type = "flat_dt";
+				arch = "arm";
+				load = <0x87fc0000>;
+			};
+		};
+
+		configurations {
+			default = "foo-reva.dtb;
+			foo-reva.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 2";
+			};
+			foo-revb.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 3";
+			};
+			foo-reva-bar.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 2", "fdt at 4";
+			};
+			foo-revb-bar.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 3", "fdt at 4";
+			};
+			foo-revb-baz.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 3", "fdt at 5";
+			};
+			foo-revb-bar-baz.dtb {
+				kernel = "kernel at 1";
+				fdt = "fdt at 1", "fdt at 3", "fdt at 4", "fdt at 5";
+			};
+			bar {
+				fdt = "fdt at 4";
+			};
+			baz {
+				fdt = "fdt at 5";
+			};
+		};
+	};
+
+Booting this image is exactly the same as the non-overlay example.
+u-boot will retrieve the base blob and apply the overlays in sequence as
+they are declared in the configuration.
+
+Note the minimum amount of different DT blobs, as well as the requirement for
+the DT blobs to have a load address; the overlay application requires the blobs
+to be writeable.
+
+Configuration using overlays and feature selection
+--------------------------------------------------
+
+Although the configuration in the previous section works is a bit inflexible
+since it requires all possible configuration options to be laid out before
+hand in the FIT image. For the add-on boards the extra config selection method
+might make sense.
+
+Note the two bar & baz configuration nodes. To boot a reva board with
+the bar add-on board enabled simply use:
+
+	# bootm <addr>#foo-reva.dtb#bar
+
+While booting a revb with bar and baz is as follows:
+
+	# bootm <addr>#foo-revb.dtb#bar#baz
+
+The limitation for a feature selection configuration node is that a single
+fdt option is currently supported.
+
+Pantelis Antoniou
+pantelis.antoniou at konsulko.com
+12/6/2017
diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
index 136d3d7..ba8013a 100644
--- a/doc/uImage.FIT/source_file_format.txt
+++ b/doc/uImage.FIT/source_file_format.txt
@@ -235,7 +235,7 @@ o config at 1
   |- description = "configuration description"
   |- kernel = "kernel sub-node unit name"
   |- ramdisk = "ramdisk sub-node unit name"
-  |- fdt = "fdt sub-node unit-name"
+  |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...]
   |- fpga = "fpga sub-node unit-name"
   |- loadables = "loadables sub-node unit-name"
 
@@ -249,7 +249,9 @@ o config at 1
   - ramdisk : Unit name of the corresponding ramdisk image (component image
     node of a "ramdisk" type).
   - fdt : Unit name of the corresponding fdt blob (component image node of a
-    "fdt type").
+    "fdt type"). Additional fdt overlay nodes can be supplied which signify
+    that the resulting device tree blob is generated by the first base fdt
+    blob with all subsequent overlays applied.
   - setup : Unit name of the corresponding setup binary (used for booting
     an x86 kernel). This contains the setup.bin file built by the kernel.
   - fpga : Unit name of the corresponding fpga bitstream blob
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (7 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-06 19:07   ` Łukasz Majewski
                     ` (2 more replies)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
                   ` (5 subsequent siblings)
  14 siblings, 3 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

We have the capability to apply overlays on the command line but
we didn't have a document explaining how.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 doc/README.fdt-overlays | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 doc/README.fdt-overlays

diff --git a/doc/README.fdt-overlays b/doc/README.fdt-overlays
new file mode 100644
index 0000000..ee868ec
--- /dev/null
+++ b/doc/README.fdt-overlays
@@ -0,0 +1,37 @@
+U-Boot FDT Overlay usage (without FIT images)
+=============================================
+
+FDT overlays are now available for use even without FIT images.
+It is not as automagic as with FIT images though and require a few
+manual steps.
+
+1. Figure out where to place both the base device tree blob and the
+overlay. Make sure you have enough space to grow the base tree without
+overlapping anything.
+
+=> setenv fdtaddr 0x87f00000
+=> setenv fdtovaddr 0x87fc0000
+
+2. Load the base blob and overlay blobs
+
+=> load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/base.dtb
+=> load ${devtype} ${bootpart} ${fdtovaddr} ${bootdir}/overlay.dtb
+
+3. Set it as the working fdt tree.
+
+=> fdtaddr $fdtaddr
+
+4. Grow it enough so it can 'fit' all the applied overlays
+
+=> fdt resize 8192
+
+5. You are now ready to apply the overlay.
+
+=> fdt apply $fdtovaddr
+
+Please note that in case of an error, both the base and overlays are going
+to be invalidated, so keep copies to avoid reloading.
+
+Pantelis Antoniou
+pantelis.antoniou at konsulko.com
+11/7/2017
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (8 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-06 19:10   ` Łukasz Majewski
                     ` (2 more replies)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special Pantelis Antoniou
                   ` (4 subsequent siblings)
  14 siblings, 3 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

From: Franklin S Cooper Jr <fcooper@ti.com>

Pull some information regarding overlays from commit messages and
put them directly within the documentation. Also add some information
regarding required dtc version to properly use overlays.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
 doc/README.fdt-overlays             | 85 +++++++++++++++++++++++++++++++++++--
 doc/uImage.FIT/overlay-fdt-boot.txt |  8 +++-
 2 files changed, 87 insertions(+), 6 deletions(-)

diff --git a/doc/README.fdt-overlays b/doc/README.fdt-overlays
index ee868ec..39139cb 100644
--- a/doc/README.fdt-overlays
+++ b/doc/README.fdt-overlays
@@ -1,9 +1,76 @@
-U-Boot FDT Overlay usage (without FIT images)
+U-Boot FDT Overlay usage
 =============================================
 
-FDT overlays are now available for use even without FIT images.
-It is not as automagic as with FIT images though and require a few
-manual steps.
+Overlays Syntax
+---------------
+
+Overlays require slightly different syntax compared to traditional overlays.
+Please refer to dt-object-internal.txt in the dtc sources for information
+regarding the internal format of overlays:
+https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/Documentation/dt-object-internal.txt
+
+Building Overlays
+-----------------
+
+In a nutshell overlays provides a means to manipulate a symbol a previous dtb
+or overlay has defined. It requires both the base and all the overlays
+to be compiled with the -@ command line switch so that symbol information is
+included.
+
+Note support for -@ option can only be found in dtc version 1.4.4 or newer.
+Only version 4.14 or higher of the Linux kernel includes a built in version
+of dtc that meets this requirement.
+
+Building an overlay follows the same process as building a traditional dtb.
+
+For example:
+
+base.dts
+--------
+
+	/dts-v1/;
+	/ {
+		foo: foonode {
+			foo-property;
+		};
+	};
+
+	$ dtc -@ -I dts -O dtb -o base.dtb base.dts
+
+bar.dts
+-------
+
+	/dts-v1/;
+	/plugin/;
+	/ {
+		fragment at 1 {
+			target = <&foo>;
+			__overlay__ {
+				overlay-1-property;
+				bar: barnode {
+					bar-property;
+				};
+			};
+		};
+	};
+
+	$ dtc -@ -I dts -O dtb -o bar.dtb bar.dts
+
+Ways to Utilize Overlays in U-boot
+----------------------------------
+
+There are two ways to apply overlays in U-boot.
+1. Include and define overlays within a FIT image and have overlays
+   automatically applied.
+
+2. Manually load and apply overlays
+
+The remainder of this document will discuss using overlays via the manual
+approach. For information on using overlays as part of a FIT image please see:
+doc/uImage.FIT/overlay-fdt-boot.txt
+
+Manually Loading and Applying Overlays
+--------------------------------------
 
 1. Figure out where to place both the base device tree blob and the
 overlay. Make sure you have enough space to grow the base tree without
@@ -29,6 +96,16 @@ overlapping anything.
 
 => fdt apply $fdtovaddr
 
+6. Boot system like you would do with a traditional dtb.
+
+For bootm:
+
+=> bootm ${kerneladdr} - ${fdtaddr}
+
+For bootz:
+
+=> bootz ${kerneladdr} - ${fdtaddr}
+
 Please note that in case of an error, both the base and overlays are going
 to be invalidated, so keep copies to avoid reloading.
 
diff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt
index dbdf2a1..63e47da 100644
--- a/doc/uImage.FIT/overlay-fdt-boot.txt
+++ b/doc/uImage.FIT/overlay-fdt-boot.txt
@@ -1,5 +1,5 @@
-U-Boot FDT Overlay usage
-========================
+U-Boot FDT Overlay FIT usage
+============================
 
 Introduction
 ------------
@@ -8,6 +8,10 @@ of similar boards and their expansion options. The same kernel on DT enabled
 platforms can support this easily enough by providing a DT blob upon boot
 that matches the desired configuration.
 
+This document focuses on specifically using overlays as part of a FIT image.
+General information regarding overlays including its syntax and building it
+can be found in doc/README.fdt-overlays
+
 Configuration without overlays
 ------------------------------
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (9 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 15:50   ` Stephen Warren
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests Pantelis Antoniou
                   ` (3 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Special rule for dtbo generation

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 scripts/Makefile.lib | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 9ce47b4..2a7ed70 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -321,6 +321,23 @@ $(obj)/%.dtb: $(src)/%.dts FORCE
 
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
 
+# DTCO
+# ---------------------------------------------------------------------------
+
+quiet_cmd_dtco = DTCO    $@
+# Rule for objects only; does not put specific u-boot include at the end
+# No generation of assembly file either
+# Modified for U-Boot
+cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
+	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
+	$(DTC) -@ -O dtb -o $@ -b 0 \
+		-i $(dir $<) $(DTC_FLAGS) \
+		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
+	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
+
+$(obj)/%.dtbo: $(src)/%.dts FORCE
+	$(call if_changed_dep,dtco)
+
 # Fonts
 # ---------------------------------------------------------------------------
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (10 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change Pantelis Antoniou
                   ` (2 subsequent siblings)
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Add unit tests for sandbox default config.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 configs/sandbox_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 4c4e480..54120c2 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -189,7 +189,9 @@ CONFIG_CMD_DHRYSTONE=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
 CONFIG_ERRNO_STR=y
+CONFIG_OF_LIBFDT_OVERLAY=y
 CONFIG_UNIT_TEST=y
 CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
 CONFIG_UT_ENV=y
+CONFIG_UT_OVERLAY=y
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (11 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
  2017-09-14  0:53 ` [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Simon Glass
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

fdt_getprop_u32 is not exported and it's different than what the
unit test uses. Rename u32 prop access methods to something that's
unit test specific.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 test/overlay/cmd_ut_overlay.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
index cbef720..7106f42 100644
--- a/test/overlay/cmd_ut_overlay.c
+++ b/test/overlay/cmd_ut_overlay.c
@@ -21,7 +21,7 @@
 extern u32 __dtb_test_fdt_base_begin;
 extern u32 __dtb_test_fdt_overlay_begin;
 
-static int fdt_getprop_u32_by_index(void *fdt, const char *path,
+static int ut_fdt_getprop_u32_by_index(void *fdt, const char *path,
 				    const char *name, int index,
 				    u32 *out)
 {
@@ -42,10 +42,10 @@ static int fdt_getprop_u32_by_index(void *fdt, const char *path,
 	return 0;
 }
 
-static int fdt_getprop_u32(void *fdt, const char *path, const char *name,
+static int ut_fdt_getprop_u32(void *fdt, const char *path, const char *name,
 			   u32 *out)
 {
-	return fdt_getprop_u32_by_index(fdt, path, name, 0, out);
+	return ut_fdt_getprop_u32_by_index(fdt, path, name, 0, out);
 }
 
 static int fdt_getprop_str(void *fdt, const char *path, const char *name,
@@ -68,7 +68,7 @@ static int fdt_overlay_change_int_property(struct unit_test_state *uts)
 	void *fdt = uts->priv;
 	u32 val = 0;
 
-	ut_assertok(fdt_getprop_u32(fdt, "/test-node", "test-int-property",
+	ut_assertok(ut_fdt_getprop_u32(fdt, "/test-node", "test-int-property",
 				    &val));
 	ut_asserteq(43, val);
 
@@ -158,11 +158,11 @@ static int fdt_overlay_local_phandle(struct unit_test_state *uts)
 	local_phandle = fdt_get_phandle(fdt, off);
 	ut_assert(local_phandle);
 
-	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+	ut_assertok(ut_fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
 					     0, &val));
 	ut_asserteq(local_phandle, val);
 
-	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
+	ut_assertok(ut_fdt_getprop_u32_by_index(fdt, "/", "test-several-phandle",
 					     1, &val));
 	ut_asserteq(local_phandle, val);
 
@@ -189,11 +189,11 @@ static int fdt_overlay_local_phandles(struct unit_test_state *uts)
 	test_phandle = fdt_get_phandle(fdt, off);
 	ut_assert(test_phandle);
 
-	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 0,
+	ut_assertok(ut_fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 0,
 					     &val));
 	ut_asserteq(test_phandle, val);
 
-	ut_assertok(fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 1,
+	ut_assertok(ut_fdt_getprop_u32_by_index(fdt, "/", "test-phandle", 1,
 					     &val));
 	ut_asserteq(local_phandle, val);
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (12 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change Pantelis Antoniou
@ 2017-09-04 20:12 ` Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2017-09-14  0:53 ` [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Simon Glass
  14 siblings, 2 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-04 20:12 UTC (permalink / raw)
  To: u-boot

Verify that stacked overlays work.

Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
---
 test/overlay/Makefile                     |  1 +
 test/overlay/cmd_ut_overlay.c             | 34 ++++++++++++++++++++++++++++++-
 test/overlay/test-fdt-overlay-stacked.dts | 21 +++++++++++++++++++
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 test/overlay/test-fdt-overlay-stacked.dts

diff --git a/test/overlay/Makefile b/test/overlay/Makefile
index 907f085..416645c 100644
--- a/test/overlay/Makefile
+++ b/test/overlay/Makefile
@@ -13,3 +13,4 @@ DTC_FLAGS += -@
 # DT overlays
 obj-y += test-fdt-base.dtb.o
 obj-y += test-fdt-overlay.dtb.o
+obj-y += test-fdt-overlay-stacked.dtb.o
diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
index 7106f42..24891ee 100644
--- a/test/overlay/cmd_ut_overlay.c
+++ b/test/overlay/cmd_ut_overlay.c
@@ -20,6 +20,7 @@
 
 extern u32 __dtb_test_fdt_base_begin;
 extern u32 __dtb_test_fdt_overlay_begin;
+extern u32 __dtb_test_fdt_overlay_stacked_begin;
 
 static int ut_fdt_getprop_u32_by_index(void *fdt, const char *path,
 				    const char *name, int index,
@@ -201,6 +202,19 @@ static int fdt_overlay_local_phandles(struct unit_test_state *uts)
 }
 OVERLAY_TEST(fdt_overlay_local_phandles, 0);
 
+static int fdt_overlay_stacked(struct unit_test_state *uts)
+{
+	void *fdt = uts->priv;
+	u32 val = 0;
+
+	ut_assertok(ut_fdt_getprop_u32(fdt, "/new-local-node",
+				       "stacked-test-int-property", &val));
+	ut_asserteq(43, val);
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_stacked, 0);
+
 int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	struct unit_test *tests = ll_entry_start(struct unit_test,
@@ -210,7 +224,8 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct unit_test *test;
 	void *fdt_base = &__dtb_test_fdt_base_begin;
 	void *fdt_overlay = &__dtb_test_fdt_overlay_begin;
-	void *fdt_base_copy, *fdt_overlay_copy;
+	void *fdt_overlay_stacked = &__dtb_test_fdt_overlay_stacked_begin;
+	void *fdt_base_copy, *fdt_overlay_copy, *fdt_overlay_stacked_copy;
 
 	uts = calloc(1, sizeof(*uts));
 	if (!uts)
@@ -228,6 +243,10 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (!fdt_overlay_copy)
 		return -ENOMEM;
 
+	fdt_overlay_stacked_copy = malloc(FDT_COPY_SIZE);
+	if (!fdt_overlay_stacked_copy)
+		return -ENOMEM;
+
 	/*
 	 * Resize the FDT to 4k so that we have room to operate on
 	 *
@@ -245,9 +264,21 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	ut_assertok(fdt_open_into(fdt_overlay, fdt_overlay_copy,
 				  FDT_COPY_SIZE));
 
+	/*
+	 * Resize the stacked overlay to 4k so that we have room to operate on
+	 *
+	 * (and relocate it since the memory might be mapped
+	 * read-only)
+	 */
+	ut_assertok(fdt_open_into(fdt_overlay_stacked, fdt_overlay_stacked_copy,
+				  FDT_COPY_SIZE));
+
 	/* Apply the overlay */
 	ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_copy));
 
+	/* Apply the stacked overlay */
+	ut_assertok(fdt_overlay_apply(fdt_base_copy, fdt_overlay_stacked_copy));
+
 	if (argc == 1)
 		printf("Running %d environment tests\n", n_ents);
 
@@ -263,6 +294,7 @@ int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	printf("Failures: %d\n", uts->fail_count);
 
+	free(fdt_overlay_stacked_copy);
 	free(fdt_overlay_copy);
 	free(fdt_base_copy);
 	free(uts);
diff --git a/test/overlay/test-fdt-overlay-stacked.dts b/test/overlay/test-fdt-overlay-stacked.dts
new file mode 100644
index 0000000..9fb7c7b
--- /dev/null
+++ b/test/overlay/test-fdt-overlay-stacked.dts
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 NextThing Co
+ * Copyright (c) 2016 Free Electrons
+ * Copyright (c) 2018 Konsulko Group
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+	/* Test that we can reference an overlay symbol */
+	fragment at 0 {
+		target = <&local>;
+
+		__overlay__ {
+			stacked-test-int-property = <43>;
+		};
+	};
+};
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
@ 2017-09-06 19:06   ` Łukasz Majewski
  2017-09-07  6:52     ` Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 1 reply; 57+ messages in thread
From: Łukasz Majewski @ 2017-09-06 19:06 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 9950 bytes --]

On 09/04/2017 10:12 PM, Pantelis Antoniou wrote:
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>   doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
>   doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++
>   doc/uImage.FIT/source_file_format.txt        |   6 +-
>   3 files changed, 236 insertions(+), 3 deletions(-)
>   create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
> 
> diff --git a/doc/uImage.FIT/command_syntax_extensions.txt b/doc/uImage.FIT/command_syntax_extensions.txt
> index 6c99b1c..676f992 100644
> --- a/doc/uImage.FIT/command_syntax_extensions.txt
> +++ b/doc/uImage.FIT/command_syntax_extensions.txt
> @@ -36,7 +36,7 @@ Old uImage:
>   New uImage:
>   8.  bootm <addr1>
>   9.  bootm [<addr1>]:<subimg1>
> -10. bootm [<addr1>]#<conf>
> +10. bootm [<addr1>]#<conf>[#<extra-conf[#...]]
>   11. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2>
>   12. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> [<addr3>]:<subimg3>
>   13. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> <addr3>
> @@ -129,6 +129,12 @@ following syntax:
>   - new uImage configuration specification
>   <addr>#<configuration unit_name>
>   
> +- new uImage configuration specification with extra configuration components
> +<addr>#<configuration unit_name>[#<extra configuration unit_name>[#..]]
> +
> +The extra configuration currently is supported only for additional device tree
> +overlays to apply on the base device tree supplied by the first configuration
> +unit.
>   
>   Examples:
>   
> @@ -138,6 +144,10 @@ bootm 200000:kernel at 1
>   - boot configuration "cfg at 1" from a new uImage located at 200000:
>   bootm 200000#cfg at 1
>   
> +- boot configuration "cfg at 1" with extra "cfg at 2" from a new uImage located
> +  at 200000:
> +bootm 200000#cfg at 1#cfg at 2
> +
>   - boot "kernel at 1" from a new uImage at 200000 with initrd "ramdisk at 2" found in
>     some other new uImage stored at address 800000:
>   bootm 200000:kernel at 1 800000:ramdisk at 2
> diff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt
> new file mode 100644
> index 0000000..dbdf2a1
> --- /dev/null
> +++ b/doc/uImage.FIT/overlay-fdt-boot.txt
> @@ -0,0 +1,221 @@
> +U-Boot FDT Overlay usage
> +========================
> +
> +Introduction
> +------------
> +In many cases it is desirable to have a single FIT image support a multitude
> +of similar boards and their expansion options. The same kernel on DT enabled
> +platforms can support this easily enough by providing a DT blob upon boot
> +that matches the desired configuration.
> +
> +Configuration without overlays
> +------------------------------
> +
> +Take a hypothetical board named 'foo' where there are different supported
> +revisions, reva and revb. Assume that both board revisions can use add a bar
> +add-on board, while only the revb board can use a baz add-on board.
> +
> +Without using overlays the configuration would be as follows for every case.
> +
> +	/dts-v1/;
> +	/ {
> +		images {
> +			kernel at 1 {
> +				data = /incbin/("./zImage");
> +				type = "kernel";
> +				arch = "arm";
> +				os = "linux";
> +				load = <0x82000000>;
> +				entry = <0x82000000>;
> +			};
> +			fdt at 1 {
> +				data = /incbin/("./foo-reva.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +			fdt at 2 {
> +				data = /incbin/("./foo-revb.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +			fdt at 3 {
> +				data = /incbin/("./foo-reva-bar.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +			fdt at 4 {
> +				data = /incbin/("./foo-revb-bar.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +			fdt at 5 {
> +				data = /incbin/("./foo-revb-baz.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +			fdt at 6 {
> +				data = /incbin/("./foo-revb-bar-baz.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +			};
> +		};
> +
> +		configurations {
> +			default = "foo-reva.dtb;
> +			foo-reva.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1";
> +			};
> +			foo-revb.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 2";
> +			};
> +			foo-reva-bar.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 3";
> +			};
> +			foo-revb-bar.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 4";
> +			};
> +			foo-revb-baz.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 5";
> +			};
> +			foo-revb-bar-baz.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 6";
> +			};
> +		};
> +	};
> +
> +Note the blob needs to be compiled for each case and the combinatorial explosion of
> +configurations. A typical device tree blob is in the low hunderds of kbytes so a
> +multitude of configuration grows the image quite a bit.
> +
> +Booting this image is done by using
> +
> +	# bootm <addr>#<config>
> +
> +Where config is one of:
> +	foo-reva.dtb, foo-revb.dtb, foo-reva-bar.dtb, foo-revb-bar.dtb,
> +	foo-revb-baz.dtb, foo-revb-bar-baz.dtb
> +
> +This selects the DTB to use when booting.
> +
> +Configuration using overlays
> +----------------------------
> +
> +Device tree overlays can be applied to a base DT and result in the same blob
> +being passed to the booting kernel. This saves on space and avoid the combinatorial
> +explosion problem.
> +
> +	/dts-v1/;
> +	/ {
> +		images {
> +			kernel at 1 {
> +				data = /incbin/("./zImage");
> +				type = "kernel";
> +				arch = "arm";
> +				os = "linux";
> +				load = <0x82000000>;
> +				entry = <0x82000000>;
> +			};
> +			fdt at 1 {
> +				data = /incbin/("./foo.dtb");
> +				type = "flat_dt";
> +				arch = "arm";
> +				load = <0x87f00000>;
> +			};
> +			fdt at 2 {
> +				data = /incbin/("./reva.dtbo");
> +				type = "flat_dt";
> +				arch = "arm";
> +				load = <0x87fc0000>;
> +			};
> +			fdt at 3 {
> +				data = /incbin/("./revb.dtbo");
> +				type = "flat_dt";
> +				arch = "arm";
> +				load = <0x87fc0000>;
> +			};
> +			fdt at 4 {
> +				data = /incbin/("./bar.dtbo");
> +				type = "flat_dt";
> +				arch = "arm";
> +				load = <0x87fc0000>;
> +			};
> +			fdt at 5 {
> +				data = /incbin/("./baz.dtbo");
> +				type = "flat_dt";
> +				arch = "arm";
> +				load = <0x87fc0000>;
> +			};
> +		};
> +
> +		configurations {
> +			default = "foo-reva.dtb;
> +			foo-reva.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 2";
> +			};
> +			foo-revb.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 3";
> +			};
> +			foo-reva-bar.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 2", "fdt at 4";
> +			};
> +			foo-revb-bar.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 3", "fdt at 4";
> +			};
> +			foo-revb-baz.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 3", "fdt at 5";
> +			};
> +			foo-revb-bar-baz.dtb {
> +				kernel = "kernel at 1";
> +				fdt = "fdt at 1", "fdt at 3", "fdt at 4", "fdt at 5";
> +			};
> +			bar {
> +				fdt = "fdt at 4";
> +			};
> +			baz {
> +				fdt = "fdt at 5";
> +			};
> +		};
> +	};
> +
> +Booting this image is exactly the same as the non-overlay example.
> +u-boot will retrieve the base blob and apply the overlays in sequence as
> +they are declared in the configuration.
> +
> +Note the minimum amount of different DT blobs, as well as the requirement for
> +the DT blobs to have a load address; the overlay application requires the blobs
> +to be writeable.
> +
> +Configuration using overlays and feature selection
> +--------------------------------------------------
> +
> +Although the configuration in the previous section works is a bit inflexible
> +since it requires all possible configuration options to be laid out before
> +hand in the FIT image. For the add-on boards the extra config selection method
> +might make sense.
> +
> +Note the two bar & baz configuration nodes. To boot a reva board with
> +the bar add-on board enabled simply use:
> +
> +	# bootm <addr>#foo-reva.dtb#bar
> +
> +While booting a revb with bar and baz is as follows:
> +
> +	# bootm <addr>#foo-revb.dtb#bar#baz
> +
> +The limitation for a feature selection configuration node is that a single
> +fdt option is currently supported.
> +
> +Pantelis Antoniou
> +pantelis.antoniou at konsulko.com
> +12/6/2017
> diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
> index 136d3d7..ba8013a 100644
> --- a/doc/uImage.FIT/source_file_format.txt
> +++ b/doc/uImage.FIT/source_file_format.txt
> @@ -235,7 +235,7 @@ o config at 1
>     |- description = "configuration description"
>     |- kernel = "kernel sub-node unit name"
>     |- ramdisk = "ramdisk sub-node unit name"
> -  |- fdt = "fdt sub-node unit-name"
> +  |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...]
>     |- fpga = "fpga sub-node unit-name"
>     |- loadables = "loadables sub-node unit-name"
>   
> @@ -249,7 +249,9 @@ o config at 1
>     - ramdisk : Unit name of the corresponding ramdisk image (component image
>       node of a "ramdisk" type).
>     - fdt : Unit name of the corresponding fdt blob (component image node of a
> -    "fdt type").
> +    "fdt type"). Additional fdt overlay nodes can be supplied which signify
> +    that the resulting device tree blob is generated by the first base fdt
> +    blob with all subsequent overlays applied.
>     - setup : Unit name of the corresponding setup binary (used for booting
>       an x86 kernel). This contains the setup.bin file built by the kernel.
>     - fpga : Unit name of the corresponding fpga bitstream blob
> 

Reviewed-by: Łukasz Majewski


I'm just curious - what was the fit image size reduction on your test setup?

-- 
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
@ 2017-09-06 19:07   ` Łukasz Majewski
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: Łukasz Majewski @ 2017-09-06 19:07 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 2005 bytes --]

On 09/04/2017 10:12 PM, Pantelis Antoniou wrote:
> We have the capability to apply overlays on the command line but
> we didn't have a document explaining how.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>   doc/README.fdt-overlays | 37 +++++++++++++++++++++++++++++++++++++
>   1 file changed, 37 insertions(+)
>   create mode 100644 doc/README.fdt-overlays
> 
> diff --git a/doc/README.fdt-overlays b/doc/README.fdt-overlays
> new file mode 100644
> index 0000000..ee868ec
> --- /dev/null
> +++ b/doc/README.fdt-overlays
> @@ -0,0 +1,37 @@
> +U-Boot FDT Overlay usage (without FIT images)
> +=============================================
> +
> +FDT overlays are now available for use even without FIT images.
> +It is not as automagic as with FIT images though and require a few
> +manual steps.
> +
> +1. Figure out where to place both the base device tree blob and the
> +overlay. Make sure you have enough space to grow the base tree without
> +overlapping anything.
> +
> +=> setenv fdtaddr 0x87f00000
> +=> setenv fdtovaddr 0x87fc0000
> +
> +2. Load the base blob and overlay blobs
> +
> +=> load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/base.dtb
> +=> load ${devtype} ${bootpart} ${fdtovaddr} ${bootdir}/overlay.dtb
> +
> +3. Set it as the working fdt tree.
> +
> +=> fdtaddr $fdtaddr
> +
> +4. Grow it enough so it can 'fit' all the applied overlays
> +
> +=> fdt resize 8192
> +
> +5. You are now ready to apply the overlay.
> +
> +=> fdt apply $fdtovaddr
> +
> +Please note that in case of an error, both the base and overlays are going
> +to be invalidated, so keep copies to avoid reloading.
> +
> +Pantelis Antoniou
> +pantelis.antoniou at konsulko.com
> +11/7/2017
> 

Reviewed-by: Łukasz Majewski

-- 
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
@ 2017-09-06 19:10   ` Łukasz Majewski
  2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: Łukasz Majewski @ 2017-09-06 19:10 UTC (permalink / raw)
  To: u-boot

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="windows-1254", Size: 4710 bytes --]

On 09/04/2017 10:12 PM, Pantelis Antoniou wrote:
> From: Franklin S Cooper Jr <fcooper@ti.com>
> 
> Pull some information regarding overlays from commit messages and
> put them directly within the documentation. Also add some information
> regarding required dtc version to properly use overlays.
> 
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> ---
>   doc/README.fdt-overlays             | 85 +++++++++++++++++++++++++++++++++++--
>   doc/uImage.FIT/overlay-fdt-boot.txt |  8 +++-
>   2 files changed, 87 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/README.fdt-overlays b/doc/README.fdt-overlays
> index ee868ec..39139cb 100644
> --- a/doc/README.fdt-overlays
> +++ b/doc/README.fdt-overlays
> @@ -1,9 +1,76 @@
> -U-Boot FDT Overlay usage (without FIT images)
> +U-Boot FDT Overlay usage
>   =============================================
>   
> -FDT overlays are now available for use even without FIT images.
> -It is not as automagic as with FIT images though and require a few
> -manual steps.
> +Overlays Syntax
> +---------------
> +
> +Overlays require slightly different syntax compared to traditional overlays.
> +Please refer to dt-object-internal.txt in the dtc sources for information
> +regarding the internal format of overlays:
> +https://git.kernel.org/pub/scm/utils/dtc/dtc.git/tree/Documentation/dt-object-internal.txt
> +
> +Building Overlays
> +-----------------
> +
> +In a nutshell overlays provides a means to manipulate a symbol a previous dtb
> +or overlay has defined. It requires both the base and all the overlays
> +to be compiled with the -@ command line switch so that symbol information is
> +included.
> +
> +Note support for -@ option can only be found in dtc version 1.4.4 or newer.
> +Only version 4.14 or higher of the Linux kernel includes a built in version
> +of dtc that meets this requirement.
> +
> +Building an overlay follows the same process as building a traditional dtb.
> +
> +For example:
> +
> +base.dts
> +--------
> +
> +	/dts-v1/;
> +	/ {
> +		foo: foonode {
> +			foo-property;
> +		};
> +	};
> +
> +	$ dtc -@ -I dts -O dtb -o base.dtb base.dts
> +
> +bar.dts
> +-------
> +
> +	/dts-v1/;
> +	/plugin/;
> +	/ {
> +		fragment at 1 {
> +			target = <&foo>;
> +			__overlay__ {
> +				overlay-1-property;
> +				bar: barnode {
> +					bar-property;
> +				};
> +			};
> +		};
> +	};
> +
> +	$ dtc -@ -I dts -O dtb -o bar.dtb bar.dts
> +
> +Ways to Utilize Overlays in U-boot
> +----------------------------------
> +
> +There are two ways to apply overlays in U-boot.
> +1. Include and define overlays within a FIT image and have overlays
> +   automatically applied.
> +
> +2. Manually load and apply overlays
> +
> +The remainder of this document will discuss using overlays via the manual
> +approach. For information on using overlays as part of a FIT image please see:
> +doc/uImage.FIT/overlay-fdt-boot.txt
> +
> +Manually Loading and Applying Overlays
> +--------------------------------------
>   
>   1. Figure out where to place both the base device tree blob and the
>   overlay. Make sure you have enough space to grow the base tree without
> @@ -29,6 +96,16 @@ overlapping anything.
>   
>   => fdt apply $fdtovaddr
>   
> +6. Boot system like you would do with a traditional dtb.
> +
> +For bootm:
> +
> +=> bootm ${kerneladdr} - ${fdtaddr}
> +
> +For bootz:
> +
> +=> bootz ${kerneladdr} - ${fdtaddr}
> +
>   Please note that in case of an error, both the base and overlays are going
>   to be invalidated, so keep copies to avoid reloading.
>   
> diff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt
> index dbdf2a1..63e47da 100644
> --- a/doc/uImage.FIT/overlay-fdt-boot.txt
> +++ b/doc/uImage.FIT/overlay-fdt-boot.txt
> @@ -1,5 +1,5 @@
> -U-Boot FDT Overlay usage
> -========================
> +U-Boot FDT Overlay FIT usage
> +============================
>   
>   Introduction
>   ------------
> @@ -8,6 +8,10 @@ of similar boards and their expansion options. The same kernel on DT enabled
>   platforms can support this easily enough by providing a DT blob upon boot
>   that matches the desired configuration.
>   
> +This document focuses on specifically using overlays as part of a FIT image.
> +General information regarding overlays including its syntax and building it
> +can be found in doc/README.fdt-overlays
> +
>   Configuration without overlays
>   ------------------------------
>   
> 

Reviwed-by: Łukasz Majewski

-- 
Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc
  2017-09-06 19:06   ` Łukasz Majewski
@ 2017-09-07  6:52     ` Pantelis Antoniou
  0 siblings, 0 replies; 57+ messages in thread
From: Pantelis Antoniou @ 2017-09-07  6:52 UTC (permalink / raw)
  To: u-boot

Hi Lukasz,

On Wed, 2017-09-06 at 21:06 +0200, Łukasz Majewski wrote:
> On 09/04/2017 10:12 PM, Pantelis Antoniou wrote:
> > Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> > ---
> >   doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
> >   doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++
> >   doc/uImage.FIT/source_file_format.txt        |   6 +-
> >   3 files changed, 236 insertions(+), 3 deletions(-)
> >   create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
> > 
> > diff --git a/doc/uImage.FIT/command_syntax_extensions.txt b/doc/uImage.FIT/command_syntax_extensions.txt
> > index 6c99b1c..676f992 100644
> > --- a/doc/uImage.FIT/command_syntax_extensions.txt
> > +++ b/doc/uImage.FIT/command_syntax_extensions.txt
> > @@ -36,7 +36,7 @@ Old uImage:
> >   New uImage:
> >   8.  bootm <addr1>
> >   9.  bootm [<addr1>]:<subimg1>
> > -10. bootm [<addr1>]#<conf>
> > +10. bootm [<addr1>]#<conf>[#<extra-conf[#...]]
> >   11. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2>
> >   12. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> [<addr3>]:<subimg3>
> >   13. bootm [<addr1>]:<subimg1> [<addr2>]:<subimg2> <addr3>
> > @@ -129,6 +129,12 @@ following syntax:
> >   - new uImage configuration specification
> >   <addr>#<configuration unit_name>
> >   
> > +- new uImage configuration specification with extra configuration components
> > +<addr>#<configuration unit_name>[#<extra configuration unit_name>[#..]]
> > +
> > +The extra configuration currently is supported only for additional device tree
> > +overlays to apply on the base device tree supplied by the first configuration
> > +unit.
> >   
> >   Examples:
> >   
> > @@ -138,6 +144,10 @@ bootm 200000:kernel at 1
> >   - boot configuration "cfg at 1" from a new uImage located at 200000:
> >   bootm 200000#cfg at 1
> >   
> > +- boot configuration "cfg at 1" with extra "cfg at 2" from a new uImage located
> > +  at 200000:
> > +bootm 200000#cfg at 1#cfg at 2
> > +
> >   - boot "kernel at 1" from a new uImage at 200000 with initrd "ramdisk at 2" found in
> >     some other new uImage stored at address 800000:
> >   bootm 200000:kernel at 1 800000:ramdisk at 2
> > diff --git a/doc/uImage.FIT/overlay-fdt-boot.txt b/doc/uImage.FIT/overlay-fdt-boot.txt
> > new file mode 100644
> > index 0000000..dbdf2a1
> > --- /dev/null
> > +++ b/doc/uImage.FIT/overlay-fdt-boot.txt
> > @@ -0,0 +1,221 @@
> > +U-Boot FDT Overlay usage
> > +========================
> > +
> > +Introduction
> > +------------
> > +In many cases it is desirable to have a single FIT image support a multitude
> > +of similar boards and their expansion options. The same kernel on DT enabled
> > +platforms can support this easily enough by providing a DT blob upon boot
> > +that matches the desired configuration.
> > +
> > +Configuration without overlays
> > +------------------------------
> > +
> > +Take a hypothetical board named 'foo' where there are different supported
> > +revisions, reva and revb. Assume that both board revisions can use add a bar
> > +add-on board, while only the revb board can use a baz add-on board.
> > +
> > +Without using overlays the configuration would be as follows for every case.
> > +
> > +	/dts-v1/;
> > +	/ {
> > +		images {
> > +			kernel at 1 {
> > +				data = /incbin/("./zImage");
> > +				type = "kernel";
> > +				arch = "arm";
> > +				os = "linux";
> > +				load = <0x82000000>;
> > +				entry = <0x82000000>;
> > +			};
> > +			fdt at 1 {
> > +				data = /incbin/("./foo-reva.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +			fdt at 2 {
> > +				data = /incbin/("./foo-revb.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +			fdt at 3 {
> > +				data = /incbin/("./foo-reva-bar.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +			fdt at 4 {
> > +				data = /incbin/("./foo-revb-bar.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +			fdt at 5 {
> > +				data = /incbin/("./foo-revb-baz.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +			fdt at 6 {
> > +				data = /incbin/("./foo-revb-bar-baz.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +			};
> > +		};
> > +
> > +		configurations {
> > +			default = "foo-reva.dtb;
> > +			foo-reva.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1";
> > +			};
> > +			foo-revb.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 2";
> > +			};
> > +			foo-reva-bar.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 3";
> > +			};
> > +			foo-revb-bar.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 4";
> > +			};
> > +			foo-revb-baz.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 5";
> > +			};
> > +			foo-revb-bar-baz.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 6";
> > +			};
> > +		};
> > +	};
> > +
> > +Note the blob needs to be compiled for each case and the combinatorial explosion of
> > +configurations. A typical device tree blob is in the low hunderds of kbytes so a
> > +multitude of configuration grows the image quite a bit.
> > +
> > +Booting this image is done by using
> > +
> > +	# bootm <addr>#<config>
> > +
> > +Where config is one of:
> > +	foo-reva.dtb, foo-revb.dtb, foo-reva-bar.dtb, foo-revb-bar.dtb,
> > +	foo-revb-baz.dtb, foo-revb-bar-baz.dtb
> > +
> > +This selects the DTB to use when booting.
> > +
> > +Configuration using overlays
> > +----------------------------
> > +
> > +Device tree overlays can be applied to a base DT and result in the same blob
> > +being passed to the booting kernel. This saves on space and avoid the combinatorial
> > +explosion problem.
> > +
> > +	/dts-v1/;
> > +	/ {
> > +		images {
> > +			kernel at 1 {
> > +				data = /incbin/("./zImage");
> > +				type = "kernel";
> > +				arch = "arm";
> > +				os = "linux";
> > +				load = <0x82000000>;
> > +				entry = <0x82000000>;
> > +			};
> > +			fdt at 1 {
> > +				data = /incbin/("./foo.dtb");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +				load = <0x87f00000>;
> > +			};
> > +			fdt at 2 {
> > +				data = /incbin/("./reva.dtbo");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +				load = <0x87fc0000>;
> > +			};
> > +			fdt at 3 {
> > +				data = /incbin/("./revb.dtbo");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +				load = <0x87fc0000>;
> > +			};
> > +			fdt at 4 {
> > +				data = /incbin/("./bar.dtbo");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +				load = <0x87fc0000>;
> > +			};
> > +			fdt at 5 {
> > +				data = /incbin/("./baz.dtbo");
> > +				type = "flat_dt";
> > +				arch = "arm";
> > +				load = <0x87fc0000>;
> > +			};
> > +		};
> > +
> > +		configurations {
> > +			default = "foo-reva.dtb;
> > +			foo-reva.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 2";
> > +			};
> > +			foo-revb.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 3";
> > +			};
> > +			foo-reva-bar.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 2", "fdt at 4";
> > +			};
> > +			foo-revb-bar.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 3", "fdt at 4";
> > +			};
> > +			foo-revb-baz.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 3", "fdt at 5";
> > +			};
> > +			foo-revb-bar-baz.dtb {
> > +				kernel = "kernel at 1";
> > +				fdt = "fdt at 1", "fdt at 3", "fdt at 4", "fdt at 5";
> > +			};
> > +			bar {
> > +				fdt = "fdt at 4";
> > +			};
> > +			baz {
> > +				fdt = "fdt at 5";
> > +			};
> > +		};
> > +	};
> > +
> > +Booting this image is exactly the same as the non-overlay example.
> > +u-boot will retrieve the base blob and apply the overlays in sequence as
> > +they are declared in the configuration.
> > +
> > +Note the minimum amount of different DT blobs, as well as the requirement for
> > +the DT blobs to have a load address; the overlay application requires the blobs
> > +to be writeable.
> > +
> > +Configuration using overlays and feature selection
> > +--------------------------------------------------
> > +
> > +Although the configuration in the previous section works is a bit inflexible
> > +since it requires all possible configuration options to be laid out before
> > +hand in the FIT image. For the add-on boards the extra config selection method
> > +might make sense.
> > +
> > +Note the two bar & baz configuration nodes. To boot a reva board with
> > +the bar add-on board enabled simply use:
> > +
> > +	# bootm <addr>#foo-reva.dtb#bar
> > +
> > +While booting a revb with bar and baz is as follows:
> > +
> > +	# bootm <addr>#foo-revb.dtb#bar#baz
> > +
> > +The limitation for a feature selection configuration node is that a single
> > +fdt option is currently supported.
> > +
> > +Pantelis Antoniou
> > +pantelis.antoniou at konsulko.com
> > +12/6/2017
> > diff --git a/doc/uImage.FIT/source_file_format.txt b/doc/uImage.FIT/source_file_format.txt
> > index 136d3d7..ba8013a 100644
> > --- a/doc/uImage.FIT/source_file_format.txt
> > +++ b/doc/uImage.FIT/source_file_format.txt
> > @@ -235,7 +235,7 @@ o config at 1
> >     |- description = "configuration description"
> >     |- kernel = "kernel sub-node unit name"
> >     |- ramdisk = "ramdisk sub-node unit name"
> > -  |- fdt = "fdt sub-node unit-name"
> > +  |- fdt = "fdt sub-node unit-name" [, "fdt overlay sub-node unit-name", ...]
> >     |- fpga = "fpga sub-node unit-name"
> >     |- loadables = "loadables sub-node unit-name"
> >   
> > @@ -249,7 +249,9 @@ o config at 1
> >     - ramdisk : Unit name of the corresponding ramdisk image (component image
> >       node of a "ramdisk" type).
> >     - fdt : Unit name of the corresponding fdt blob (component image node of a
> > -    "fdt type").
> > +    "fdt type"). Additional fdt overlay nodes can be supplied which signify
> > +    that the resulting device tree blob is generated by the first base fdt
> > +    blob with all subsequent overlays applied.
> >     - setup : Unit name of the corresponding setup binary (used for booting
> >       an x86 kernel). This contains the setup.bin file built by the kernel.
> >     - fpga : Unit name of the corresponding fpga bitstream blob
> > 
> 
> Reviewed-by: Łukasz Majewski
> 
> 
> I'm just curious - what was the fit image size reduction on your test setup?
> 

I haven't measured, but it's easy to calculate.

Assume each base blob is B bytes in average with each additional overlay
being Oi extra bytes when included in the base and O bytes (in average)
when compiled as an overlay (with O > Oi, overhead is almost constant -
O = Oi + C). Then for n cases:

The size of a non-overlay case is:

  Si = (B + Oi) * n = B * n + Oi * n

The size of an overlay case is

  So = B + O * n = B + (Oi + C) * n = B + Oi * n + C * n

The delta in size is:

  d = Si - So = B * n + Qi * n - B - Oi * n - C * n = 
    = B * (n - 1) - C * n

For contemporary device trees (which are in the 140K sizes) and
the average overhead at about 200 bytes.

  d = 140K * (n - 1) - 200 * n

It's pretty much a win even at n = 2.

For example for n = 5 (a common case).

  d = 140K * (5 - 1) - 200 * 5 = 559K

It's not earth-shattering smaller, but it's significant.

Regards

-- Pantelis

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:25   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> In some cases you need to add a property but the contents of it
> are not known at creation time, merely the extend of it.
>
> This method allows you to create a property of a given size (filled
> with garbage) while a pointer to the property data will be provided.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> [dwg: Corrected commit message]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  lib/libfdt/fdt_rw.c | 20 +++++++++++++++++---
>  lib/libfdt/libfdt.h | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+), 3 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose()
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose() Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:25   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Introduce fdt_overlay_apply_verbose, a method that applies an
> overlay but in the case of an error produces a helpful message.
>
> In addition if a base tree is found to be missing the __symbols__
> node the message will point out that the probable reason is that
> the base tree was miscompiled without the -@ option.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/fdt_support.c  | 31 +++++++++++++++++++++++++++++++
>  include/fdt_support.h |  2 ++
>  2 files changed, 33 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>

BTW I'd prefer to have the function comments in the header, but this
file is mixed, so OK.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:26     ` Simon Glass
  0 siblings, 1 reply; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> The verbose overlay application method prints out more helpful
> messages, so switch to it.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  cmd/fdt.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> This patch enables an overlay to refer to a previous overlay's
> labels by performing a merge of symbol information at application
> time.
>
> In a nutshell it allows an overlay to refer to a symbol that a previous
> overlay has defined. It requires both the base and all the overlays
> to be compiled with the -@ command line switch so that symbol
> information is included.
>
> base.dts
> --------
>
>         /dts-v1/;
>         / {
>                 foo: foonode {
>                         foo-property;
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o base.dtb base.dts
>
> bar.dts
> -------
>
>         /dts-v1/;
>         /plugin/;
>         / {
>                 fragment at 1 {
>                         target = <&foo>;
>                         __overlay__ {
>                                 overlay-1-property;
>                                 bar: barnode {
>                                         bar-property;
>                                 };
>                         };
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o bar.dtb bar.dts
>
> baz.dts
> -------
>
>         /dts-v1/;
>         /plugin/;
>         / {
>                 fragment at 1 {
>                         target = <&bar>;
>                         __overlay__ {
>                                 overlay-2-property;
>                                 baz: baznode {
>                                         baz-property;
>                                 };
>                         };
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o baz.dtb baz.dts
>
> Applying the overlays:
>
>         $ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb
>
> Dumping:
>
>         $ fdtdump target.dtb
>         / {
>             foonode {
>                 overlay-1-property;
>                 foo-property;
>                 linux,phandle = <0x00000001>;
>                 phandle = <0x00000001>;
>                 barnode {
>                     overlay-2-property;
>                     phandle = <0x00000002>;
>                     linux,phandle = <0x00000002>;
>                     bar-property;
>                     baznode {
>                         phandle = <0x00000003>;
>                         linux,phandle = <0x00000003>;
>                         baz-property;
>                     };
>                 };
>             };
>             __symbols__ {
>                 baz = "/foonode/barnode/baznode";
>                 bar = "/foonode/barnode";
>                 foo = "/foonode";
>             };
>         };
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  lib/libfdt/fdt_overlay.c | 228 ++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 206 insertions(+), 22 deletions(-)
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> As part of the fdt overlay support which need it, allow
> a list of configurations per property.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fit.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load()
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load() Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

Hi,

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> fit_image_load() threw away the extra configuration parts when
> loading. We need them around for applying extra overlays for
> building the boot fdt.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fit.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

>
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 74e5557..e75cb64 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -1653,6 +1653,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
>         int cfg_noffset, noffset;
>         const char *fit_uname;
>         const char *fit_uname_config;
> +       const char *fit_base_uname_config;
>         const void *fit;
>         const void *buf;
>         size_t size;
> @@ -1668,6 +1669,7 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
>         fit = map_sysmem(addr, 0);
>         fit_uname = fit_unamep ? *fit_unamep : NULL;
>         fit_uname_config = fit_uname_configp ? *fit_uname_configp : NULL;
> +       fit_base_uname_config = NULL;
>         prop_name = fit_get_image_type_property(image_type);
>         printf("## Loading %s from FIT Image at %08lx ...\n", prop_name, addr);
>
> @@ -1701,11 +1703,11 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
>                                         BOOTSTAGE_SUB_NO_UNIT_NAME);
>                         return -ENOENT;
>                 }
> -               fit_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
> -               printf("   Using '%s' configuration\n", fit_uname_config);
> +               fit_base_uname_config = fdt_get_name(fit, cfg_noffset, NULL);
> +               printf("   Using '%s' configuration\n", fit_base_uname_config);
>                 if (image_type == IH_TYPE_KERNEL) {
>                         /* Remember (and possibly verify) this config */
> -                       images->fit_uname_cfg = fit_uname_config;
> +                       images->fit_uname_cfg = fit_base_uname_config;
>                         if (IMAGE_ENABLE_VERIFY && images->verify) {
>                                 puts("   Verifying Hash Integrity ... ");
>                                 if (fit_config_verify(fit, cfg_noffset)) {
> @@ -1861,7 +1863,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
>         if (fit_unamep)
>                 *fit_unamep = (char *)fit_uname;
>         if (fit_uname_configp)
> -               *fit_uname_configp = (char *)fit_uname_config;
> +               *fit_uname_configp = (char *)(fit_uname_config ? :
> +                                             fit_base_uname_config);

I just learned something I didn't know about C.

>
>         return noffset;
>  }
> --
> 2.1.4
>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Introduce an overlay based method for constructing a base DT blob
> to pass to the kernel.
>
> It is based on a specific method now to get the FDT from a FIT image
> named boot_get_fdt_fit().
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fdt.c |   7 +--
>  common/image-fit.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++--
>  include/image.h    |  25 ++++++++
>  3 files changed, 205 insertions(+), 8 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

I wonder if you can use if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY))
instead of #if ?

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
  2017-09-06 19:06   ` Łukasz Majewski
@ 2017-09-09  4:53   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:53 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
>  doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++
>  doc/uImage.FIT/source_file_format.txt        |   6 +-
>  3 files changed, 236 insertions(+), 3 deletions(-)
>  create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
  2017-09-06 19:07   ` Łukasz Majewski
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> We have the capability to apply overlays on the command line but
> we didn't have a document explaining how.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  doc/README.fdt-overlays | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>  create mode 100644 doc/README.fdt-overlays
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
  2017-09-06 19:10   ` Łukasz Majewski
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> From: Franklin S Cooper Jr <fcooper@ti.com>
>
> Pull some information regarding overlays from commit messages and
> put them directly within the documentation. Also add some information
> regarding required dtc version to properly use overlays.
>
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> ---
>  doc/README.fdt-overlays             | 85 +++++++++++++++++++++++++++++++++++--
>  doc/uImage.FIT/overlay-fdt-boot.txt |  8 +++-
>  2 files changed, 87 insertions(+), 6 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special Pantelis Antoniou
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 15:50   ` Stephen Warren
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Special rule for dtbo generation
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  scripts/Makefile.lib | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests Pantelis Antoniou
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Add unit tests for sandbox default config.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  configs/sandbox_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change Pantelis Antoniou
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> fdt_getprop_u32 is not exported and it's different than what the
> unit test uses. Rename u32 prop access methods to something that's
> unit test specific.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  test/overlay/cmd_ut_overlay.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
@ 2017-09-09  4:54   ` Simon Glass
  2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-09  4:54 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Verify that stacked overlays work.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  test/overlay/Makefile                     |  1 +
>  test/overlay/cmd_ut_overlay.c             | 34 ++++++++++++++++++++++++++++++-
>  test/overlay/test-fdt-overlay-stacked.dts | 21 +++++++++++++++++++
>  3 files changed, 55 insertions(+), 1 deletion(-)
>  create mode 100644 test/overlay/test-fdt-overlay-stacked.dts

Acked-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
  2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
                   ` (13 preceding siblings ...)
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
@ 2017-09-14  0:53 ` Simon Glass
  2017-09-14  1:03   ` Tom Rini
  2017-09-14 15:30   ` Tom Rini
  14 siblings, 2 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-14  0:53 UTC (permalink / raw)
  To: u-boot

Hi Pantelis,

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> This patchset allows uboot to handle overlays in a manner that uses
> a base DT blob and an arbitrary number of DT overlays blobs.
>
> While it is intended to be used with FIT images since handling a multitude
> of device tree blobs manually is a chore, manual fdt overlay application
> is supported and described.
>
> Changes since v2:
> * Addressed review comments by splitting patches and documenting methods.
> * Patch preserving extra configuration on fit-load
>
> The patchset is available at
>
>         https://github.com/pantoniou/u-boot/tree/uboot-overlays
>
> and is against mainline u-boot as pulled today, 4/9/2017.
>
> Franklin S Cooper Jr (1):
>   doc: overlays: Tweak documentation regarding overlays
>
> Pantelis Antoniou (13):
>   Introduce fdt_setprop_placeholder() method
>   fdt: Introduce helper method fdt_overlay_apply_verbose()
>   fdt: Switch to using the verbose overlay application method
>   fdt: Allow stacked overlays phandle references
>   fit: Allow multiple images per property
>   fit: Do not throw away extra configuration on fit_image_load()
>   fit: Introduce methods for applying overlays on fit-load
>   fit: fdt overlays doc
>   doc: Document how to apply fdt overlays
>   dtbo: make dtbos special
>   config: sandbox: Add unit tests
>   ut: fix fdt_getprop_u32() change
>   test: overlay: Add unit test for stacked overlay

I applied this series (to u-boot-fdt/testing) but it requires a later
version of dtc than we use in our travis tests:

https://travis-ci.org/sglass68/u-boot/jobs/275239527

Could you please take a look? I don't think I can pull this in until I
know it can make it to mainline.

The good news is that with the new dtc my buildman test went through
with no errors.

>
>  cmd/fdt.c                                    |   7 +-
>  common/fdt_support.c                         |  31 ++++
>  common/image-fdt.c                           |   7 +-
>  common/image-fit.c                           | 210 ++++++++++++++++++++++--
>  configs/sandbox_defconfig                    |   2 +
>  doc/README.fdt-overlays                      | 114 ++++++++++++++
>  doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
>  doc/uImage.FIT/overlay-fdt-boot.txt          | 225 ++++++++++++++++++++++++++
>  doc/uImage.FIT/source_file_format.txt        |   6 +-
>  include/fdt_support.h                        |   2 +
>  include/image.h                              |  25 +++
>  lib/libfdt/fdt_overlay.c                     | 228 ++++++++++++++++++++++++---
>  lib/libfdt/fdt_rw.c                          |  20 ++-
>  lib/libfdt/libfdt.h                          |  31 ++++
>  scripts/Makefile.lib                         |  17 ++
>  test/overlay/Makefile                        |   1 +
>  test/overlay/cmd_ut_overlay.c                |  50 ++++--
>  test/overlay/test-fdt-overlay-stacked.dts    |  21 +++
>  18 files changed, 953 insertions(+), 56 deletions(-)
>  create mode 100644 doc/README.fdt-overlays
>  create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
>  create mode 100644 test/overlay/test-fdt-overlay-stacked.dts
>
> --
> 2.1.4
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
  2017-09-14  0:53 ` [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Simon Glass
@ 2017-09-14  1:03   ` Tom Rini
  2017-09-14 11:23     ` Tom Rini
  2017-09-14 15:30   ` Tom Rini
  1 sibling, 1 reply; 57+ messages in thread
From: Tom Rini @ 2017-09-14  1:03 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 13, 2017 at 06:53:17PM -0600, Simon Glass wrote:
> Hi Pantelis,
> 
> On 4 September 2017 at 14:12, Pantelis Antoniou
> <pantelis.antoniou@konsulko.com> wrote:
> > This patchset allows uboot to handle overlays in a manner that uses
> > a base DT blob and an arbitrary number of DT overlays blobs.
> >
> > While it is intended to be used with FIT images since handling a multitude
> > of device tree blobs manually is a chore, manual fdt overlay application
> > is supported and described.
> >
> > Changes since v2:
> > * Addressed review comments by splitting patches and documenting methods.
> > * Patch preserving extra configuration on fit-load
> >
> > The patchset is available at
> >
> >         https://github.com/pantoniou/u-boot/tree/uboot-overlays
> >
> > and is against mainline u-boot as pulled today, 4/9/2017.
> >
> > Franklin S Cooper Jr (1):
> >   doc: overlays: Tweak documentation regarding overlays
> >
> > Pantelis Antoniou (13):
> >   Introduce fdt_setprop_placeholder() method
> >   fdt: Introduce helper method fdt_overlay_apply_verbose()
> >   fdt: Switch to using the verbose overlay application method
> >   fdt: Allow stacked overlays phandle references
> >   fit: Allow multiple images per property
> >   fit: Do not throw away extra configuration on fit_image_load()
> >   fit: Introduce methods for applying overlays on fit-load
> >   fit: fdt overlays doc
> >   doc: Document how to apply fdt overlays
> >   dtbo: make dtbos special
> >   config: sandbox: Add unit tests
> >   ut: fix fdt_getprop_u32() change
> >   test: overlay: Add unit test for stacked overlay
> 
> I applied this series (to u-boot-fdt/testing) but it requires a later
> version of dtc than we use in our travis tests:
> 
> https://travis-ci.org/sglass68/u-boot/jobs/275239527

The -@ flag has been around for a long time, relatively speaking.  Is
there a problem in our .travis.yml perhaps where it's not picking up the
dtc we're building from git?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170913/37dc2ef9/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
  2017-09-14  1:03   ` Tom Rini
@ 2017-09-14 11:23     ` Tom Rini
  2017-09-14 11:25       ` Tom Rini
  0 siblings, 1 reply; 57+ messages in thread
From: Tom Rini @ 2017-09-14 11:23 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 13, 2017 at 09:03:38PM -0400, Tom Rini wrote:
> On Wed, Sep 13, 2017 at 06:53:17PM -0600, Simon Glass wrote:
> > Hi Pantelis,
> > 
> > On 4 September 2017 at 14:12, Pantelis Antoniou
> > <pantelis.antoniou@konsulko.com> wrote:
> > > This patchset allows uboot to handle overlays in a manner that uses
> > > a base DT blob and an arbitrary number of DT overlays blobs.
> > >
> > > While it is intended to be used with FIT images since handling a multitude
> > > of device tree blobs manually is a chore, manual fdt overlay application
> > > is supported and described.
> > >
> > > Changes since v2:
> > > * Addressed review comments by splitting patches and documenting methods.
> > > * Patch preserving extra configuration on fit-load
> > >
> > > The patchset is available at
> > >
> > >         https://github.com/pantoniou/u-boot/tree/uboot-overlays
> > >
> > > and is against mainline u-boot as pulled today, 4/9/2017.
> > >
> > > Franklin S Cooper Jr (1):
> > >   doc: overlays: Tweak documentation regarding overlays
> > >
> > > Pantelis Antoniou (13):
> > >   Introduce fdt_setprop_placeholder() method
> > >   fdt: Introduce helper method fdt_overlay_apply_verbose()
> > >   fdt: Switch to using the verbose overlay application method
> > >   fdt: Allow stacked overlays phandle references
> > >   fit: Allow multiple images per property
> > >   fit: Do not throw away extra configuration on fit_image_load()
> > >   fit: Introduce methods for applying overlays on fit-load
> > >   fit: fdt overlays doc
> > >   doc: Document how to apply fdt overlays
> > >   dtbo: make dtbos special
> > >   config: sandbox: Add unit tests
> > >   ut: fix fdt_getprop_u32() change
> > >   test: overlay: Add unit test for stacked overlay
> > 
> > I applied this series (to u-boot-fdt/testing) but it requires a later
> > version of dtc than we use in our travis tests:
> > 
> > https://travis-ci.org/sglass68/u-boot/jobs/275239527
> 
> The -@ flag has been around for a long time, relatively speaking.  Is
> there a problem in our .travis.yml perhaps where it's not picking up the
> dtc we're building from git?

Yeah, it's not:
https://travis-ci.org/trini/u-boot/builds/275424745

I bet this got broken recently too, I'll see what we need to fix in the
travis environment.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170914/28e850ff/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
  2017-09-14 11:23     ` Tom Rini
@ 2017-09-14 11:25       ` Tom Rini
  0 siblings, 0 replies; 57+ messages in thread
From: Tom Rini @ 2017-09-14 11:25 UTC (permalink / raw)
  To: u-boot

On Thu, Sep 14, 2017 at 07:23:29AM -0400, Tom Rini wrote:
> On Wed, Sep 13, 2017 at 09:03:38PM -0400, Tom Rini wrote:
> > On Wed, Sep 13, 2017 at 06:53:17PM -0600, Simon Glass wrote:
> > > Hi Pantelis,
> > > 
> > > On 4 September 2017 at 14:12, Pantelis Antoniou
> > > <pantelis.antoniou@konsulko.com> wrote:
> > > > This patchset allows uboot to handle overlays in a manner that uses
> > > > a base DT blob and an arbitrary number of DT overlays blobs.
> > > >
> > > > While it is intended to be used with FIT images since handling a multitude
> > > > of device tree blobs manually is a chore, manual fdt overlay application
> > > > is supported and described.
> > > >
> > > > Changes since v2:
> > > > * Addressed review comments by splitting patches and documenting methods.
> > > > * Patch preserving extra configuration on fit-load
> > > >
> > > > The patchset is available at
> > > >
> > > >         https://github.com/pantoniou/u-boot/tree/uboot-overlays
> > > >
> > > > and is against mainline u-boot as pulled today, 4/9/2017.
> > > >
> > > > Franklin S Cooper Jr (1):
> > > >   doc: overlays: Tweak documentation regarding overlays
> > > >
> > > > Pantelis Antoniou (13):
> > > >   Introduce fdt_setprop_placeholder() method
> > > >   fdt: Introduce helper method fdt_overlay_apply_verbose()
> > > >   fdt: Switch to using the verbose overlay application method
> > > >   fdt: Allow stacked overlays phandle references
> > > >   fit: Allow multiple images per property
> > > >   fit: Do not throw away extra configuration on fit_image_load()
> > > >   fit: Introduce methods for applying overlays on fit-load
> > > >   fit: fdt overlays doc
> > > >   doc: Document how to apply fdt overlays
> > > >   dtbo: make dtbos special
> > > >   config: sandbox: Add unit tests
> > > >   ut: fix fdt_getprop_u32() change
> > > >   test: overlay: Add unit test for stacked overlay
> > > 
> > > I applied this series (to u-boot-fdt/testing) but it requires a later
> > > version of dtc than we use in our travis tests:
> > > 
> > > https://travis-ci.org/sglass68/u-boot/jobs/275239527
> > 
> > The -@ flag has been around for a long time, relatively speaking.  Is
> > there a problem in our .travis.yml perhaps where it's not picking up the
> > dtc we're building from git?
> 
> Yeah, it's not:
> https://travis-ci.org/trini/u-boot/builds/275424745
> 
> I bet this got broken recently too, I'll see what we need to fix in the
> travis environment.

Nope, it's related to me disabling newer dtc due to all of the warnings
which in turn caused travis-ci to fail due to log sizes.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170914/28cbba5b/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest
  2017-09-14  0:53 ` [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Simon Glass
  2017-09-14  1:03   ` Tom Rini
@ 2017-09-14 15:30   ` Tom Rini
  1 sibling, 0 replies; 57+ messages in thread
From: Tom Rini @ 2017-09-14 15:30 UTC (permalink / raw)
  To: u-boot

On Wed, Sep 13, 2017 at 06:53:17PM -0600, Simon Glass wrote:

> Hi Pantelis,
> 
> On 4 September 2017 at 14:12, Pantelis Antoniou
> <pantelis.antoniou@konsulko.com> wrote:
> > This patchset allows uboot to handle overlays in a manner that uses
> > a base DT blob and an arbitrary number of DT overlays blobs.
> >
> > While it is intended to be used with FIT images since handling a multitude
> > of device tree blobs manually is a chore, manual fdt overlay application
> > is supported and described.
> >
> > Changes since v2:
> > * Addressed review comments by splitting patches and documenting methods.
> > * Patch preserving extra configuration on fit-load
> >
> > The patchset is available at
> >
> >         https://github.com/pantoniou/u-boot/tree/uboot-overlays
> >
> > and is against mainline u-boot as pulled today, 4/9/2017.
> >
> > Franklin S Cooper Jr (1):
> >   doc: overlays: Tweak documentation regarding overlays
> >
> > Pantelis Antoniou (13):
> >   Introduce fdt_setprop_placeholder() method
> >   fdt: Introduce helper method fdt_overlay_apply_verbose()
> >   fdt: Switch to using the verbose overlay application method
> >   fdt: Allow stacked overlays phandle references
> >   fit: Allow multiple images per property
> >   fit: Do not throw away extra configuration on fit_image_load()
> >   fit: Introduce methods for applying overlays on fit-load
> >   fit: fdt overlays doc
> >   doc: Document how to apply fdt overlays
> >   dtbo: make dtbos special
> >   config: sandbox: Add unit tests
> >   ut: fix fdt_getprop_u32() change
> >   test: overlay: Add unit test for stacked overlay
> 
> I applied this series (to u-boot-fdt/testing) but it requires a later
> version of dtc than we use in our travis tests:
> 
> https://travis-ci.org/sglass68/u-boot/jobs/275239527
> 
> Could you please take a look? I don't think I can pull this in until I
> know it can make it to mainline.
> 
> The good news is that with the new dtc my buildman test went through
> with no errors.

OK, please add https://patchwork.ozlabs.org/patch/813888/ into your PR,
make sure it still works (as it should), and then send it along to me.
Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170914/2837e0e2/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 15:50   ` Stephen Warren
  2017-09-15 15:52     ` Stephen Warren
  1 sibling, 1 reply; 57+ messages in thread
From: Stephen Warren @ 2017-09-15 15:50 UTC (permalink / raw)
  To: u-boot

On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
> Special rule for dtbo generation

> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib

> +quiet_cmd_dtco = DTCO    $@
> +# Rule for objects only; does not put specific u-boot include at the end
> +# No generation of assembly file either
> +# Modified for U-Boot
> +cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
> +	$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
> +	$(DTC) -@ -O dtb -o $@ -b 0 \
> +		-i $(dir $<) $(DTC_FLAGS) \
> +		-d $(depfile).dtc.tmp $(dtc-tmp) ; \

As of u-boot-fdt/master commit 503afc3ca1e5 "test: overlay: Add unit 
test for stacked overlay", the U-Boot build fails for sandbox with the 
error below. I guess it's due to this commit. Does U-Boot now 
intentionally rely on a newer dtc or is this an accident?

   DTC     test/overlay/test-fdt-base.dtb
   LD      lib/libfdt/built-in.o
   CC      lib/charset.o
   CC      lib/rsa/rsa-verify.o
dtc: invalid option -- '@'
Usage: dtc [options] <input file>

Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
   -q, --quiet
	Quiet: -q suppress warnings, -qq errors, -qqq all
...

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-15 15:50   ` Stephen Warren
@ 2017-09-15 15:52     ` Stephen Warren
  2017-09-15 16:13       ` Tom Rini
  0 siblings, 1 reply; 57+ messages in thread
From: Stephen Warren @ 2017-09-15 15:52 UTC (permalink / raw)
  To: u-boot

On 09/15/2017 09:50 AM, Stephen Warren wrote:
> On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
>> Special rule for dtbo generation
> 
>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> 
>> +quiet_cmd_dtco = DTCO    $@
>> +# Rule for objects only; does not put specific u-boot include at the end
>> +# No generation of assembly file either
>> +# Modified for U-Boot
>> +cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
>> +    $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
>> +    $(DTC) -@ -O dtb -o $@ -b 0 \
>> +        -i $(dir $<) $(DTC_FLAGS) \
>> +        -d $(depfile).dtc.tmp $(dtc-tmp) ; \
> 
> As of u-boot-fdt/master commit 503afc3ca1e5 "test: overlay: Add unit 
> test for stacked overlay", the U-Boot build fails for sandbox with the 
> error below. I guess it's due to this commit. Does U-Boot now 
> intentionally rely on a newer dtc or is this an accident?
> 
>    DTC     test/overlay/test-fdt-base.dtb
>    LD      lib/libfdt/built-in.o
>    CC      lib/charset.o
>    CC      lib/rsa/rsa-verify.o
> dtc: invalid option -- '@'
> Usage: dtc [options] <input file>
> 
> Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
>    -q, --quiet
>      Quiet: -q suppress warnings, -qq errors, -qqq all
> ...

Related, the following check in Makefile doesn't trigger:

checkdtc:
	@if test $(call dtc-version) -lt 0104; then \
		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
		false; \
	fi

... because I have dtc 1.4.0. If U-Boot requires a new version now, that 
Makefile chunk should be updated.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-15 15:52     ` Stephen Warren
@ 2017-09-15 16:13       ` Tom Rini
  2017-09-15 16:21         ` Stephen Warren
  0 siblings, 1 reply; 57+ messages in thread
From: Tom Rini @ 2017-09-15 16:13 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 15, 2017 at 09:52:41AM -0600, Stephen Warren wrote:
> On 09/15/2017 09:50 AM, Stephen Warren wrote:
> >On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
> >>Special rule for dtbo generation
> >
> >>diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> >
> >>+quiet_cmd_dtco = DTCO    $@
> >>+# Rule for objects only; does not put specific u-boot include at the end
> >>+# No generation of assembly file either
> >>+# Modified for U-Boot
> >>+cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
> >>+    $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
> >>+    $(DTC) -@ -O dtb -o $@ -b 0 \
> >>+        -i $(dir $<) $(DTC_FLAGS) \
> >>+        -d $(depfile).dtc.tmp $(dtc-tmp) ; \
> >
> >As of u-boot-fdt/master commit 503afc3ca1e5 "test: overlay: Add
> >unit test for stacked overlay", the U-Boot build fails for sandbox
> >with the error below. I guess it's due to this commit. Does U-Boot
> >now intentionally rely on a newer dtc or is this an accident?
> >
> >   DTC     test/overlay/test-fdt-base.dtb
> >   LD      lib/libfdt/built-in.o
> >   CC      lib/charset.o
> >   CC      lib/rsa/rsa-verify.o
> >dtc: invalid option -- '@'
> >Usage: dtc [options] <input file>
> >
> >Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
> >   -q, --quiet
> >     Quiet: -q suppress warnings, -qq errors, -qqq all
> >...
> 
> Related, the following check in Makefile doesn't trigger:
> 
> checkdtc:
> 	@if test $(call dtc-version) -lt 0104; then \
> 		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
> 		false; \
> 	fi
> 
> ... because I have dtc 1.4.0. If U-Boot requires a new version now,
> that Makefile chunk should be updated.

Ah, this is what needs updating, yes, it needs to cehck for 1.4.3 or
newer.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/734f733b/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-15 16:13       ` Tom Rini
@ 2017-09-15 16:21         ` Stephen Warren
  2017-09-15 17:12           ` Tom Rini
  2017-09-15 19:19           ` sjg at google.com
  0 siblings, 2 replies; 57+ messages in thread
From: Stephen Warren @ 2017-09-15 16:21 UTC (permalink / raw)
  To: u-boot

On 09/15/2017 10:13 AM, Tom Rini wrote:
> On Fri, Sep 15, 2017 at 09:52:41AM -0600, Stephen Warren wrote:
>> On 09/15/2017 09:50 AM, Stephen Warren wrote:
>>> On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
>>>> Special rule for dtbo generation
>>>
>>>> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
>>>
>>>> +quiet_cmd_dtco = DTCO    $@
>>>> +# Rule for objects only; does not put specific u-boot include at the end
>>>> +# No generation of assembly file either
>>>> +# Modified for U-Boot
>>>> +cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
>>>> +    $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
>>>> +    $(DTC) -@ -O dtb -o $@ -b 0 \
>>>> +        -i $(dir $<) $(DTC_FLAGS) \
>>>> +        -d $(depfile).dtc.tmp $(dtc-tmp) ; \
>>>
>>> As of u-boot-fdt/master commit 503afc3ca1e5 "test: overlay: Add
>>> unit test for stacked overlay", the U-Boot build fails for sandbox
>>> with the error below. I guess it's due to this commit. Does U-Boot
>>> now intentionally rely on a newer dtc or is this an accident?
>>>
>>>    DTC     test/overlay/test-fdt-base.dtb
>>>    LD      lib/libfdt/built-in.o
>>>    CC      lib/charset.o
>>>    CC      lib/rsa/rsa-verify.o
>>> dtc: invalid option -- '@'
>>> Usage: dtc [options] <input file>
>>>
>>> Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
>>>    -q, --quiet
>>>      Quiet: -q suppress warnings, -qq errors, -qqq all
>>> ...
>>
>> Related, the following check in Makefile doesn't trigger:
>>
>> checkdtc:
>> 	@if test $(call dtc-version) -lt 0104; then \
>> 		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
>> 		false; \
>> 	fi
>>
>> ... because I have dtc 1.4.0. If U-Boot requires a new version now,
>> that Makefile chunk should be updated.
> 
> Ah, this is what needs updating, yes, it needs to cehck for 1.4.3 or
> newer.

Related: The Travis systems run Ubuntu 14.04 (same as my systems) and 
hence have dtc 1.4.0. If u-boot-fdt/master is merged into u-boot/master, 
the build will break in Travis.

The logic in .travis.yml to use a newer dtc (built from upstream dtc 
source) is disabled since apparently more recent dtc spew lots of 
warnings and make the logs too long for Travis. Ideally, .travis.yml 
would check out and build the exact same dtc version/tag that Makefile 
dictates as the minimum, but I'm not sure that's possible given the log 
spew issue.

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-15 16:21         ` Stephen Warren
@ 2017-09-15 17:12           ` Tom Rini
  2017-09-15 19:19           ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: Tom Rini @ 2017-09-15 17:12 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 15, 2017 at 10:21:28AM -0600, Stephen Warren wrote:
> On 09/15/2017 10:13 AM, Tom Rini wrote:
> >On Fri, Sep 15, 2017 at 09:52:41AM -0600, Stephen Warren wrote:
> >>On 09/15/2017 09:50 AM, Stephen Warren wrote:
> >>>On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
> >>>>Special rule for dtbo generation
> >>>
> >>>>diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> >>>
> >>>>+quiet_cmd_dtco = DTCO    $@
> >>>>+# Rule for objects only; does not put specific u-boot include at the end
> >>>>+# No generation of assembly file either
> >>>>+# Modified for U-Boot
> >>>>+cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
> >>>>+    $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \
> >>>>+    $(DTC) -@ -O dtb -o $@ -b 0 \
> >>>>+        -i $(dir $<) $(DTC_FLAGS) \
> >>>>+        -d $(depfile).dtc.tmp $(dtc-tmp) ; \
> >>>
> >>>As of u-boot-fdt/master commit 503afc3ca1e5 "test: overlay: Add
> >>>unit test for stacked overlay", the U-Boot build fails for sandbox
> >>>with the error below. I guess it's due to this commit. Does U-Boot
> >>>now intentionally rely on a newer dtc or is this an accident?
> >>>
> >>>   DTC     test/overlay/test-fdt-base.dtb
> >>>   LD      lib/libfdt/built-in.o
> >>>   CC      lib/charset.o
> >>>   CC      lib/rsa/rsa-verify.o
> >>>dtc: invalid option -- '@'
> >>>Usage: dtc [options] <input file>
> >>>
> >>>Options: -[qI:O:o:V:d:R:S:p:fb:i:H:sW:E:hv]
> >>>   -q, --quiet
> >>>     Quiet: -q suppress warnings, -qq errors, -qqq all
> >>>...
> >>
> >>Related, the following check in Makefile doesn't trigger:
> >>
> >>checkdtc:
> >>	@if test $(call dtc-version) -lt 0104; then \
> >>		echo '*** Your dtc is too old, please upgrade to dtc 1.4 or newer'; \
> >>		false; \
> >>	fi
> >>
> >>... because I have dtc 1.4.0. If U-Boot requires a new version now,
> >>that Makefile chunk should be updated.
> >
> >Ah, this is what needs updating, yes, it needs to cehck for 1.4.3 or
> >newer.
> 
> Related: The Travis systems run Ubuntu 14.04 (same as my systems)
> and hence have dtc 1.4.0. If u-boot-fdt/master is merged into
> u-boot/master, the build will break in Travis.
> 
> The logic in .travis.yml to use a newer dtc (built from upstream dtc
> source) is disabled since apparently more recent dtc spew lots of
> warnings and make the logs too long for Travis. Ideally, .travis.yml
> would check out and build the exact same dtc version/tag that
> Makefile dictates as the minimum, but I'm not sure that's possible
> given the log spew issue.

Right, it was a problem, but it's not now and Simon is I believe
grabbing the patch that brings us back to using dtc git.  I'm working on
patching dtc-version.sh now to give the patchlevel.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170915/3f6df58a/attachment.sig>

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Verify that stacked overlays work.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  test/overlay/Makefile                     |  1 +
>  test/overlay/cmd_ut_overlay.c             | 34 ++++++++++++++++++++++++++++++-
>  test/overlay/test-fdt-overlay-stacked.dts | 21 +++++++++++++++++++
>  3 files changed, 55 insertions(+), 1 deletion(-)
>  create mode 100644 test/overlay/test-fdt-overlay-stacked.dts

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> fdt_getprop_u32 is not exported and it's different than what the
> unit test uses. Rename u32 prop access methods to something that's
> unit test specific.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  test/overlay/cmd_ut_overlay.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests Pantelis Antoniou
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Add unit tests for sandbox default config.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  configs/sandbox_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
>

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special
  2017-09-15 16:21         ` Stephen Warren
  2017-09-15 17:12           ` Tom Rini
@ 2017-09-15 19:19           ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 15, 2017 at 10:21:28AM -0600, Stephen Warren wrote:
> On 09/15/2017 10:13 AM, Tom Rini wrote:
> >On Fri, Sep 15, 2017 at 09:52:41AM -0600, Stephen Warren wrote:
> >>On 09/15/2017 09:50 AM, Stephen Warren wrote:
> >>>On 09/04/2017 02:12 PM, Pantelis Antoniou wrote:
> >>>>Special rule for dtbo generation
> >>>
Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
  2017-09-06 19:10   ` Łukasz Majewski
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> From: Franklin S Cooper Jr <fcooper@ti.com>
>
> Pull some information regarding overlays from commit messages and
> put them directly within the documentation. Also add some information
> regarding required dtc version to properly use overlays.
>
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> ---
>  doc/README.fdt-overlays             | 85 +++++++++++++++++++++++++++++++++++--
>  doc/uImage.FIT/overlay-fdt-boot.txt |  8 +++-
>  2 files changed, 87 insertions(+), 6 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
  2017-09-06 19:07   ` Łukasz Majewski
  2017-09-09  4:54   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> We have the capability to apply overlays on the command line but
> we didn't have a document explaining how.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  doc/README.fdt-overlays | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>  create mode 100644 doc/README.fdt-overlays
>

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
  2017-09-06 19:06   ` Łukasz Majewski
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  2 siblings, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  doc/uImage.FIT/command_syntax_extensions.txt |  12 +-
>  doc/uImage.FIT/overlay-fdt-boot.txt          | 221 +++++++++++++++++++++++++++
>  doc/uImage.FIT/source_file_format.txt        |   6 +-
>  3 files changed, 236 insertions(+), 3 deletions(-)
>  create mode 100644 doc/uImage.FIT/overlay-fdt-boot.txt
>

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Introduce an overlay based method for constructing a base DT blob
> to pass to the kernel.
>
> It is based on a specific method now to get the FDT from a FIT image
> named boot_get_fdt_fit().
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fdt.c |   7 +--
>  common/image-fit.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++--
>  include/image.h    |  25 ++++++++
>  3 files changed, 205 insertions(+), 8 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

I wonder if you can use if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY))
instead of #if ?

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load()
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load() Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

Hi,

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> fit_image_load() threw away the extra configuration parts when
> loading. We need them around for applying extra overlays for
> building the boot fdt.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fit.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

>
Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> As part of the fdt overlay support which need it, allow
> a list of configurations per property.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/image-fit.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:19   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:19 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> This patch enables an overlay to refer to a previous overlay's
> labels by performing a merge of symbol information at application
> time.
>
> In a nutshell it allows an overlay to refer to a symbol that a previous
> overlay has defined. It requires both the base and all the overlays
> to be compiled with the -@ command line switch so that symbol
> information is included.
>
> base.dts
> --------
>
>         /dts-v1/;
>         / {
>                 foo: foonode {
>                         foo-property;
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o base.dtb base.dts
>
> bar.dts
> -------
>
>         /dts-v1/;
>         /plugin/;
>         / {
>                 fragment at 1 {
>                         target = <&foo>;
>                         __overlay__ {
>                                 overlay-1-property;
>                                 bar: barnode {
>                                         bar-property;
>                                 };
>                         };
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o bar.dtb bar.dts
>
> baz.dts
> -------
>
>         /dts-v1/;
>         /plugin/;
>         / {
>                 fragment at 1 {
>                         target = <&bar>;
>                         __overlay__ {
>                                 overlay-2-property;
>                                 baz: baznode {
>                                         baz-property;
>                                 };
>                         };
>                 };
>         };
>
>         $ dtc -@ -I dts -O dtb -o baz.dtb baz.dts
>
> Applying the overlays:
>
>         $ fdtoverlay -i base.dtb -o target.dtb bar.dtb baz.dtb
>
> Dumping:
>
>         $ fdtdump target.dtb
>         / {
>             foonode {
>                 overlay-1-property;
>                 foo-property;
>                 linux,phandle = <0x00000001>;
>                 phandle = <0x00000001>;
>                 barnode {
>                     overlay-2-property;
>                     phandle = <0x00000002>;
>                     linux,phandle = <0x00000002>;
>                     bar-property;
>                     baznode {
>                         phandle = <0x00000003>;
>                         linux,phandle = <0x00000003>;
>                         baz-property;
>                     };
>                 };
>             };
>             __symbols__ {
>                 baz = "/foonode/barnode/baznode";
>                 bar = "/foonode/barnode";
>                 foo = "/foonode";
>             };
>         };
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  lib/libfdt/fdt_overlay.c | 228 ++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 206 insertions(+), 22 deletions(-)
>

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose()
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose() Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:25   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:25 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> Introduce fdt_overlay_apply_verbose, a method that applies an
> overlay but in the case of an error produces a helpful message.
>
> In addition if a base tree is found to be missing the __symbols__
> node the message will point out that the probable reason is that
> the base tree was miscompiled without the -@ option.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> ---
>  common/fdt_support.c  | 31 +++++++++++++++++++++++++++++++
>  include/fdt_support.h |  2 ++
>  2 files changed, 33 insertions(+)

Acked-by: Simon Glass <sjg@chromium.org>

BTW I'd prefer to have the function comments in the header, but this
file is mixed, so OK.

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method
  2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:25   ` sjg at google.com
  1 sibling, 0 replies; 57+ messages in thread
From: sjg at google.com @ 2017-09-15 19:25 UTC (permalink / raw)
  To: u-boot

On 4 September 2017 at 14:12, Pantelis Antoniou
<pantelis.antoniou@konsulko.com> wrote:
> In some cases you need to add a property but the contents of it
> are not known at creation time, merely the extend of it.
>
> This method allows you to create a property of a given size (filled
> with garbage) while a pointer to the property data will be provided.
>
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
> [dwg: Corrected commit message]
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  lib/libfdt/fdt_rw.c | 20 +++++++++++++++++---
>  lib/libfdt/libfdt.h | 31 +++++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+), 3 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

* [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method
  2017-09-09  4:53   ` Simon Glass
@ 2017-09-15 19:26     ` Simon Glass
  0 siblings, 0 replies; 57+ messages in thread
From: Simon Glass @ 2017-09-15 19:26 UTC (permalink / raw)
  To: u-boot

On 8 September 2017 at 22:53, Simon Glass <sjg@chromium.org> wrote:
> On 4 September 2017 at 14:12, Pantelis Antoniou
> <pantelis.antoniou@konsulko.com> wrote:
>> The verbose overlay application method prints out more helpful
>> messages, so switch to it.
>>
>> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
>> ---
>>  cmd/fdt.c | 7 +++----
>>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-fdt, thanks!

^ permalink raw reply	[flat|nested] 57+ messages in thread

end of thread, other threads:[~2017-09-15 19:26 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-04 20:12 [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Pantelis Antoniou
2017-09-04 20:12 ` [U-Boot] [PATCH v3 01/14] Introduce fdt_setprop_placeholder() method Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:25   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 02/14] fdt: Introduce helper method fdt_overlay_apply_verbose() Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:25   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 03/14] fdt: Switch to using the verbose overlay application method Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:26     ` Simon Glass
2017-09-04 20:12 ` [U-Boot] [PATCH v3 04/14] fdt: Allow stacked overlays phandle references Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 05/14] fit: Allow multiple images per property Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 06/14] fit: Do not throw away extra configuration on fit_image_load() Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 07/14] fit: Introduce methods for applying overlays on fit-load Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 08/14] fit: fdt overlays doc Pantelis Antoniou
2017-09-06 19:06   ` Łukasz Majewski
2017-09-07  6:52     ` Pantelis Antoniou
2017-09-09  4:53   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 09/14] doc: Document how to apply fdt overlays Pantelis Antoniou
2017-09-06 19:07   ` Łukasz Majewski
2017-09-09  4:54   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 10/14] doc: overlays: Tweak documentation regarding overlays Pantelis Antoniou
2017-09-06 19:10   ` Łukasz Majewski
2017-09-09  4:54   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 11/14] dtbo: make dtbos special Pantelis Antoniou
2017-09-09  4:54   ` Simon Glass
2017-09-15 15:50   ` Stephen Warren
2017-09-15 15:52     ` Stephen Warren
2017-09-15 16:13       ` Tom Rini
2017-09-15 16:21         ` Stephen Warren
2017-09-15 17:12           ` Tom Rini
2017-09-15 19:19           ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 12/14] config: sandbox: Add unit tests Pantelis Antoniou
2017-09-09  4:54   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 13/14] ut: fix fdt_getprop_u32() change Pantelis Antoniou
2017-09-09  4:54   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-04 20:12 ` [U-Boot] [PATCH v3 14/14] test: overlay: Add unit test for stacked overlay Pantelis Antoniou
2017-09-09  4:54   ` Simon Glass
2017-09-15 19:19   ` sjg at google.com
2017-09-14  0:53 ` [U-Boot] [PATCH v3 00/14] uboot overlays, FIT image & unittest Simon Glass
2017-09-14  1:03   ` Tom Rini
2017-09-14 11:23     ` Tom Rini
2017-09-14 11:25       ` Tom Rini
2017-09-14 15:30   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.