Skip to contentSkip to conversation

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

PATCH Superseded Masahiro Yamada 2 participants 6 messages Oct 17, 2017

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

Masahiro Yamada (3):
dtc: libfdt: import fdt_addresses.c and fdt_overlay.c
pylibfdt: move pylibfdt to scripts/dtc/pylibfdt and refactor makefile
pylibfdt: compile pylibfdt only when dtoc/binman is necessary

 Makefile                                           |  17 +-
 arch/arm/Kconfig                                   |   1 +
 arch/x86/Kconfig                                   |   1 +
 dts/Kconfig                                        |  13 +
 scripts/Makefile.spl                               |  17 +-
 scripts/dtc/Makefile                               |   3 +
 scripts/dtc/libfdt/fdt_addresses.c                 |  96 +++
 scripts/dtc/libfdt/fdt_overlay.c                   | 861 +++++++++++++++++++++
 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 +-
 15 files changed, 1015 insertions(+), 64 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 1/3 dtc: libfdt: import fdt_addresses.c and fdt_overlay.c

I will move the pylibfdt build script under the scripts/dtc/ in the next commit. We need two more files to build the pylibfdt.

We have almost same copies in lib/libfdt, but we are collecting all DTC-derived files into scripts/dtc.

Import fdt_addresses.c and fdt_overlay.c from DTC v1.4.5.

---

 scripts/dtc/libfdt/fdt_addresses.c |  96 +++++
 scripts/dtc/libfdt/fdt_overlay.c   | 861 +++++++++++++++++++++++++++++++++++++
 2 files changed, 957 insertions(+)
 create mode 100644 scripts/dtc/libfdt/fdt_addresses.c
 create mode 100644 scripts/dtc/libfdt/fdt_overlay.c
scripts/dtc/libfdt/fdt_addresses.c new file +96 -0
new file mode 100644
index 0000000..eff4dbc
@@ -0,0 +1,96 @@
+/*
+ * libfdt - Flat Device Tree manipulation
+ * Copyright (C) 2014 David Gibson <[email protected]>
+ *
+ * libfdt is dual licensed: you can use it either under the terms of
+ * the GPL, or the BSD license, at your option.
+ *
+ *  a) This library is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License as
+ *     published by the Free Software Foundation; either version 2 of the
+ *     License, or (at your option) any later version.
+ *
+ *     This library is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public
+ *     License along with this library; if not, write to the Free
+ *     Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+ *     MA 02110-1301 USA
+ *
+ * Alternatively,
+ *
+ *  b) Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
+ *
+ *     1. Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
+ *     2. Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
+ *
+ *     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ *     CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ *     INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ *     MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ *     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ *     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ *     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ *     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ *     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ *     OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "libfdt_env.h"
+
+#include <fdt.h>
+#include <libfdt.h>
+
+#include "libfdt_internal.h"
+
+int fdt_address_cells(const void *fdt, int nodeoffset)
+{
+	const fdt32_t *ac;
+	int val;
+	int len;
+
+	ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len);
+	if (!ac)
+		return 2;
+
+	if (len != sizeof(*ac))
+		return -FDT_ERR_BADNCELLS;
+
+	val = fdt32_to_cpu(*ac);
+	if ((val <= 0) || (val > FDT_MAX_NCELLS))
+		return -FDT_ERR_BADNCELLS;
+
+	return val;
+}
+
+int fdt_size_cells(const void *fdt, int nodeoffset)
+{
+	const fdt32_t *sc;
+	int val;
+	int len;
+
+	sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len);
+	if (!sc)
+		return 2;
+
+	if (len != sizeof(*sc))
+		return -FDT_ERR_BADNCELLS;
+
+	val = fdt32_to_cpu(*sc);
+	if ((val < 0) || (val > FDT_MAX_NCELLS))
+		return -FDT_ERR_BADNCELLS;
+
+	return val;
+}
scripts/dtc/libfdt/fdt_overlay.c new file +861 -0

861 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/3 dtc: libfdt: import fdt_addresses.c and fdt_overlay.c

Quoted 9 lines · Masahiro Yamada

I will move the pylibfdt build script under the scripts/dtc/ in the next commit. We need two more files to build the pylibfdt.

We have almost same copies in lib/libfdt, but we are collecting all DTC-derived files into scripts/dtc.

Import fdt_addresses.c and fdt_overlay.c from DTC v1.4.5.

Has Rob's patch to re-sync the kernel with v1.4.5-and-change been applied? Moving forward I'd like to try and keep us in-sync with the version the kernel is using (we're ahead of the kernel until that change goes in, and then I think behind). 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/20171016/73c1167b/attachment.sig>
#3 lore raw

PATCH 1/3 dtc: libfdt: import fdt_addresses.c and fdt_overlay.c

2017-10-17 10:37 GMT+09:00 Tom Rini <[email protected]>:

Quoted 7 lines · Masahiro Yamada
Quoted 6 lines

I will move the pylibfdt build script under the scripts/dtc/ in the next commit. We need two more files to build the pylibfdt.

We have almost same copies in lib/libfdt, but we are collecting all DTC-derived files into scripts/dtc.

Quoted 9 lines
Quoted 3 lines

Import fdt_addresses.c and fdt_overlay.c from DTC v1.4.5.

Has Rob's patch to re-sync the kernel with v1.4.5-and-change been applied? Moving forward I'd like to try and keep us in-sync with the version the kernel is using (we're ahead of the kernel until that change goes in, and then I think behind). Thanks!

fdt_addresses.c and fdt_overlay.c in linux-next
are already synced with DTC 1.4.5

I will do re-sync just in case, but those two files will not change.

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

PATCH 2/3 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 888486b..0044503 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 c164774..38090a9 100644
@@ -64,15 +64,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/, \
@@ -124,23 +115,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 .
@@ -232,10 +206,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
#5 lore raw

PATCH 3/3 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 0044503..627a639 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