Skip to contentSkip to conversation

pylibfdt: compile pylibfdt in scripts/dtc/pylibfdt only when necessary

PATCH New Masahiro Yamada 4 participants 12 messages Oct 17, 2017 – Nov 17, 2017

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

v2 cover pylibfdt: compile pylibfdt in scripts/dtc/pylibfdt only when necessary

V2: resync scripts/dtc/ with linux-next-20171016

Masahiro Yamada (3):
scripts/dtc: Update to upstream version v1.4.5-3-gb1a60033c110
pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile
pylibfdt: compile pylibfdt only when dtoc/binman is necessary

Rob Herring (1):
scripts/dtc: add fdt_overlay.c and fdt_addresses.c to sync script

 Makefile                                           |  17 +-
 arch/arm/Kconfig                                   |   1 +
 arch/x86/Kconfig                                   |   1 +
 dts/Kconfig                                        |  13 +
 scripts/Makefile.spl                               |  17 +-
 scripts/dtc/Makefile                               |   3 +
 scripts/dtc/checks.c                               | 280 +++++++
 scripts/dtc/dtc-lexer.lex.c_shipped                | 216 +++---
 scripts/dtc/dtc-parser.tab.c_shipped               | 464 +++++------
 scripts/dtc/dtc-parser.tab.h_shipped               |   8 +-
 scripts/dtc/dtc-parser.y                           |  20 +-
 scripts/dtc/dtc.h                                  |   2 +
 scripts/dtc/libfdt/fdt_addresses.c                 |  96 +++
 scripts/dtc/libfdt/fdt_overlay.c                   | 861 +++++++++++++++++++++
 scripts/dtc/livetree.c                             |  28 +
 scripts/dtc/pylibfdt/.gitignore                    |   4 +
 scripts/dtc/pylibfdt/Makefile                      |  30 +
 .../dtc/pylibfdt/libfdt.i_shipped                  |   0
 {lib/libfdt => scripts/dtc}/pylibfdt/setup.py      |   0
 scripts/dtc/update-dtc-source.sh                   |   4 +-
 scripts/dtc/version_gen.h                          |   2 +-
 tools/.gitignore                                   |   4 -
 tools/Makefile                                     |  30 -
 tools/binman/binman.py                             |   2 +-
 24 files changed, 1703 insertions(+), 400 deletions(-)
 create mode 100644 scripts/dtc/libfdt/fdt_addresses.c
 create mode 100644 scripts/dtc/libfdt/fdt_overlay.c
 create mode 100644 scripts/dtc/pylibfdt/.gitignore
 create mode 100644 scripts/dtc/pylibfdt/Makefile
 rename lib/libfdt/pylibfdt/libfdt.i => scripts/dtc/pylibfdt/libfdt.i_shipped (100%)
 rename {lib/libfdt => scripts/dtc}/pylibfdt/setup.py (100%)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/4 scripts/dtc: add fdt_overlay.c and fdt_addresses.c to sync script

From: Rob Herring <[email protected]>

libfdt has gained some new files. We need to include them in the kernel's copy.

[ Linux commit: 4322323058f010274564006d61945187a15b6361 ]

---

 scripts/dtc/update-dtc-source.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/dtc/update-dtc-source.sh +3 -1
index b8ebcc6..f3e5c59 100755
@@ -34,7 +34,9 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c
 		srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
 		dtc-lexer.l dtc-parser.y"
 DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
-LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
+LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \
+		fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \
+		fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
 
 get_last_dtc_version() {
 	git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/'
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/4 scripts/dtc: add fdt_overlay.c and fdt_addresses.c to sync script

Quoted 10 lines · Masahiro Yamada

From: Rob Herring <[email protected]>

libfdt has gained some new files. We need to include them in the kernel's copy.

[ Linux commit: 4322323058f010274564006d61945187a15b6361 ]

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/1fc8ef3e/attachment.sig>
#3 lore raw

PATCH v2 2/4 scripts/dtc: Update to upstream version v1.4.5-3-gb1a60033c110

In reply to Masahiro Yamada

This adds the following commits from upstream:

b1a6003 tests: Add a test for overlays syntactic sugar 737b2df overlay: Add syntactic sugar version of overlays 497432f checks: Use proper format modifier for size_t 22a65c5 dtc: Bump version to v1.4.5
c575d80 Add fdtoverlay to .gitignore
b6a6f94 fdtoverlay: Sanity check blob size 8c1eb15 pylibfdt: Use Python2 explicitly ee3d26f checks: add interrupts property check c1e7738 checks: add gpio binding properties check b3bbac0 checks: add phandle with arg property checks

[ sync with Linux commit: 4201d057ea91c3d6efd2db65219bc91fae413bc2 ]

---

 scripts/dtc/checks.c                 | 280 ++++++++++++
 scripts/dtc/dtc-lexer.lex.c_shipped  | 216 ++++-----
 scripts/dtc/dtc-parser.tab.c_shipped | 464 ++++++++++---------
 scripts/dtc/dtc-parser.tab.h_shipped |   8 +-
 scripts/dtc/dtc-parser.y             |  20 +-
 scripts/dtc/dtc.h                    |   2 +
 scripts/dtc/libfdt/fdt_addresses.c   |  96 ++++
 scripts/dtc/libfdt/fdt_overlay.c     | 861 +++++++++++++++++++++++++++++++++++
 scripts/dtc/livetree.c               |  28 ++
 scripts/dtc/version_gen.h            |   2 +-
 10 files changed, 1642 insertions(+), 335 deletions(-)
 create mode 100644 scripts/dtc/libfdt/fdt_addresses.c
 create mode 100644 scripts/dtc/libfdt/fdt_overlay.c
scripts/dtc/checks.c +280 -0
index afabf64..08a3a29 100644
@@ -956,6 +956,265 @@ static void check_obsolete_chosen_interrupt_controller(struct check *c,
 WARNING(obsolete_chosen_interrupt_controller,
 	check_obsolete_chosen_interrupt_controller, NULL);
 
+struct provider {
+	const char *prop_name;
+	const char *cell_name;
+	bool optional;
+};
+
+static void check_property_phandle_args(struct check *c,
+					  struct dt_info *dti,
+				          struct node *node,
+				          struct property *prop,
+				          const struct provider *provider)
+{
+	struct node *root = dti->dt;
+	int cell, cellsize = 0;
+
+	if (prop->val.len % sizeof(cell_t)) {
+		FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
+		     prop->name, prop->val.len, sizeof(cell_t), node->fullpath);
+		return;
+	}
+
+	for (cell = 0; cell < prop->val.len / sizeof(cell_t); cell += cellsize + 1) {
+		struct node *provider_node;
+		struct property *cellprop;
+		int phandle;
+
+		phandle = propval_cell_n(prop, cell);
+		/*
+		 * Some bindings use a cell value 0 or -1 to skip over optional
+		 * entries when each index position has a specific definition.
+		 */
+		if (phandle == 0 || phandle == -1) {
+			cellsize = 0;
+			continue;
+		}
+
+		/* If we have markers, verify the current cell is a phandle */
+		if (prop->val.markers) {
+			struct marker *m = prop->val.markers;
+			for_each_marker_of_type(m, REF_PHANDLE) {
+				if (m->offset == (cell * sizeof(cell_t)))
+					break;
+			}
+			if (!m)
+				FAIL(c, dti, "Property '%s', cell %d is not a phandle reference in %s",
+				     prop->name, cell, node->fullpath);
+		}
+
+		provider_node = get_node_by_phandle(root, phandle);
+		if (!provider_node) {
+			FAIL(c, dti, "Could not get phandle node for %s:%s(cell %d)",
+			     node->fullpath, prop->name, cell);
+			break;
+		}
+
+		cellprop = get_property(provider_node, provider->cell_name);
+		if (cellprop) {
+			cellsize = propval_cell(cellprop);
+		} else if (provider->optional) {
+			cellsize = 0;
+		} else {
+			FAIL(c, dti, "Missing property '%s' in node %s or bad phandle (referred from %s:%s[%d])",
+			     provider->cell_name,
+			     provider_node->fullpath,
+			     node->fullpath, prop->name, cell);
+			break;
+		}
+
+		if (prop->val.len < ((cell + cellsize + 1) * sizeof(cell_t))) {
+			FAIL(c, dti, "%s property size (%d) too small for cell size %d in %s",
+			     prop->name, prop->val.len, cellsize, node->fullpath);
+		}
+	}
+}
+
+static void check_provider_cells_property(struct check *c,
+					  struct dt_info *dti,
+				          struct node *node)
+{
+	struct provider *provider = c->data;
+	struct property *prop;
+
+	prop = get_property(node, provider->prop_name);
+	if (!prop)
+		return;
+
+	check_property_phandle_args(c, dti, node, prop, provider);
+}
+#define WARNING_PROPERTY_PHANDLE_CELLS(nm, propname, cells_name, ...) \
+	static struct provider nm##_provider = { (propname), (cells_name), __VA_ARGS__ }; \
+	WARNING(nm##_property, check_provider_cells_property, &nm##_provider, &phandle_references);
+
+WARNING_PROPERTY_PHANDLE_CELLS(clocks, "clocks", "#clock-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(cooling_device, "cooling-device", "#cooling-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(dmas, "dmas", "#dma-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(hwlocks, "hwlocks", "#hwlock-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(interrupts_extended, "interrupts-extended", "#interrupt-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(io_channels, "io-channels", "#io-channel-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(iommus, "iommus", "#iommu-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(mboxes, "mboxes", "#mbox-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(msi_parent, "msi-parent", "#msi-cells", true);
+WARNING_PROPERTY_PHANDLE_CELLS(mux_controls, "mux-controls", "#mux-control-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(phys, "phys", "#phy-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(power_domains, "power-domains", "#power-domain-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(pwms, "pwms", "#pwm-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(resets, "resets", "#reset-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(sound_dais, "sound-dais", "#sound-dai-cells");
+WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sensor-cells");
+
+static bool prop_is_gpio(struct property *prop)
+{
+	char *str;
+
+	/*
+	 * *-gpios and *-gpio can appear in property names,
+	 * so skip over any false matches (only one known ATM)
+	 */
+	if (strstr(prop->name, "nr-gpio"))
+		return false;
+
+	str = strrchr(prop->name, '-');
+	if (str)
+		str++;
+	else
+		str = prop->name;
+	if (!(streq(str, "gpios") || streq(str, "gpio")))
+		return false;
+
+	return true;
+}
+
+static void check_gpios_property(struct check *c,
+					  struct dt_info *dti,
+				          struct node *node)
+{
+	struct property *prop;
+
+	/* Skip GPIO hog nodes which have 'gpios' property */
+	if (get_property(node, "gpio-hog"))
+		return;
+
+	for_each_property(node, prop) {
+		struct provider provider;
+
+		if (!prop_is_gpio(prop))
+			continue;
+
+		provider.prop_name = prop->name;
+		provider.cell_name = "#gpio-cells";
+		provider.optional = false;
+		check_property_phandle_args(c, dti, node, prop, &provider);
+	}
+
+}
+WARNING(gpios_property, check_gpios_property, NULL, &phandle_references);
+
+static void check_deprecated_gpio_property(struct check *c,
+					   struct dt_info *dti,
+				           struct node *node)
+{
+	struct property *prop;
+
+	for_each_property(node, prop) {
+		char *str;
+
+		if (!prop_is_gpio(prop))
+			continue;
+
+		str = strstr(prop->name, "gpio");
+		if (!streq(str, "gpio"))
+			continue;
+
+		FAIL(c, dti, "'[*-]gpio' is deprecated, use '[*-]gpios' instead for %s:%s",
+		     node->fullpath, prop->name);
+	}
+
+}
+CHECK(deprecated_gpio_property, check_deprecated_gpio_property, NULL);
+
+static bool node_is_interrupt_provider(struct node *node)
+{
+	struct property *prop;
+
+	prop = get_property(node, "interrupt-controller");
+	if (prop)
+		return true;
+
+	prop = get_property(node, "interrupt-map");
+	if (prop)
+		return true;
+
+	return false;
+}
+static void check_interrupts_property(struct check *c,
+				      struct dt_info *dti,
+				      struct node *node)
+{
+	struct node *root = dti->dt;
+	struct node *irq_node = NULL, *parent = node;
+	struct property *irq_prop, *prop = NULL;
+	int irq_cells, phandle;
+
+	irq_prop = get_property(node, "interrupts");
+	if (!irq_prop)
+		return;
+
+	if (irq_prop->val.len % sizeof(cell_t))
+		FAIL(c, dti, "property '%s' size (%d) is invalid, expected multiple of %zu in node %s",
+		     irq_prop->name, irq_prop->val.len, sizeof(cell_t),
+		     node->fullpath);
+
+	while (parent && !prop) {
+		if (parent != node && node_is_interrupt_provider(parent)) {
+			irq_node = parent;
+			break;
+		}
+
+		prop = get_property(parent, "interrupt-parent");
+		if (prop) {
+			phandle = propval_cell(prop);
+			irq_node = get_node_by_phandle(root, phandle);
+			if (!irq_node) {
+				FAIL(c, dti, "Bad interrupt-parent phandle for %s",
+				     node->fullpath);
+				return;
+			}
+			if (!node_is_interrupt_provider(irq_node))
+				FAIL(c, dti,
+				     "Missing interrupt-controller or interrupt-map property in %s",
+				     irq_node->fullpath);
+
+			break;
+		}
+
+		parent = parent->parent;
+	}
+
+	if (!irq_node) {
+		FAIL(c, dti, "Missing interrupt-parent for %s", node->fullpath);
+		return;
+	}
+
+	prop = get_property(irq_node, "#interrupt-cells");
+	if (!prop) {
+		FAIL(c, dti, "Missing #interrupt-cells in interrupt-parent %s",
+		     irq_node->fullpath);
+		return;
+	}
+
+	irq_cells = propval_cell(prop);
+	if (irq_prop->val.len % (irq_cells * sizeof(cell_t))) {
+		FAIL(c, dti,
+		     "interrupts size is (%d), expected multiple of %d in %s",
+		     irq_prop->val.len, (int)(irq_cells * sizeof(cell_t)),
+		     node->fullpath);
+	}
+}
+WARNING(interrupts_property, check_interrupts_property, &phandle_references);
+
 static struct check *check_table[] = {
 	&duplicate_node_names, &duplicate_property_names,
 	&node_name_chars, &node_name_format, &property_name_chars,
@@ -987,6 +1246,27 @@ static struct check *check_table[] = {
 	&avoid_default_addr_size,
 	&obsolete_chosen_interrupt_controller,
 
+	&clocks_property,
+	&cooling_device_property,
+	&dmas_property,
+	&hwlocks_property,
+	&interrupts_extended_property,
+	&io_channels_property,
+	&iommus_property,
+	&mboxes_property,
+	&msi_parent_property,
+	&mux_controls_property,
+	&phys_property,
+	&power_domains_property,
+	&pwms_property,
+	&resets_property,
+	&sound_dais_property,
+	&thermal_sensors_property,
+
+	&deprecated_gpio_property,
+	&gpios_property,
+	&interrupts_property,
+
 	&always_fail,
 };
 
scripts/dtc/dtc-lexer.lex.c_shipped +110 -106

624 lines not on this page · raw message

scripts/dtc/dtc-parser.tab.c_shipped +242 -222

875 lines not on this page · raw message

scripts/dtc/dtc-parser.tab.h_shipped +5 -3
index e7b04dd..6aa512c 100644
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -72,7 +72,7 @@ extern int yydebug;
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
 #line 39 "dtc-parser.y" /* yacc.c:1909  */
@@ -97,6 +97,8 @@ union YYSTYPE
 
 #line 99 "dtc-parser.tab.h" /* yacc.c:1909  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
scripts/dtc/dtc-parser.y +17 -3
index ca3f500..affc81a 100644
@@ -182,10 +182,19 @@ devicetree:
 		{
 			struct node *target = get_node_by_ref($1, $2);
 
-			if (target)
+			if (target) {
 				merge_nodes(target, $3);
-			else
-				ERROR(&@2, "Label or path %s not found", $2);
+			} else {
+				/*
+				 * We rely on the rule being always:
+				 *   versioninfo plugindecl memreserves devicetree
+				 * so $-1 is what we want (plugindecl)
+				 */
+				if ($<flags>-1 & DTSF_PLUGIN)
+					add_orphan_node($1, $3, $2);
+				else
+					ERROR(&@2, "Label or path %s not found", $2);
+			}
 			$$ = $1;
 		}
 	| devicetree DT_DEL_NODE DT_REF ';'
@@ -200,6 +209,11 @@ devicetree:
 
 			$$ = $1;
 		}
+	| /* empty */
+		{
+			/* build empty node */
+			$$ = name_node(build_node(NULL, NULL), "");
+		}
 	;
 
 nodedef:
scripts/dtc/dtc.h +2 -0
index 409db76..35cf926 100644
@@ -203,6 +203,7 @@ struct node *build_node_delete(void);
 struct node *name_node(struct node *node, char *name);
 struct node *chain_node(struct node *first, struct node *list);
 struct node *merge_nodes(struct node *old_node, struct node *new_node);
+void add_orphan_node(struct node *old_node, struct node *new_node, char *ref);
 
 void add_property(struct node *node, struct property *prop);
 void delete_property_by_name(struct node *node, char *name);
@@ -216,6 +217,7 @@ void append_to_property(struct node *node,
 const char *get_unitname(struct node *node);
 struct property *get_property(struct node *node, const char *propname);
 cell_t propval_cell(struct property *prop);
+cell_t propval_cell_n(struct property *prop, int n);
 struct property *get_property_by_label(struct node *tree, const char *label,
 				       struct node **node);
 struct marker *get_marker_label(struct node *tree, const char *label,
scripts/dtc/libfdt/fdt_addresses.c new file +96 -0

96 lines not on this page · raw message

scripts/dtc/libfdt/fdt_overlay.c new file +861 -0

861 lines not on this page · raw message

scripts/dtc/livetree.c +28 -0
index aecd278..6846ad2 100644
@@ -216,6 +216,28 @@ struct node *merge_nodes(struct node *old_node, struct node *new_node)
 	return old_node;
 }
 
+void add_orphan_node(struct node *dt, struct node *new_node, char *ref)
+{
+	static unsigned int next_orphan_fragment = 0;
+	struct node *node;
+	struct property *p;
+	struct data d = empty_data;
+	char *name;
+
+	d = data_add_marker(d, REF_PHANDLE, ref);
+	d = data_append_integer(d, 0xffffffff, 32);
+
+	p = build_property("target", d);
+
+	xasprintf(&name, "fragment@%u",
+			next_orphan_fragment++);
+	name_node(new_node, "__overlay__");
+	node = build_node(p, new_node);
+	name_node(node, name);
+
+	add_child(dt, node);
+}
+
 struct node *chain_node(struct node *first, struct node *list)
 {
 	assert(first->next_sibling == NULL);
@@ -396,6 +418,12 @@ cell_t propval_cell(struct property *prop)
 	return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
 }
 
+cell_t propval_cell_n(struct property *prop, int n)
+{
+	assert(prop->val.len / sizeof(cell_t) >= n);
+	return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));
+}
+
 struct property *get_property_by_label(struct node *tree, const char *label,
 				       struct node **node)
 {
scripts/dtc/version_gen.h +1 -1
index b5ed715..d88393c 100644
@@ -1 +1 @@
-#define DTC_VERSION "DTC 1.4.4-gfe50bd1e"
+#define DTC_VERSION "DTC 1.4.5-gb1a60033"
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 2/4 scripts/dtc: Update to upstream version v1.4.5-3-gb1a60033c110

Quoted 13 lines · Masahiro Yamada

This adds the following commits from upstream:

b1a6003 tests: Add a test for overlays syntactic sugar 737b2df overlay: Add syntactic sugar version of overlays 497432f checks: Use proper format modifier for size_t 22a65c5 dtc: Bump version to v1.4.5
c575d80 Add fdtoverlay to .gitignore
b6a6f94 fdtoverlay: Sanity check blob size 8c1eb15 pylibfdt: Use Python2 explicitly ee3d26f checks: add interrupts property check c1e7738 checks: add gpio binding properties check b3bbac0 checks: add phandle with arg property checks

Quoted 3 lines

[ sync with Linux commit: 4201d057ea91c3d6efd2db65219bc91fae413bc2 ]

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/c2008189/attachment.sig>
#5 lore raw

PATCH v2 3/4 pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile

In reply to Masahiro Yamada

The pylibfdt is used by dtoc (and, indirectly by binman), but there is no reason why it must be generated in the tools/ directory.

Recently, U-Boot switched over to the bundled DTC, and the directory structure under scripts/dtc/ now mirrors the upstream DTC project. So, scripts/dtc/pylibfdt is the best location.

I also rewrote the Makefile in a cleaner Kbuild style.

The scripts from the upstream have been moved as follows:

lib/libfdt/pylibfdt/setup.py -> scripts/dtc/pylibfdt/setup.py lib/libfdt/pylibfdt/libfdt.i -> scripts/dtc/pylibfdt/libfdt.i_shipped

The .i_shipped is coped to .i during building because the .i must be located in the objtree when we build it out of tree.

---

 Makefile                                           |  2 +-
 scripts/Makefile.spl                               |  4 +--
 scripts/dtc/Makefile                               |  3 +++
 scripts/dtc/pylibfdt/.gitignore                    |  4 +++
 scripts/dtc/pylibfdt/Makefile                      | 30 ++++++++++++++++++++++
 .../dtc/pylibfdt/libfdt.i_shipped                  |  0
 {lib/libfdt => scripts/dtc}/pylibfdt/setup.py      |  0
 tools/.gitignore                                   |  4 ---
 tools/Makefile                                     | 30 ----------------------
 tools/binman/binman.py                             |  2 +-
 10 files changed, 41 insertions(+), 38 deletions(-)
 create mode 100644 scripts/dtc/pylibfdt/.gitignore
 create mode 100644 scripts/dtc/pylibfdt/Makefile
 rename lib/libfdt/pylibfdt/libfdt.i => scripts/dtc/pylibfdt/libfdt.i_shipped (100%)
 rename {lib/libfdt => scripts/dtc}/pylibfdt/setup.py (100%)
Makefile +1 -1
index d074358..40cd61a 100644
@@ -1380,7 +1380,7 @@ $(timestamp_h): $(srctree)/Makefile FORCE
 	$(call filechk,timestamp.h)
 
 checkbinman: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \
+	@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
 		echo >&2; \
 		echo >&2 '*** binman needs the Python libfdt library.'; \
 		echo >&2 '*** Either install it on your system, or try:'; \
scripts/Makefile.spl +2 -2
index 49b27ac..065bb25 100644
@@ -257,7 +257,7 @@ quiet_cmd_fdtgrep = FDTGREP $@
 $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
 	$(call if_changed,fdtgrep)
 
-pythonpath = PYTHONPATH=tools
+pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
 
 quiet_cmd_dtocc = DTOC C  $@
 cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
@@ -381,7 +381,7 @@ ifneq ($(cmd_files),)
 endif
 
 checkdtoc: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \
+	@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
 		echo '*** dtoc needs the Python libfdt library. Either '; \
 		echo '*** install it on your system, or try:'; \
 		echo '***'; \
scripts/dtc/Makefile +3 -0
index 2a48022..f4a16ed 100644
@@ -29,3 +29,6 @@ $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
 
 # generated files need to be cleaned explicitly
 clean-files	:= dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
+
+# Added for U-Boot
+subdir-y += pylibfdt
scripts/dtc/pylibfdt/.gitignore new file +4 -0
new file mode 100644
index 0000000..033f23d
@@ -0,0 +1,4 @@
+/_libfdt.so
+/libfdt.py
+/libfdt.pyc
+/libfdt_wrap.c
scripts/dtc/pylibfdt/Makefile new file +30 -0
new file mode 100644
index 0000000..01d5e0f
@@ -0,0 +1,30 @@
+# Unfortunately setup.py below cannot handle srctree being ".." which it often
+# is. It fails with an error like:
+# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
+#    No such file or directory
+# To fix this, use an absolute path.
+LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
+
+include $(LIBFDT_srcdir)/Makefile.libfdt
+
+# Unfortunately setup.py (or actually the Python distutil implementation) puts
+# files into the same directory as the .i file. We cannot touch the source
+# directory, so we "ship" .i file into the objtree.
+PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
+		$(obj)/libfdt.i
+
+quiet_cmd_pymod = PYMOD   $@
+      cmd_pymod = unset CC; unset CROSS_COMPILE; unset CFLAGS;\
+		LDFLAGS="$(HOSTLDFLAGS)" \
+		VERSION="u-boot-$(UBOOTVERSION)" \
+		CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
+		SOURCES="$(PYLIBFDT_srcs)" \
+		SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
+		$(PYTHON) $< --quiet build_ext --inplace
+
+$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
+	$(call if_changed,pymod)
+
+always += _libfdt.so
+
+clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
scripts/dtc/pylibfdt/libfdt.i_shipped renamed from lib/libfdt/pylibfdt/libfdt.i +0 -0
similarity index 100%
rename from lib/libfdt/pylibfdt/libfdt.i
rename to scripts/dtc/pylibfdt/libfdt.i_shipped
scripts/dtc/pylibfdt/setup.py renamed from lib/libfdt/pylibfdt/setup.py +0 -0
similarity index 100%
rename from lib/libfdt/pylibfdt/setup.py
rename to scripts/dtc/pylibfdt/setup.py
tools/.gitignore +0 -4
index 5293d44..6a487d2 100644
@@ -1,4 +1,3 @@
-/_libfdt.so
 /atmel_pmecc_params
 /bin2header
 /bmp_logo
@@ -17,9 +16,6 @@
 /img2srec
 /kwboot
 /lib/
-/libfdt.py
-/libfdt.pyc
-/libfdt_wrap.c
 /mips-relocs
 /mkenvimage
 /mkexynosspl
tools/Makefile +0 -30
index 5db2a54..2b87e18 100644
@@ -63,15 +63,6 @@ LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c  \
 			fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \
 			fdt_region.c
 
-# Unfortunately setup.py below cannot handle srctree being ".." which it often
-# is. It fails with an error like:
-# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
-#    No such file or directory
-# To fix this, use an absolute path.
-libfdt_tree := $(shell readlink -f $(srctree)/lib/libfdt)
-
-LIBFDT_SRCS := $(addprefix $(libfdt_tree)/, $(LIBFDT_CSRCS))
-LIBFDT_SWIG := $(addprefix $(libfdt_tree)/, pylibfdt/libfdt.i)
 LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS)))
 
 RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
@@ -123,23 +114,6 @@ mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
 fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
 fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
 
-# Unfortunately setup.py (or actually the Python distutil implementation)
-# puts files into the same directory as the .i file. We cannot touch the source
-# directory, so we copy the .i file into the tools/ build subdirectory before
-# calling setup. This directory is safe to write to. This ensures that we get
-# all three files in $(obj)/tools: _libfdt.so, libfdt.py and libfdt_wrap.c
-# The latter is a temporary file which we could actually remove.
-tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG)
-	$(Q)cp $(LIBFDT_SWIG) tools/.
-	$(Q)unset CC; \
-	unset CROSS_COMPILE; \
-	LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= VERSION="u-boot-$(UBOOTVERSION)" \
-		CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \
-		SOURCES="$(LIBFDT_SRCS) tools/libfdt.i" \
-		SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \
-		$(PYTHON) $(libfdt_tree)/pylibfdt/setup.py --quiet build_ext \
-			--build-lib tools
-
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
 # the mxsimage support within tools/mxsimage.c .
