Skip to contentSkip to conversation

kbuild: Add support to build overlays (%.dtbo)

RFC In review Viresh Kumar 6 participants 20 messages Jan 5, 2021 – Jan 12, 2021

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

cover kbuild: Add support to build overlays (%.dtbo)

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Also fdtoverlay is an external entity right now, and is not part of the kernel. Do we need to make it part of the kernel ? Or keep using the external entity ?

Thanks.

--
Viresh

Viresh Kumar (2):
kbuild: Add support to build overlays (%.dtbo)
scripts: dtc: Handle outform dtbo

 Makefile             |  4 ++--
 scripts/Makefile.lib | 12 ++++++++++++
 scripts/dtc/dtc.c    |  2 ++
 3 files changed, 16 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#1 lore raw

RFC 1/2 kbuild: Add support to build overlays (%.dtbo)

Add support for building DT overlays (%.dtbo). The overlay's source file will have the usual extension, i.e. .dts, though the blob will have .dtbo extension to distinguish it from normal blobs.

---
 Makefile             |  4 ++--
 scripts/Makefile.lib | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
Makefile +2 -2
index 3d328b7ab200..54cdcdfea67b 100644
@@ -1334,7 +1334,7 @@ endif
 
 ifneq ($(dtstree),)
 
-%.dtb: include/config/kernel.release scripts_dtc
+%.dtb %.dtbo: include/config/kernel.release scripts_dtc
 	$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
 
 PHONY += dtbs dtbs_install dtbs_check
@@ -1816,7 +1816,7 @@ clean: $(clean-dirs)
 	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
 		\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
 		-o -name '*.ko.*' \
-		-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
+		-o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
 		-o -name '*.dwo' -o -name '*.lst' \
 		-o -name '*.su' -o -name '*.mod' \
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
scripts/Makefile.lib +12 -0
index 213677a5ed33..f70d7bd3262a 100644
@@ -82,11 +82,15 @@ always-y += $(userprogs-always-y) $(userprogs-always-m)
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
 extra-y				+= $(dtb-y)
+extra-y				+= $(dtbo-y)
 extra-$(CONFIG_OF_ALL_DTBS)	+= $(dtb-)
+extra-$(CONFIG_OF_ALL_DTBS)	+= $(dtbo-)
 
 ifneq ($(CHECK_DTBS),)
 extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
+extra-y += $(patsubst %.dtbo,%.dt.yaml, $(dtbo-y))
 extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
+extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtbo,%.dt.yaml, $(dtbo-))
 endif
 
 # Add subdir path
@@ -299,6 +303,11 @@ endif
 
 DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
 
+# enable creation of __symbols__ node
+ifneq ($(dtbo-y),)
+DTC_FLAGS += -@
+endif
+
 # Generate an assembly file to wrap the output of the device tree compiler
 quiet_cmd_dt_S_dtb= DTB     $@
 cmd_dt_S_dtb=						\
@@ -327,6 +336,9 @@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ;
 $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
+$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
+	$(call if_changed_dep,dtc)
+
 DT_CHECKER ?= dt-validate
 DT_BINDING_DIR := Documentation/devicetree/bindings
 # DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#2 lore raw

RFC 2/2 scripts: dtc: Handle outform dtbo

In reply to Viresh Kumar

Update dtc compiler to accept dtbo as an outform.

---
I feel that this needs to go directly to
https://git.kernel.org/pub/scm/utils/dtc/dtc.git

Right ? I will send it separately if the idea is accepted here.

---
 scripts/dtc/dtc.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/dtc/dtc.c +2 -0