@@ -231,10 +205,6 @@ clean-dirs := lib common
 
 always := $(hostprogs-y)
 
-# Build a libfdt Python module if swig is available
-# Use 'sudo apt-get install swig libpython-dev' to enable this
-always += $(if $(shell which swig 2> /dev/null),_libfdt.so)
-
 # Generated LCD/video logo
 LOGO_H = $(objtree)/include/bmp_logo.h
 LOGO_DATA_H = $(objtree)/include/bmp_logo_data.h
tools/binman/binman.py +1 -1
index 09dc36a..e75a59d 100755
@@ -21,7 +21,7 @@ for dirname in ['../patman', '../dtoc', '..']:
     sys.path.insert(0, os.path.join(our_path, dirname))
 
 # Bring in the libfdt module
-sys.path.insert(0, 'tools')
+sys.path.insert(0, 'scripts/dtc/pylibfdt')
 
 # Also allow entry-type modules to be brought in from the etype directory.
 sys.path.insert(0, os.path.join(our_path, 'etype'))
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 3/4 pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile

Masahiro,

Quoted 200 lines · Masahiro Yamada

The pylibfdt is used by dtoc (and, indirectly by binman), but there is no reason why it must be generated in the tools/ directory.

Recently, U-Boot switched over to the bundled DTC, and the directory structure under scripts/dtc/ now mirrors the upstream DTC project. So, scripts/dtc/pylibfdt is the best location.

I also rewrote the Makefile in a cleaner Kbuild style.

The scripts from the upstream have been moved as follows:

lib/libfdt/pylibfdt/setup.py -> scripts/dtc/pylibfdt/setup.py lib/libfdt/pylibfdt/libfdt.i -> scripts/dtc/pylibfdt/libfdt.i_shipped

The .i_shipped is coped to .i during building because the .i must be located in the objtree when we build it out of tree.

---

 Makefile                                           |  2 +-
 scripts/Makefile.spl                               |  4 +--
 scripts/dtc/Makefile                               |  3 +++
 scripts/dtc/pylibfdt/.gitignore                    |  4 +++
 scripts/dtc/pylibfdt/Makefile                      | 30 ++++++++++++++++++++++
 .../dtc/pylibfdt/libfdt.i_shipped                  |  0
 {lib/libfdt => scripts/dtc}/pylibfdt/setup.py      |  0
 tools/.gitignore                                   |  4 ---
 tools/Makefile                                     | 30 ----------------------
 tools/binman/binman.py                             |  2 +-
 10 files changed, 41 insertions(+), 38 deletions(-)
 create mode 100644 scripts/dtc/pylibfdt/.gitignore
 create mode 100644 scripts/dtc/pylibfdt/Makefile
 rename lib/libfdt/pylibfdt/libfdt.i => scripts/dtc/pylibfdt/libfdt.i_shipped (100%)
 rename {lib/libfdt => scripts/dtc}/pylibfdt/setup.py (100%)