index bdb3f5945699..40fa7128b3d6 100644
@@ -357,6 +357,8 @@ int main(int argc, char *argv[])
 #endif
 	} else if (streq(outform, "dtb")) {
 		dt_to_blob(outf, dti, outversion);
+	} else if (streq(outform, "dtbo")) {
+		dt_to_blob(outf, dti, outversion);
 	} else if (streq(outform, "asm")) {
 		dt_to_asm(outf, dti, outversion);
 	} else if (streq(outform, "null")) {
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#3 lore raw

Re: [RFC 2/2] scripts: dtc: Handle outform dtbo

Quoted 10 lines · Viresh Kumar

Update dtc compiler to accept dtbo as an outform.

---
I feel that this needs to go directly to
https://git.kernel.org/pub/scm/utils/dtc/dtc.git

Right ? I will send it separately if the idea is accepted here.

Yes, needs to go to devicetree-compiler list. I think this came up before and IIRC David wasn't completely in agreement. I looked briefly and couldn't find the thread though...

We really don't need a different extension because we could just examine the dtb to determine if it is an overlay or not. That's less obvious. We could also add meta-data to overlays defining what base they apply to. If we had that, a tool could just list all overlays that should apply to a base and we could use that info for build time applying overlays. Of course, that and a dtbo extension/format are not mutually exclusive.

Quoted 9 lines
---
 scripts/dtc/dtc.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/dtc/dtc.c +0 -0
index bdb3f5945699..40fa7128b3d6 100644

scripts/dtc/dtc.c int main(int argc, char *argv[]) · line 364

Quoted 8 lines
scripts/dtc/dtc.c +2 -0
@@ -357,6 +357,8 @@ int main(int argc, char *argv[])
 #endif
        } else if (streq(outform, "dtb")) {
                dt_to_blob(outf, dti, outversion);
+       } else if (streq(outform, "dtbo")) {
+               dt_to_blob(outf, dti, outversion);
        } else if (streq(outform, "asm")) {
                dt_to_asm(outf, dti, outversion);
        } else if (streq(outform, "null")) {

You also need to extend guess_type_by_name().

Rob

#4 lore raw

Re: [RFC 2/2] scripts: dtc: Handle outform dtbo

Quoted 12 lines · Rob Herring
Quoted 10 lines · Viresh Kumar

Update dtc compiler to accept dtbo as an outform.

---
I feel that this needs to go directly to
https://git.kernel.org/pub/scm/utils/dtc/dtc.git

Right ? I will send it separately if the idea is accepted here.

Quoted 8 lines

Yes, needs to go to devicetree-compiler list. I think this came up before and IIRC David wasn't completely in agreement. I looked briefly and couldn't find the thread though...

We really don't need a different extension because we could just examine the dtb to determine if it is an overlay or not. That's less obvious. We could also add meta-data to overlays defining what base they apply to. If we had that, a tool could just list all overlays

It may be valid to apply an overlay may be valid to more than one base FDT.

And for connector nodes and plugin overlays (which do not exist yet, I'm way behind on bringing that concept forward), a single overlay may be applied to more than one connector node in the base FDT.

Quoted 27 lines

that should apply to a base and we could use that info for build time applying overlays. Of course, that and a dtbo extension/format are not mutually exclusive.

Quoted 9 lines
---
 scripts/dtc/dtc.c | 2 ++
 1 file changed, 2 insertions(+)
scripts/dtc/dtc.c +0 -0
index bdb3f5945699..40fa7128b3d6 100644

scripts/dtc/dtc.c int main(int argc, char *argv[]) · line 364

Quoted 8 lines
scripts/dtc/dtc.c +2 -0
@@ -357,6 +357,8 @@ int main(int argc, char *argv[])
 #endif
        } else if (streq(outform, "dtb")) {
                dt_to_blob(outf, dti, outversion);
+       } else if (streq(outform, "dtbo")) {
+               dt_to_blob(outf, dti, outversion);
        } else if (streq(outform, "asm")) {
                dt_to_asm(outf, dti, outversion);
        } else if (streq(outform, "null")) {

You also need to extend guess_type_by_name().

Rob

#5 lore raw
In reply to Viresh Kumar
Quoted 10 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

Quoted 5 lines

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

(One difference here is we will want all the intermediate targets unlike .o files.)

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

Quoted 3 lines

Also fdtoverlay is an external entity right now, and is not part of the kernel. Do we need to make it part of the kernel ? Or keep using the external entity ?

Part of the kernel. We just need to add it to the dtc sync script and makefile I think.

Rob

#6 lore raw

PATCH 1/1 scripts: dtc: Start building fdtoverlay and fdtdump

We will start building overlays for platforms soon in the kernel and would need these tools going forward. Lets fetch and build these.

Note that a copy of fdtdump.c was already copied back in the year 2012, but it was never updated or built for some reason.

---
 scripts/dtc/Makefile             | 8 +++++++-
 scripts/dtc/update-dtc-source.sh | 6 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)
scripts/dtc/Makefile +7 -1
index 4852bf44e913..c607980a5c17 100644
@@ -1,12 +1,18 @@
 # SPDX-License-Identifier: GPL-2.0
 # scripts/dtc makefile
 
-hostprogs-always-$(CONFIG_DTC)		+= dtc
+hostprogs-always-$(CONFIG_DTC)		+= dtc fdtdump fdtoverlay
 hostprogs-always-$(CHECK_DT_BINDING)	+= dtc
 
 dtc-objs	:= dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
 		   srcpos.o checks.o util.o
 dtc-objs	+= dtc-lexer.lex.o dtc-parser.tab.o
+fdtdump-objs	:= fdtdump.o util.o
+
+libfdt_dir	= libfdt
+libfdt-objs	:= fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o
+libfdt		= $(addprefix $(libfdt_dir)/,$(libfdt-objs))
+fdtoverlay-objs	:= $(libfdt) fdtoverlay.o util.o
 
 # Source files need to get at the userspace version of libfdt_env.h to compile
 HOST_EXTRACFLAGS += -I $(srctree)/$(src)/libfdt
scripts/dtc/update-dtc-source.sh +3 -3
index bc704e2a6a4a..9bc4afb71415 100755
@@ -31,9 +31,9 @@ set -ev
 DTC_UPSTREAM_PATH=`pwd`/../dtc
 DTC_LINUX_PATH=`pwd`/scripts/dtc
 
-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 yamltree.c \
-		dtc-lexer.l dtc-parser.y"
+DTC_SOURCE="checks.c data.c dtc.c dtc.h fdtdump.c fdtoverlay.c flattree.c \
+		fstree.c livetree.c srcpos.c srcpos.h treesource.c util.c \
+		util.h version_gen.h yamltree.c dtc-lexer.l dtc-parser.y"
 LIBFDT_SOURCE="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"
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
#7 lore raw

Re: [PATCH] scripts: dtc: Start building fdtoverlay and fdtdump

I love your patch! Yet something to improve:

Hi Viresh,

I love your patch! Yet something to improve:

[auto build test ERROR on robh/for-next]
[also build test ERROR on v5.11-rc2 next-20210104]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Viresh-Kumar/scripts-dtc-Start-building-fdtoverlay-and-fdtdump/20210106-181140
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: x86_64-randconfig-a013-20210106 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 5c951623bc8965fa1e89660f2f5f4a2944e4981a)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/5ee2a6ba3d6de17f6e9b9dc259081630b6deffb8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Viresh-Kumar/scripts-dtc-Start-building-fdtoverlay-and-fdtdump/20210106-181140 git checkout 5ee2a6ba3d6de17f6e9b9dc259081630b6deffb8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> make[2]: *** No rule to make target 'scripts/dtc/fdtoverlay.c', needed by 'scripts/dtc/fdtoverlay.o'.
   In file included from scripts/dtc/fdtdump.c:12:
>> scripts/dtc/libfdt/fdt.h:13:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t magic;                   /* magic word FDT_MAGIC */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:14:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t totalsize;               /* total size of DT block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:15:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_dt_struct;           /* offset to structure */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:16:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_dt_strings;          /* offset to strings */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:17:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_mem_rsvmap;          /* offset to memory reserve map */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:18:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t version;                 /* format version */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:19:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t last_comp_version;       /* last compatible version */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:22:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t boot_cpuid_phys;         /* Which physical CPU id we're
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:25:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t size_dt_strings;         /* size of the strings block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:28:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t size_dt_struct;          /* size of the structure block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
>> scripts/dtc/libfdt/fdt.h:32:2: error: unknown type name 'fdt64_t'; did you mean 'int64_t'?
           fdt64_t address;
           ^~~~~~~
           int64_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   typedef __int64_t int64_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:33:2: error: unknown type name 'fdt64_t'; did you mean 'int64_t'?
           fdt64_t size;
           ^~~~~~~
           int64_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   typedef __int64_t int64_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:37:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t tag;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:42:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t tag;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:43:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t len;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:44:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t nameoff;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
>> scripts/dtc/fdtdump.c:156:28: error: too few arguments to function call, expected 2, have 1
           buf = utilfdt_read(argv[1]);
                 ~~~~~~~~~~~~        ^
   scripts/dtc/util.h:97:7: note: 'utilfdt_read' declared here
   char *utilfdt_read(const char *filename, size_t *len);
         ^

17 errors generated.
make[2]: *** [scripts/Makefile.host:112: scripts/dtc/fdtdump.o] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1356: scripts_dtc] Error 2
make[1]: Target 'modules_prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'modules_prepare' not remade because of errors.
--

>> make[2]: *** No rule to make target 'scripts/dtc/fdtoverlay.c', needed by 'scripts/dtc/fdtoverlay.o'.
   In file included from scripts/dtc/fdtdump.c:12:
>> scripts/dtc/libfdt/fdt.h:13:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t magic;                   /* magic word FDT_MAGIC */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:14:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t totalsize;               /* total size of DT block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:15:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_dt_struct;           /* offset to structure */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:16:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_dt_strings;          /* offset to strings */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:17:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t off_mem_rsvmap;          /* offset to memory reserve map */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:18:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t version;                 /* format version */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:19:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t last_comp_version;       /* last compatible version */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:22:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t boot_cpuid_phys;         /* Which physical CPU id we're
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:25:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t size_dt_strings;         /* size of the strings block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:28:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t size_dt_struct;          /* size of the structure block */
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
>> scripts/dtc/libfdt/fdt.h:32:2: error: unknown type name 'fdt64_t'; did you mean 'int64_t'?
           fdt64_t address;
           ^~~~~~~
           int64_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   typedef __int64_t int64_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:33:2: error: unknown type name 'fdt64_t'; did you mean 'int64_t'?
           fdt64_t size;
           ^~~~~~~
           int64_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here
   typedef __int64_t int64_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:37:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t tag;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:42:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t tag;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:43:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t len;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
   In file included from scripts/dtc/fdtdump.c:12:
   scripts/dtc/libfdt/fdt.h:44:2: error: unknown type name 'fdt32_t'; did you mean 'int32_t'?
           fdt32_t nameoff;
           ^~~~~~~
           int32_t
   /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:26:19: note: 'int32_t' declared here
   typedef __int32_t int32_t;
                     ^
>> scripts/dtc/fdtdump.c:156:28: error: too few arguments to function call, expected 2, have 1
           buf = utilfdt_read(argv[1]);
                 ~~~~~~~~~~~~        ^
   scripts/dtc/util.h:97:7: note: 'utilfdt_read' declared here
   char *utilfdt_read(const char *filename, size_t *len);
         ^

17 errors generated.
make[2]: *** [scripts/Makefile.host:112: scripts/dtc/fdtdump.o] Error 1 make[2]: Target '__build' not remade because of errors. make[1]: *** [Makefile:1356: scripts_dtc] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.

vim +13 scripts/dtc/libfdt/fdt.h

1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10 11

1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  12  struct fdt_header {
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29 @13  	fdt32_t magic;			 /* magic word FDT_MAGIC */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  14  	fdt32_t totalsize;		 /* total size of DT block */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  15  	fdt32_t off_dt_struct;		 /* offset to structure */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  16  	fdt32_t off_dt_strings;		 /* offset to strings */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  17  	fdt32_t off_mem_rsvmap;		 /* offset to memory reserve map */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  18  	fdt32_t version;		 /* format version */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  19  	fdt32_t last_comp_version;	 /* last compatible version */
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  20  
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  21  	/* version 2 fields below */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  22  	fdt32_t boot_cpuid_phys;	 /* Which physical CPU id we're
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  23  					    booting on */
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  24  	/* version 3 fields below */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  25  	fdt32_t size_dt_strings;	 /* size of the strings block */
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  26  
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  27  	/* version 17 fields below */
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  28  	fdt32_t size_dt_struct;		 /* size of the structure block */
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  29  };
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  30  
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  31  struct fdt_reserve_entry {
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29 @32  	fdt64_t address;
4760597116e34bd scripts/dtc/libfdt/fdt.h       Rob Herring  2015-04-29  33  	fdt64_t size;
1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10  34  };

1cade99497c881a arch/powerpc/boot/libfdt/fdt.h David Gibson 2007-12-10 35

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#8 lore raw

Re: [PATCH] scripts: dtc: Start building fdtoverlay and fdtdump