Makefile +1 -1
index d074358..40cd61a 100644
@@ -1380,7 +1380,7 @@ $(timestamp_h): $(srctree)/Makefile FORCE
        $(call filechk,timestamp.h)
 
 checkbinman: tools
-       @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \
+       @if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
                echo >&2; \
                echo >&2 '*** binman needs the Python libfdt library.'; \
                echo >&2 '*** Either install it on your system, or try:'; \
scripts/Makefile.spl +2 -2
index 49b27ac..065bb25 100644
@@ -257,7 +257,7 @@ quiet_cmd_fdtgrep = FDTGREP $@
 $(obj)/$(SPL_BIN).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
        $(call if_changed,fdtgrep)
 
-pythonpath = PYTHONPATH=tools
+pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
 
 quiet_cmd_dtocc = DTOC C  $@
 cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
@@ -381,7 +381,7 @@ ifneq ($(cmd_files),)
 endif
 
 checkdtoc: tools
-       @if ! ( echo 'import libfdt' | ( PYTHONPATH=tools $(PYTHON) )); then \
+       @if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
                echo '*** dtoc needs the Python libfdt library. Either '; \
                echo '*** install it on your system, or try:'; \
                echo '***'; \
scripts/dtc/Makefile +3 -0
index 2a48022..f4a16ed 100644
@@ -29,3 +29,6 @@ $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
 
 # generated files need to be cleaned explicitly
 clean-files    := dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