In reply to Viresh Kumar
Quoted 11 lines · Viresh Kumar

We will start building overlays for platforms soon in the kernel and would need these tools going forward. Lets fetch and build these.

Note that a copy of fdtdump.c was already copied back in the year 2012, but it was never updated or built for some reason.

---
 scripts/dtc/Makefile             | 8 +++++++-
 scripts/dtc/update-dtc-source.sh | 6 +++---

This needs to be 2 patches so we can do a dtc sync in between. So update update-dtc-source.sh, run update-dtc-source.sh, update the Makefile.

Quoted 46 lines
 2 files changed, 10 insertions(+), 4 deletions(-)
scripts/dtc/Makefile +7 -1
index 4852bf44e913..c607980a5c17 100644
@@ -1,12 +1,18 @@
 # SPDX-License-Identifier: GPL-2.0
 # scripts/dtc makefile
 
-hostprogs-always-$(CONFIG_DTC)         += dtc
+hostprogs-always-$(CONFIG_DTC)         += dtc fdtdump fdtoverlay
 hostprogs-always-$(CHECK_DT_BINDING)   += dtc
 
 dtc-objs       := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
                   srcpos.o checks.o util.o
 dtc-objs       += dtc-lexer.lex.o dtc-parser.tab.o
+fdtdump-objs   := fdtdump.o util.o
+
+libfdt_dir     = libfdt
+libfdt-objs    := fdt.o fdt_ro.o fdt_wip.o fdt_sw.o fdt_rw.o fdt_strerror.o fdt_empty_tree.o fdt_addresses.o fdt_overlay.o
+libfdt         = $(addprefix $(libfdt_dir)/,$(libfdt-objs))
+fdtoverlay-objs        := $(libfdt) fdtoverlay.o util.o
 
 # Source files need to get at the userspace version of libfdt_env.h to compile
 HOST_EXTRACFLAGS += -I $(srctree)/$(src)/libfdt
scripts/dtc/update-dtc-source.sh +3 -4
index bc704e2a6a4a..9bc4afb71415 100755
@@ -31,9 +31,9 @@ set -ev
 DTC_UPSTREAM_PATH=`pwd`/../dtc
 DTC_LINUX_PATH=`pwd`/scripts/dtc
 
-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 yamltree.c \
-               dtc-lexer.l dtc-parser.y"
+DTC_SOURCE="checks.c data.c dtc.c dtc.h fdtdump.c fdtoverlay.c flattree.c \
+               fstree.c livetree.c srcpos.c srcpos.h treesource.c util.c \
+               util.h version_gen.h yamltree.c dtc-lexer.l dtc-parser.y"
 LIBFDT_SOURCE="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"
--

2.25.0.rc1.19.g042ed3e048af

#9 lore raw
In reply to Rob Herring
Quoted 12 lines · Rob Herring
Quoted 10 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

Quoted 5 lines
Quoted 5 lines

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

We use chained extension in some places, for example, .dt.yaml for schema yaml files.

dtb-$(CONFIG_ARCH_FOO) += \
    foo-board.dtb \
    foo-overlay1.ovl.dtb \
    foo-overlay2.ovl.dtb

Overlay DT source file names must end with '.ovl.dts'

Quoted 8 lines

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

Quoted 6 lines

(One difference here is we will want all the intermediate targets unlike .o files.)

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

I guess the motivation for supporting -dtbs is to add per-board -@ option only when it contains *.dtbo pattern.

But, as you notice, if the overlay files are located under drivers/, it is difficult to add -@ per board.

Another scenario is, some people may want to compile downstream overlay files (i.e. similar concept as external modules), then we have no idea which base board should be given with the -@ flag.

I'd rather be tempted to add it globally

ifdef CONFIG_OF_OVERLAY
DTC_FLAGS += -@
endif

Quoted 8 lines

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

If this is a big churn, perhaps we could make it extreme to decouple DT and Linux-arch.

arch/*/boot/dts/*.dts
-> dts/<vendor>/*.dts

Documentation/devicetree/bindings
-> dts/Bindings/

include/dt-bindings/
-> dts/include/dt-bindings/

Then, other project can take dts/
to reuse for them.

Quoted 8 lines
Quoted 3 lines

Also fdtoverlay is an external entity right now, and is not part of the kernel. Do we need to make it part of the kernel ? Or keep using the external entity ?

Part of the kernel. We just need to add it to the dtc sync script and makefile I think.

Rob

--
Best Regards
Masahiro Yamada

#10 lore raw
Quoted 15 lines · Masahiro Yamada
Quoted 14 lines · Rob Herring
Quoted 12 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

A simple way is to mention that with -base extension, like this:

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

Thanks.

Quoted 2 lines

In my understanding, the build rule is completely the same between .dtb and .dtbo

Right.

Quoted 13 lines

As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

We use chained extension in some places, for example, .dt.yaml for schema yaml files.

Quoted 7 lines
dtb-$(CONFIG_ARCH_FOO) += \
    foo-board.dtb \
    foo-overlay1.ovl.dtb \
    foo-overlay2.ovl.dtb

Overlay DT source file names must end with '.ovl.dts'

I am fine with any approach that you guys feel is better, .dts or .ovl.dts. I wanted to start a discussion where we can resolve this and be done with it.

Thanks.

Signature · 1 line
viresh
#11 lore raw
In reply to Masahiro Yamada
Quoted 43 lines · Masahiro Yamada
Quoted 12 lines · Rob Herring
Quoted 10 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

Quoted 5 lines
Quoted 5 lines

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

We use chained extension in some places, for example, .dt.yaml for schema yaml files.

Quoted 7 lines
dtb-$(CONFIG_ARCH_FOO) += \
    foo-board.dtb \
    foo-overlay1.ovl.dtb \
    foo-overlay2.ovl.dtb

Overlay DT source file names must end with '.ovl.dts'

I like that suggestion as then it's also clear looking at the source files which ones are overlays. Or we'd need .dtso to be consistent.

Quoted 10 lines
Quoted 10 lines

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

(One difference here is we will want all the intermediate targets unlike .o files.)

Quoted 7 lines
Quoted 3 lines

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

I guess the motivation for supporting -dtbs is to add per-board -@ option only when it contains *.dtbo pattern.

I hadn't thought that far, but yeah, that would be good. Really, I just want it to be controlled per SoC family at least.

Quoted 2 lines

But, as you notice, if the overlay files are located under drivers/, it is difficult to add -@ per board.

Generally, they shouldn't be. The exceptions are what we already have there which are old dt fixups and unittests.

We want the stripped DT repo (devicetree-rebasing) to have all this and drivers/ is stripped out. (Which reminds me, the DT repo will need some work to support all this. It's a different build sys.)

Quoted 11 lines

Another scenario is, some people may want to compile downstream overlay files (i.e. similar concept as external modules), then we have no idea which base board should be given with the -@ flag.

I'd rather be tempted to add it globally

ifdef CONFIG_OF_OVERLAY
DTC_FLAGS += -@
endif

We've already rejected doing that. Turning on '-@' can grow the dtb size by a significant amount which could be problematic for some boards.

Quoted 11 lines
Quoted 7 lines

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

If this is a big churn, perhaps we could make it extreme to decouple DT and Linux-arch.

I would be fine with that, but I don't think we'll get agreement there. With that amount of change, we'll be discussing git submodule again.

Rereading the thread on vendor directories[1], we may just move boards one vendor at a time. We could just make that a prerequisite for vendor supporting overlays.

Quoted 6 lines

arch/*/boot/dts/*.dts
-> dts/<vendor>/*.dts

Documentation/devicetree/bindings
-> dts/Bindings/

Quoted 7 lines

include/dt-bindings/
-> dts/include/dt-bindings/

Then, other project can take dts/
to reuse for them.

This is already possible with devicetree-rebasing.git. Though it is still by arch.

Rob

[1] https://lore.kernel.org/linux-devicetree/20181204183649.GA5716@bogus/

#12 lore raw

Hello,

Quoted 35 lines · Rob Herring
Quoted 34 lines · Masahiro Yamada
Quoted 12 lines · Rob Herring
Quoted 10 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

Quoted 5 lines
Quoted 5 lines

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

Quoted 3 lines
Quoted 3 lines

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

*.dtbo is already a well established defato standard. I see little value in changing it and doing so will likely just bifurcate common usage.

Quoted 12 lines
Quoted 12 lines

We use chained extension in some places, for example, .dt.yaml for schema yaml files.

dtb-$(CONFIG_ARCH_FOO) += \
     foo-board.dtb \
     foo-overlay1.ovl.dtb \
     foo-overlay2.ovl.dtb
Quoted 5 lines
Quoted 1 line

Overlay DT source file names must end with '.ovl.dts'

I like that suggestion as then it's also clear looking at the source files which ones are overlays. Or we'd need .dtso to be consistent.

I don't think there is much of a problem renaming the source side. Don't know if that helps if the output is still dtbo.

"Be consistent on dtso" sounds good to me.
Can it be enforced via build time checks?

Quoted 81 lines
Quoted 11 lines
Quoted 11 lines

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

(One difference here is we will want all the intermediate targets unlike .o files.)

Quoted 7 lines
Quoted 3 lines

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

I guess the motivation for supporting -dtbs is to add per-board -@ option only when it contains *.dtbo pattern.

I hadn't thought that far, but yeah, that would be good. Really, I just want it to be controlled per SoC family at least.

Quoted 2 lines

But, as you notice, if the overlay files are located under drivers/, it is difficult to add -@ per board.

Generally, they shouldn't be. The exceptions are what we already have there which are old dt fixups and unittests.

We want the stripped DT repo (devicetree-rebasing) to have all this and drivers/ is stripped out. (Which reminds me, the DT repo will need some work to support all this. It's a different build sys.)

Quoted 11 lines

Another scenario is, some people may want to compile downstream overlay files (i.e. similar concept as external modules), then we have no idea which base board should be given with the -@ flag.

I'd rather be tempted to add it globally

ifdef CONFIG_OF_OVERLAY
DTC_FLAGS += -@
endif

We've already rejected doing that. Turning on '-@' can grow the dtb size by a significant amount which could be problematic for some boards >

Quoted 11 lines
Quoted 7 lines

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

If this is a big churn, perhaps we could make it extreme to decouple DT and Linux-arch.

I would be fine with that, but I don't think we'll get agreement there. With that amount of change, we'll be discussing git submodule again.

Rereading the thread on vendor directories[1], we may just move boards one vendor at a time. We could just make that a prerequisite for vendor supporting overlays.

Quoted 6 lines

arch/*/boot/dts/*.dts
-> dts/<vendor>/*.dts

Documentation/devicetree/bindings
-> dts/Bindings/

Quoted 7 lines

include/dt-bindings/
-> dts/include/dt-bindings/

Then, other project can take dts/
to reuse for them.

Quoted 7 lines

This is already possible with devicetree-rebasing.git. Though it is still by arch.

Rob

[1] https://lore.kernel.org/linux-devicetree/20181204183649.GA5716@bogus/

Thanks for digging up this script!

Bill

#13 lore raw
In reply to Rob Herring
Quoted 136 lines · Rob Herring
Quoted 43 lines · Masahiro Yamada
Quoted 12 lines · Rob Herring
Quoted 10 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

Quoted 5 lines
Quoted 5 lines

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Any other preference ?

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

We use chained extension in some places, for example, .dt.yaml for schema yaml files.

Quoted 7 lines
dtb-$(CONFIG_ARCH_FOO) += \
    foo-board.dtb \
    foo-overlay1.ovl.dtb \
    foo-overlay2.ovl.dtb

Overlay DT source file names must end with '.ovl.dts'

I like that suggestion as then it's also clear looking at the source files which ones are overlays. Or we'd need .dtso to be consistent.

Quoted 10 lines
Quoted 10 lines

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

(One difference here is we will want all the intermediate targets unlike .o files.)

Quoted 7 lines
Quoted 3 lines

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

I guess the motivation for supporting -dtbs is to add per-board -@ option only when it contains *.dtbo pattern.

I hadn't thought that far, but yeah, that would be good. Really, I just want it to be controlled per SoC family at least.

Quoted 2 lines

But, as you notice, if the overlay files are located under drivers/, it is difficult to add -@ per board.

Generally, they shouldn't be. The exceptions are what we already have there which are old dt fixups and unittests.

We want the stripped DT repo (devicetree-rebasing) to have all this and drivers/ is stripped out. (Which reminds me, the DT repo will need some work to support all this. It's a different build sys.)

Quoted 11 lines

Another scenario is, some people may want to compile downstream overlay files (i.e. similar concept as external modules), then we have no idea which base board should be given with the -@ flag.

I'd rather be tempted to add it globally

ifdef CONFIG_OF_OVERLAY
DTC_FLAGS += -@
endif

We've already rejected doing that. Turning on '-@' can grow the dtb size by a significant amount which could be problematic for some boards.

Quoted 11 lines
Quoted 7 lines

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

If this is a big churn, perhaps we could make it extreme to decouple DT and Linux-arch.

I would be fine with that, but I don't think we'll get agreement there. With that amount of change, we'll be discussing git submodule again.

Rereading the thread on vendor directories[1], we may just move boards one vendor at a time. We could just make that a prerequisite for vendor supporting overlays.

Quoted 11 lines

arch/*/boot/dts/*.dts
-> dts/<vendor>/*.dts

Documentation/devicetree/bindings
-> dts/Bindings/

include/dt-bindings/
-> dts/include/dt-bindings/

Quoted 5 lines
Quoted 2 lines

Then, other project can take dts/
to reuse for them.

This is already possible with devicetree-rebasing.git. Though it is still by arch.

Yes, I know this project.

There are still cross-references between arm and arm64.

Associating DT with Linux-arch is not good
because it is possible to boot the 32-bit kernel (arch/arm/) on the 64-bit boards (arch/arm64/boot/dts/).

Quoted 3 lines

Rob

[1] https://lore.kernel.org/linux-devicetree/20181204183649.GA5716@bogus/

Signature · 2 lines
Best Regards
Masahiro Yamada
#14 lore raw
In reply to Masahiro Yamada
Quoted 5 lines · Masahiro Yamada

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

Quoted 8 lines

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

By the time you gave feedback, I have already sent the dtbo change for DTC to the device-tree-compiler list (based on Rob's suggestion).

And it got merged today by David:

https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc

Can we please finalize what we need to do with naming here and be done with it, so I can rework my patches and get going ?

Thanks.

Signature · 1 line
viresh
#15 lore raw
Quoted 23 lines · Viresh Kumar
Quoted 5 lines · Masahiro Yamada

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

Quoted 8 lines

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

By the time you gave feedback, I have already sent the dtbo change for DTC to the device-tree-compiler list (based on Rob's suggestion).

And it got merged today by David:

https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc

Quoted 7 lines

Can we please finalize what we need to do with naming here and be done with it, so I can rework my patches and get going ?

Thanks.

--
viresh

It is unfortunate to see such a patch merged before getting agreement about how it should work as a whole.

Review

Quoted 4 lines
(quoted diff) +4 -0
+# enable creation of __symbols__ node
+ifneq ($(dtbo-y),)
+DTC_FLAGS += -@
+endif

I am not convinced with this code.

A single user of the dtbo-y syntax gives -@ to all device trees in the same directory.

This is not a solution since Rob already stated -@ should be given per board (or per platform, at least).

I still do not understand why adding the new syntax dtbo-y is helpful.

Have we already decided to use separate ".dtb" and ".dtbo" for blobs?

Will we use ".dts" for all source files?
Or, will we use ".dtso" for overlay source files?

How should the build system determine the targets that should have -@ option?

For consistency, will we need a patch like follows?

dtc.c +0 -0
index bdb3f59..474401e 100644
@@ -120,6 +120,8 @@ static const char *guess_type_by_name(const char

*fname, const char *fallback)

                return fallback;
        if (!strcasecmp(s, ".dts"))
                return "dts";
+       if (!strcasecmp(s, ".dtso"))
+               return "dts";
        if (!strcasecmp(s, ".yaml"))
                return "yaml";
        if (!strcasecmp(s, ".dtb"))

@@ -349,6 +351,8 @@ int main(int argc, char *argv[])

        if (streq(outform, "dts")) {
                dt_to_source(outf, dti);
+       else if (streq(outform, "dtso")) {
+               dt_to_source(outf, dti);
 #ifndef NO_YAML
        } else if (streq(outform, "yaml")) {
                if (!streq(inform, "dts"))

Overall solution looks unclear to me.

Again, it is unfortunate that we did not take enough time (in spite of the RFC prefix) before proceeding.

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

+David Gibson

Quoted 30 lines · Masahiro Yamada
Quoted 28 lines · Viresh Kumar
Quoted 5 lines · Masahiro Yamada

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

Quoted 8 lines

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

By the time you gave feedback, I have already sent the dtbo change for DTC to the device-tree-compiler list (based on Rob's suggestion).

And it got merged today by David:

https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc

Can we please finalize what we need to do with naming here and be done with it, so I can rework my patches and get going ?

Thanks.

Quoted 8 lines
Quoted 2 lines

--
viresh

It is unfortunate to see such a patch merged before getting agreement about how it should work as a whole.

Given the feedback that dtbo is already a standard, I'd suggest we just stick with dts->dtbo.

Quoted 7 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+# enable creation of __symbols__ node
+ifneq ($(dtbo-y),)
+DTC_FLAGS += -@
+endif

I am not convinced with this code.

Quoted 5 lines

A single user of the dtbo-y syntax gives -@ to all device trees in the same directory.

This is not a solution since Rob already stated -@ should be given per board (or per platform, at least).

Agreed.

Quoted 2 lines

I still do not understand why adding the new syntax dtbo-y is helpful.

I think we should stick with 'dtb-y' here.

Quoted 7 lines

Have we already decided to use separate ".dtb" and ".dtbo" for blobs?

Will we use ".dts" for all source files?
Or, will we use ".dtso" for overlay source files?

How should the build system determine the targets that should have -@ option?

The way it does already. Either:

DTC_FLAGS += -@

in a directory of dts files. Or on a per file basis like:

DTC_FLAGS_foo_base += -@

Quoted 29 lines

For consistency, will we need a patch like follows?

dtc.c +2 -0
index bdb3f59..474401e 100644
@@ -120,6 +120,8 @@ static const char *guess_type_by_name(const char
 *fname, const char *fallback)
                return fallback;
        if (!strcasecmp(s, ".dts"))
                return "dts";
+       if (!strcasecmp(s, ".dtso"))
+               return "dts";
        if (!strcasecmp(s, ".yaml"))
                return "yaml";
        if (!strcasecmp(s, ".dtb"))
dtc.c +2 -0
@@ -349,6 +351,8 @@ int main(int argc, char *argv[])
 
        if (streq(outform, "dts")) {
                dt_to_source(outf, dti);
+       else if (streq(outform, "dtso")) {
+               dt_to_source(outf, dti);
 #ifndef NO_YAML
        } else if (streq(outform, "yaml")) {
                if (!streq(inform, "dts"))
Quoted 5 lines

Overall solution looks unclear to me.

Again, it is unfortunate that we did not take enough time (in spite of the RFC prefix) before proceeding.

I should have added David here from the start. Honestly, I expected some discussion there.

Rob

#17 lore raw
Quoted 39 lines · Rob Herring

+David Gibson

Quoted 35 lines · Masahiro Yamada
Quoted 30 lines · Viresh Kumar
Quoted 5 lines · Masahiro Yamada

Viresh's patch is not enough.

We will need to change .gitignore
and scripts/Makefile.dtbinst as well.

Quoted 8 lines

In my understanding, the build rule is completely the same between .dtb and .dtbo
As Rob mentioned, I am not sure if we really need/want a separate extension.

A counter approach is to use an extension like '.ovl.dtb' It clarifies it is an overlay fragment without changing anything in our build system or the upstream DTC project.

By the time you gave feedback, I have already sent the dtbo change for DTC to the device-tree-compiler list (based on Rob's suggestion).

And it got merged today by David:

https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc

Can we please finalize what we need to do with naming here and be done with it, so I can rework my patches and get going ?

Thanks.

--
viresh

Quoted 6 lines
Quoted 3 lines

It is unfortunate to see such a patch merged before getting agreement about how it should work as a whole.

Given the feedback that dtbo is already a standard, I'd suggest we just stick with dts->dtbo.

OK.
dtbo seems a stanrdard already...

Quoted 29 lines
Quoted 7 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+# enable creation of __symbols__ node
+ifneq ($(dtbo-y),)
+DTC_FLAGS += -@
+endif

I am not convinced with this code.

Quoted 5 lines

A single user of the dtbo-y syntax gives -@ to all device trees in the same directory.

This is not a solution since Rob already stated -@ should be given per board (or per platform, at least).

Agreed.

Quoted 2 lines

I still do not understand why adding the new syntax dtbo-y is helpful.

I think we should stick with 'dtb-y' here.

Quoted 7 lines

Have we already decided to use separate ".dtb" and ".dtbo" for blobs?

Will we use ".dts" for all source files?
Or, will we use ".dtso" for overlay source files?

How should the build system determine the targets that should have -@ option?

Quoted 7 lines

The way it does already. Either:

DTC_FLAGS += -@

in a directory of dts files. Or on a per file basis like:

DTC_FLAGS_foo_base += -@

Ah yes. I like this.

We do not need the dtbo-y syntax.

We can simply use dtb-y for
base boards and overlay fragments:

dtb-$(CONFIG_ARCH_FOO) += \
     foo-base.dtb \
     foo-overlay1.dtbo \
     foo-overlay2.dtbo

DTB_FLAGS_foo-base += -@

Quoted 40 lines
Quoted 30 lines

For consistency, will we need a patch like follows?

dtc.c +2 -0
index bdb3f59..474401e 100644
@@ -120,6 +120,8 @@ static const char *guess_type_by_name(const char
 *fname, const char *fallback)
                return fallback;
        if (!strcasecmp(s, ".dts"))
                return "dts";
+       if (!strcasecmp(s, ".dtso"))
+               return "dts";
        if (!strcasecmp(s, ".yaml"))
                return "yaml";
        if (!strcasecmp(s, ".dtb"))
dtc.c +2 -0
@@ -349,6 +351,8 @@ int main(int argc, char *argv[])
 
        if (streq(outform, "dts")) {
                dt_to_source(outf, dti);
+       else if (streq(outform, "dtso")) {
+               dt_to_source(outf, dti);
 #ifndef NO_YAML
        } else if (streq(outform, "yaml")) {
                if (!streq(inform, "dts"))
Quoted 5 lines

Overall solution looks unclear to me.

Again, it is unfortunate that we did not take enough time (in spite of the RFC prefix) before proceeding.

I should have added David here from the start. Honestly, I expected some discussion there.

Rob

Signature · 2 lines
Best Regards
Masahiro Yamada
#18 lore raw
Quoted 3 lines · Masahiro Yamada
Quoted 1 line · Rob Herring

On Mon, Jan 11, 2021 at 9:40 AM Masahiro Yamada <[email protected]> wrote:

We do not need the dtbo-y syntax.

+1

And we are left with much simpler diff with what we agreed on. Does this look okay now ?

---
 .gitignore               | 3 +--
 Makefile                 | 4 ++--
 scripts/Makefile.dtbinst | 3 +++
 scripts/Makefile.lib     | 4 +++-
 4 files changed, 9 insertions(+), 5 deletions(-)
.gitignore +1 -2
index d01cda8e1177..0458c36f3cb2 100644
@@ -17,8 +17,7 @@
 *.bz2
 *.c.[012]*.*
 *.dt.yaml
-*.dtb
-*.dtb.S
+*.dtb*
 *.dwo
 *.elf
 *.gcno
Makefile +2 -2
index 9e73f82e0d86..b84f5e0b46ab 100644
@@ -1334,7 +1334,7 @@ endif
 
 ifneq ($(dtstree),)
 
-%.dtb: include/config/kernel.release scripts_dtc
+%.dtb %.dtbo: include/config/kernel.release scripts_dtc
 	$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
 
 PHONY += dtbs dtbs_install dtbs_check
@@ -1816,7 +1816,7 @@ clean: $(clean-dirs)
 	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
 		\( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \
 		-o -name '*.ko.*' \
-		-o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
+		-o -name '*.dtb' -o -name '*.dtbo' -o -name '*.dtb.S' -o -name '*.dt.yaml' \
 		-o -name '*.dwo' -o -name '*.lst' \
 		-o -name '*.su' -o -name '*.mod' \
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
scripts/Makefile.dtbinst +3 -0
index 50d580d77ae9..ba01f5ba2517 100644
@@ -29,6 +29,9 @@ quiet_cmd_dtb_install = INSTALL $@
 $(dst)/%.dtb: $(obj)/%.dtb
 	$(call cmd,dtb_install)
 
+$(dst)/%.dtbo: $(obj)/%.dtbo
+	$(call cmd,dtb_install)
+
 PHONY += $(subdirs)
 $(subdirs):
 	$(Q)$(MAKE) $(dtbinst)=$@ dst=$(patsubst $(obj)/%,$(dst)/%,$@)
scripts/Makefile.lib +3 -1
index 213677a5ed33..30bc0a8e0087 100644
@@ -86,7 +86,9 @@ extra-$(CONFIG_OF_ALL_DTBS)	+= $(dtb-)
 
 ifneq ($(CHECK_DTBS),)
 extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
+extra-y += $(patsubst %.dtbo,%.dt.yaml, $(dtb-y))
 extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
+extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtbo,%.dt.yaml, $(dtb-))
 endif
 
 # Add subdir path
@@ -324,7 +326,7 @@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ;
 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
 
-$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
+$(obj)/%.dtb $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
 DT_CHECKER ?= dt-validate
#19 lore raw
In reply to Rob Herring
Quoted 15 lines · Rob Herring
Quoted 14 lines · Viresh Kumar

Hello,

Here is an attempt to make some changes in the kernel to allow building of device tree overlays.

While at it, I would also like to discuss about how we should mention the base DT blobs in the Makefiles for the overlays, so they can be build tested to make sure the overlays apply properly.

A simple way is to mention that with -base extension, like this:

$(overlay-file)-base := platform-base.dtb

Quoted 8 lines
Quoted 1 line

Any other preference ?

I think we'll want something similar to how '-objs' works for modules:

foo-board-1-dtbs := foo-board.dtb foo-overlay1.dtbo foo-board-2-dtbs := foo-board.dtb foo-overlay2.dtbo foo-board-1-2-dtbs := foo-board.dtb foo-overlay1.dtbo foo-overlay2.dtbo dtbs-y += foo-board-1.dtb foo-board-2.dtb foo-board-1-2.dtb

(Thinking ahead....) I'm not sure how to fit connector nodes and the corresponding plugin overlays into this model. A single plugin .dtbo will need to be relocated onto one or more connector nodes. fdtoverlay and the run time overlay apply code do not know how to do this yet.

-Frank

Quoted 25 lines

(One difference here is we will want all the intermediate targets unlike .o files.)

You wouldn't necessarily have all the above combinations, but you have to allow for them. I'm not sure how we'd handle applying any common overlays where the base and overlay are in different directories.

Another thing here is adding all the above is not really going to scale on arm32 where we have a single dts directory. We need to move things to per vendor/soc family directories. I have the script to do this. We just need to agree on the vendor names and get Arnd/Olof to run it. I also want that so we can enable schema checks by default once a vendor is warning free (the whole tree is going to take forever).

Quoted 3 lines

Also fdtoverlay is an external entity right now, and is not part of the kernel. Do we need to make it part of the kernel ? Or keep using the external entity ?

Part of the kernel. We just need to add it to the dtc sync script and makefile I think.

Rob