+
+# Added for U-Boot
+subdir-y += pylibfdt
scripts/dtc/pylibfdt/.gitignore new file +4 -0
new file mode 100644
index 0000000..033f23d
@@ -0,0 +1,4 @@
+/_libfdt.so
+/libfdt.py
+/libfdt.pyc
+/libfdt_wrap.c
scripts/dtc/pylibfdt/Makefile new file +30 -0
new file mode 100644
index 0000000..01d5e0f
@@ -0,0 +1,30 @@
+# Unfortunately setup.py below cannot handle srctree being ".." which it often
+# is. It fails with an error like:
+# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
+#    No such file or directory
+# To fix this, use an absolute path.
+LIBFDT_srcdir = $(abspath $(srctree)/$(src)/../libfdt)
+
+include $(LIBFDT_srcdir)/Makefile.libfdt
+
+# Unfortunately setup.py (or actually the Python distutil implementation) puts
+# files into the same directory as the .i file. We cannot touch the source
+# directory, so we "ship" .i file into the objtree.
+PYLIBFDT_srcs = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_SRCS)) \
+               $(obj)/libfdt.i
+
+quiet_cmd_pymod = PYMOD   $@
+      cmd_pymod = unset CC; unset CROSS_COMPILE; unset CFLAGS;\
+               LDFLAGS="$(HOSTLDFLAGS)" \
+               VERSION="u-boot-$(UBOOTVERSION)" \
+               CPPFLAGS="$(HOSTCFLAGS) -I$(LIBFDT_srcdir)" OBJDIR=$(obj) \
+               SOURCES="$(PYLIBFDT_srcs)" \
+               SWIG_OPTS="-I$(LIBFDT_srcdir) -I$(LIBFDT_srcdir)/.." \
+               $(PYTHON) $< --quiet build_ext --inplace
+
+$(obj)/_libfdt.so: $(src)/setup.py $(PYLIBFDT_srcs) FORCE
+       $(call if_changed,pymod)
+
+always += _libfdt.so
+
+clean-files += libfdt.i _libfdt.so libfdt.py libfdt_wrap.c
scripts/dtc/pylibfdt/libfdt.i_shipped renamed from lib/libfdt/pylibfdt/libfdt.i +0 -0
similarity index 100%
rename from lib/libfdt/pylibfdt/libfdt.i
rename to scripts/dtc/pylibfdt/libfdt.i_shipped
scripts/dtc/pylibfdt/setup.py renamed from lib/libfdt/pylibfdt/setup.py +0 -0
similarity index 100%
rename from lib/libfdt/pylibfdt/setup.py
rename to scripts/dtc/pylibfdt/setup.py
tools/.gitignore +0 -4
index 5293d44..6a487d2 100644
@@ -1,4 +1,3 @@
-/_libfdt.so
 /atmel_pmecc_params
 /bin2header
 /bmp_logo
@@ -17,9 +16,6 @@
 /img2srec
 /kwboot
 /lib/
-/libfdt.py
-/libfdt.pyc
-/libfdt_wrap.c
 /mips-relocs
 /mkenvimage
 /mkexynosspl
tools/Makefile +0 -26
index 5db2a54..2b87e18 100644
@@ -63,15 +63,6 @@ LIBFDT_CSRCS := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c  \
                        fdt_empty_tree.c fdt_addresses.c fdt_overlay.c \
                        fdt_region.c
 
-# Unfortunately setup.py below cannot handle srctree being ".." which it often
-# is. It fails with an error like:
-# Fatal error: can't create build/temp.linux-x86_64-2.7/../lib/libfdt/fdt.o:
-#    No such file or directory
-# To fix this, use an absolute path.
-libfdt_tree := $(shell readlink -f $(srctree)/lib/libfdt)
-
-LIBFDT_SRCS := $(addprefix $(libfdt_tree)/, $(LIBFDT_CSRCS))
-LIBFDT_SWIG := $(addprefix $(libfdt_tree)/, pylibfdt/libfdt.i)
 LIBFDT_OBJS := $(addprefix lib/libfdt/, $(patsubst %.c, %.o, $(LIBFDT_CSRCS)))
 
 RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
@@ -123,23 +114,6 @@ mkimage-objs   := $(dumpimage-mkimage-objs) mkimage.o
 fit_info-objs   := $(dumpimage-mkimage-objs) fit_info.o
 fit_check_sign-objs   := $(dumpimage-mkimage-objs) fit_check_sign.o
 
-# Unfortunately setup.py (or actually the Python distutil implementation)
-# puts files into the same directory as the .i file. We cannot touch the source
-# directory, so we copy the .i file into the tools/ build subdirectory before
-# calling setup. This directory is safe to write to. This ensures that we get
-# all three files in $(obj)/tools: _libfdt.so, libfdt.py and libfdt_wrap.c
-# The latter is a temporary file which we could actually remove.
-tools/_libfdt.so: $(LIBFDT_SRCS) $(LIBFDT_SWIG)
-       $(Q)cp $(LIBFDT_SWIG) tools/.
-       $(Q)unset CC; \
-       unset CROSS_COMPILE; \
-       LDFLAGS="$(HOSTLDFLAGS)" CFLAGS= VERSION="u-boot-$(UBOOTVERSION)" \
-               CPPFLAGS="$(_hostc_flags)" OBJDIR=tools \
-               SOURCES="$(LIBFDT_SRCS) tools/libfdt.i" \
-               SWIG_OPTS="-I$(srctree)/lib/libfdt -I$(srctree)/lib" \
-               $(PYTHON) $(libfdt_tree)/pylibfdt/setup.py --quiet build_ext \
-                       --build-lib tools
-
 ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
 # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
 # the mxsimage support within tools/mxsimage.c .

tools/Makefile clean-dirs := lib common · line 236

Quoted 6 lines
tools/Makefile +0 -3
@@ -231,10 +205,6 @@ clean-dirs := lib common
 
 always := $(hostprogs-y)
 
-# Build a libfdt Python module if swig is available
-# Use 'sudo apt-get install swig libpython-dev' to enable this
-always += $(if $(shell which swig 2> /dev/null),_libfdt.so)

I'm working on updating Buildroot to remove the host dependency on python as part of the tools build (Plus fix the mix of host system vs host buildroot python/swig checks). Appreciate the recent changes as it makes that easier, with the addition of the kconfig option to turn on the libfdt build. I assume that removes the python/swig dependency
when that's disabled? Is the default in a un-configured uboot (ie
if I was just building tools) to leave libfdt off?

I'm irc if it's easier to discuss.

Matt

#7 lore raw

PATCH v2 3/4 pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile

2017-10-18 3:03 GMT+09:00 Matthew Weber <[email protected]>:

Quoted 8 lines

Masahiro,

I'm working on updating Buildroot to remove the host dependency on python as part of the tools build (Plus fix the mix of host system vs host buildroot python/swig checks). Appreciate the recent changes as it makes that easier, with the addition of the kconfig option to turn on the libfdt build. I assume that removes the python/swig dependency when that's disabled?

Right. No more dependency on python/swig
when CONFIG_PYLIBFDT is disabled.

Quoted 2 lines

Is the default in a un-configured uboot (ie
if I was just building tools) to leave libfdt off?

If un-configured, CONFIG_PYLIBFDT is undefined.
Kbuild will not build pylibfdt.

Quoted 7 lines

I'm irc if it's easier to discuss.

Matt
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

PATCH v2 3/4 pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile

In reply to Masahiro Yamada
Quoted 11 lines · Masahiro Yamada

The pylibfdt is used by dtoc (and, indirectly by binman), but there is no reason why it must be generated in the tools/ directory.

Recently, U-Boot switched over to the bundled DTC, and the directory structure under scripts/dtc/ now mirrors the upstream DTC project. So, scripts/dtc/pylibfdt is the best location.

I also rewrote the Makefile in a cleaner Kbuild style.

The scripts from the upstream have been moved as follows:

Quoted 7 lines

lib/libfdt/pylibfdt/setup.py -> scripts/dtc/pylibfdt/setup.py lib/libfdt/pylibfdt/libfdt.i -> scripts/dtc/pylibfdt/libfdt.i_shipped

The .i_shipped is coped to .i during building because the .i must be located in the objtree when we build it out of tree.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/9a44f934/attachment.sig>
#9 lore raw

PATCH v2 4/4 pylibfdt: compile pylibfdt only when dtoc/binman is necessary

In reply to Masahiro Yamada

Currently, pylibfdt is always compiled if swig is installed on your machine. It is really annoying because most of targets (excepts x86, sunxi, rockchip) do not use dtoc or binman.

"checkbinman" and "checkdtoc" are wrong. It is odd that the final build stage checks if we have built necessary tools. If your platform depends on dtoc/binman, you must be able to build pylibfdt. If swig is not installed, it should fail immediately.

I added PYLIBFDT, DTOC, BINMAN entries to Kconfig. They should be property select:ed by platforms that need them. Kbuild will descend into scripts/dtc/pylibfdt/ only when CONFIG_PYLIBFDT is enabled.

---

 Makefile             | 17 ++---------------
 arch/arm/Kconfig     |  1 +
 arch/x86/Kconfig     |  1 +
 dts/Kconfig          | 13 +++++++++++++
 scripts/Makefile.spl | 15 ++-------------
 scripts/dtc/Makefile |  2 +-
 6 files changed, 20 insertions(+), 29 deletions(-)
Makefile +2 -15
index 40cd61a..8f3fcfe 100644
@@ -1135,7 +1135,7 @@ cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \
 
 u-boot.rom: u-boot-x86-16bit.bin u-boot.bin \
 		$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
-		$(if $(CONFIG_HAVE_REFCODE),refcode.bin) checkbinman FORCE
+		$(if $(CONFIG_HAVE_REFCODE),refcode.bin) FORCE
 	$(call if_changed,binman)
 
 OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec
@@ -1144,8 +1144,7 @@ u-boot-x86-16bit.bin: u-boot FORCE
 endif
 
 ifneq ($(CONFIG_ARCH_SUNXI),)
-u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb \
-		checkbinman FORCE
+u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE
 	$(call if_changed,binman)
 endif
 
@@ -1379,18 +1378,6 @@ $(version_h): include/config/uboot.release FORCE
 $(timestamp_h): $(srctree)/Makefile FORCE
 	$(call filechk,timestamp.h)
 
-checkbinman: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
-		echo >&2; \
-		echo >&2 '*** binman needs the Python libfdt library.'; \
-		echo >&2 '*** Either install it on your system, or try:'; \
-		echo >&2 '***'; \
-		echo >&2 '*** sudo apt-get install swig libpython-dev'; \
-		echo >&2 '***'; \
-		echo >&2 '*** to have U-Boot build its own version.'; \
-		false; \
-	fi
-
 # ---------------------------------------------------------------------------
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \
arch/arm/Kconfig +1 -0
index 64e0ee4..d69141a 100644
@@ -682,6 +682,7 @@ config ARCH_SOCFPGA
 
 config ARCH_SUNXI
 	bool "Support sunxi (Allwinner) SoCs"
+	select BINMAN
 	select CMD_GPIO
 	select CMD_MMC if MMC
 	select CMD_USB if DISTRO_DEFAULTS
arch/x86/Kconfig +1 -0
index 38a6187..9d12a98 100644
@@ -152,6 +152,7 @@ config SMM_TSEG_SIZE
 config X86_RESET_VECTOR
 	bool
 	default n
+	select BINMAN
 
 # The following options control where the 16-bit and 32-bit init lies
 # If SPL is enabled then it normally holds this init code, and U-Boot proper
dts/Kconfig +13 -0
index daa757d..0cef225 100644
@@ -8,6 +8,17 @@ config SUPPORT_OF_CONTROL
 config DTC
 	bool
 
+config PYLIBFDT
+	bool
+
+config DTOC
+	bool
+	select PYLIBFDT
+
+config BINMAN
+	bool
+	select DTOC
+
 menu "Device Tree Control"
 	depends on SUPPORT_OF_CONTROL
 
@@ -231,6 +242,7 @@ config OF_SPL_REMOVE_PROPS
 config SPL_OF_PLATDATA
 	bool "Generate platform data for use in SPL"
 	depends on SPL_OF_CONTROL
+	select DTOC
 	help
 	  For very constrained SPL environments the overhead of decoding
 	  device tree nodes and converting their contents into platform data
@@ -252,6 +264,7 @@ config SPL_OF_PLATDATA
 config TPL_OF_PLATDATA
 	bool "Generate platform data for use in TPL"
 	depends on TPL_OF_CONTROL
+	select DTOC
 	help
 	  For very constrained SPL environments the overhead of decoding
 	  device tree nodes and converting their contents into platform data
scripts/Makefile.spl +2 -13
index 065bb25..ca04476 100644
@@ -276,10 +276,10 @@ PHONY += dts_dir
 dts_dir:
 	$(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
 
-include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir checkdtoc
+include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
 	$(call if_changed,dtoch)
 
-$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir checkdtoc
+$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
 	$(call if_changed,dtocc)
 
 ifdef CONFIG_SAMSUNG
@@ -380,17 +380,6 @@ ifneq ($(cmd_files),)
   include $(cmd_files)
 endif
 
-checkdtoc: tools
-	@if ! ( echo 'import libfdt' | ( PYTHONPATH=scripts/dtc/pylibfdt $(PYTHON) )); then \
-		echo '*** dtoc needs the Python libfdt library. Either '; \
-		echo '*** install it on your system, or try:'; \
-		echo '***'; \
-		echo '*** sudo apt-get install swig libpython-dev'; \
-		echo '***'; \
-		echo '*** to have U-Boot build its own version.'; \
-		false; \
-	fi
-
 PHONY += FORCE
 FORCE:
 
scripts/dtc/Makefile +1 -1
index f4a16ed..90ef2db 100644
@@ -31,4 +31,4 @@ $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
 clean-files	:= dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h
 
 # Added for U-Boot
-subdir-y += pylibfdt
+subdir-$(CONFIG_PYLIBFDT) += pylibfdt
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 4/4 pylibfdt: compile pylibfdt only when dtoc/binman is necessary

Hi Masahiro,

Quoted 16 lines · Masahiro Yamada

Currently, pylibfdt is always compiled if swig is installed on your machine. It is really annoying because most of targets (excepts x86, sunxi, rockchip) do not use dtoc or binman.

"checkbinman" and "checkdtoc" are wrong. It is odd that the final build stage checks if we have built necessary tools. If your platform depends on dtoc/binman, you must be able to build pylibfdt. If swig is not installed, it should fail immediately.

I added PYLIBFDT, DTOC, BINMAN entries to Kconfig. They should be property select:ed by platforms that need them. Kbuild will descend into scripts/dtc/pylibfdt/ only when CONFIG_PYLIBFDT is enabled.

---

Quoted 8 lines
 Makefile             | 17 ++---------------
 arch/arm/Kconfig     |  1 +
 arch/x86/Kconfig     |  1 +
 dts/Kconfig          | 13 +++++++++++++
 scripts/Makefile.spl | 15 ++-------------
 scripts/dtc/Makefile |  2 +-
 6 files changed, 20 insertions(+), 29 deletions(-)

I think this is a reasonable change.

Regards,
Simon

#11 lore raw

PATCH v2 4/4 pylibfdt: compile pylibfdt only when dtoc/binman is necessary

In reply to Masahiro Yamada
Quoted 9 lines · Masahiro Yamada

Currently, pylibfdt is always compiled if swig is installed on your machine. It is really annoying because most of targets (excepts x86, sunxi, rockchip) do not use dtoc or binman.

"checkbinman" and "checkdtoc" are wrong. It is odd that the final build stage checks if we have built necessary tools. If your platform depends on dtoc/binman, you must be able to build pylibfdt. If swig is not installed, it should fail immediately.

Quoted 6 lines

I added PYLIBFDT, DTOC, BINMAN entries to Kconfig. They should be property select:ed by platforms that need them. Kbuild will descend into scripts/dtc/pylibfdt/ only when CONFIG_PYLIBFDT is enabled.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171117/45a78a70/attachment.sig>