dt: build overlays
Subsystems (2)
v6 cover dt: build overlays
Hi Frank/Rob,
This patchset makes necessary changes to the kernel to add support for building overlays (%.dtbo) and the required fdtoverlay tool. This also builds static_test.dtb using most of the existing overlay tests present in drivers/of/unittest-data/ for better test coverage.
Note that in order for anyone to test this stuff, you need to manually run the ./update-dtc-source.sh script once to fetch the necessary changes from the external DTC project (i.e. fdtoverlay.c and this[1] patch).
Also note that Frank has already shared his concerns towards the error reporting done by fdtoverlay tool [2], and David said it is not that straight forward to make such changes in fdtoverlay. I have still included the patch in this series for completeness.
FWIW, with fdtoverlay we generate a new build warning now, not sure why though:
drivers/of/unittest-data/tests-interrupts.dtsi:20.5-28: Warning (interrupts_property): /testcase-data/testcase-device2:#interrupt-cells: size is (4), expected multiple of 8
V6:
- Create separate rules for dtbo-s and separate entries in .gitignore in 4/6 (Masahiro).
- A new file layout for handling all overlays for existing and new tests 5/6 (Frank).
- Include overlay.dts as well now in 6/6 (Frank).
V5:
- Don't reuse DTC_SOURCE for fdtoverlay.c in patch 1/5 (Frank).
- Update .gitignore and scripts/Makefile.dtbinst, drop dtbo-y syntax and DTC_FLAGS += -@ in patch 4/5 (Masahiro).
- Remove the intermediate dtb, rename output to static_test.dtb, don't use overlay.dtb and overlay_base.dtb for static builds, improved layout/comments in Makefile for patch 5/5 (Frank).
--
Viresh
[1] https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc
[2] https://lore.kernel.org/lkml/[email protected]/
Viresh Kumar (6):
scripts: dtc: Fetch fdtoverlay.c from external DTC project
scripts: dtc: Build fdtoverlay tool
scripts: dtc: Remove the unused fdtdump.c file
kbuild: Add support to build overlays (%.dtbo)
of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
of: unittest: Statically apply overlays using fdtoverlay
.gitignore | 1 + Makefile | 5 +- drivers/of/unittest-data/Makefile | 51 ++++++ drivers/of/unittest-data/overlay_base.dts | 90 +--------- drivers/of/unittest-data/overlay_common.dtsi | 91 ++++++++++ drivers/of/unittest-data/static_base.dts | 5 + drivers/of/unittest-data/testcases.dts | 17 +- .../of/unittest-data/testcases_common.dtsi | 18 ++ scripts/Makefile.dtbinst | 3 + scripts/Makefile.lib | 5 + scripts/dtc/Makefile | 6 +- scripts/dtc/fdtdump.c | 163 ------------------ scripts/dtc/update-dtc-source.sh | 3 +- 13 files changed, 187 insertions(+), 271 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/static_base.dts create mode 100644 drivers/of/unittest-data/testcases_common.dtsi delete mode 100644 scripts/dtc/fdtdump.c
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH v6 1/6 scripts: dtc: Fetch fdtoverlay.c from external DTC project
We will start building overlays for platforms soon in the kernel and would need fdtoverlay tool going forward. Lets start fetching it.
--- scripts/dtc/update-dtc-source.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/dtc/update-dtc-source.sh +2 -1
@@ -37,6 +37,7 @@ DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c 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" +FDTOVERLAY_SOURCE=fdtoverlay.c get_last_dtc_version() { git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/'
@@ -54,7 +55,7 @@ dtc_log=$(git log --oneline ${last_dtc_ver}..) # Copy the files into the Linux tree cd $DTC_LINUX_PATH -for f in $DTC_SOURCE; do +for f in $DTC_SOURCE $FDTOVERLAY_SOURCE; do cp ${DTC_UPSTREAM_PATH}/${f} ${f} git add ${f} done
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH v6 2/6 scripts: dtc: Build fdtoverlay tool
In reply to Viresh KumarWe will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it.
The fdtoverlay program applies (or merges) one or more overlay dtb blobs to a base dtb blob. The kernel build system would later use fdtoverlay to generate the overlaid blobs based on platform specific configurations.
--- scripts/dtc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/dtc/Makefile +5 -1
@@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0 # scripts/dtc makefile -hostprogs-always-$(CONFIG_DTC) += dtc +hostprogs-always-$(CONFIG_DTC) += dtc 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 +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/,$(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
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
Re: [PATCH V6 2/6] scripts: dtc: Build fdtoverlay tool
Quoted 4 lines · Viresh Kumar
We will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it.
The fdtoverlay program applies (or merges) one or more overlay dtb
Saying "merges" here is probably misleading, since as I mentioned elsewhere fdtoverlay can *not* merge overlays, only apply them to a base tree.
Quoted 32 lines
blobs to a base dtb blob. The kernel build system would later use fdtoverlay to generate the overlaid blobs based on platform specific configurations.
Signed-off-by Viresh Kumar <[email protected]>--- scripts/dtc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/dtc/Makefile +5
-1@@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0 # scripts/dtc makefile -hostprogs-always-$(CONFIG_DTC) += dtc +hostprogs-always-$(CONFIG_DTC) += dtc 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 +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/,$(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
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH V6 2/6] scripts: dtc: Build fdtoverlay tool
Quoted 9 lines · David Gibson
Quoted 4 lines · Viresh Kumar
We will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it.
The fdtoverlay program applies (or merges) one or more overlay dtb
Saying "merges" here is probably misleading, since as I mentioned elsewhere fdtoverlay can *not* merge overlays, only apply them to a base tree.
Right, my mistake.
Signature · 1 line
viresh
Re: [PATCH V6 2/6] scripts: dtc: Build fdtoverlay tool
In reply to Viresh KumarQuoted 19 lines · Viresh Kumar
We will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it.
The fdtoverlay program applies (or merges) one or more overlay dtb blobs to a base dtb blob. The kernel build system would later use fdtoverlay to generate the overlaid blobs based on platform specific configurations.
Signed-off-by Viresh Kumar <[email protected]>--- scripts/dtc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/dtc/Makefile +0
-0@@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0
scripts/dtc/Makefile line 10
Quoted 10 lines
scripts/dtc/Makefile +1
-1# scripts/dtc makefile -hostprogs-always-$(CONFIG_DTC) += dtc +hostprogs-always-$(CONFIG_DTC) += dtc 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
Please add this comment:
# The upstream project builds libfdt as a separate library. We are choosing to
# instead directly link the libfdt object files into fdtoverly
Quoted 8 lines
scripts/dtc/Makefile +4
-0+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/,$(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
Re: [PATCH V6 2/6] scripts: dtc: Build fdtoverlay tool
Quoted 33 lines · Frank Rowand
Quoted 19 lines · Viresh Kumar
We will start building overlays for platforms soon in the kernel and would need fdtoverlay going forward. Lets start building it.
The fdtoverlay program applies (or merges) one or more overlay dtb blobs to a base dtb blob. The kernel build system would later use fdtoverlay to generate the overlaid blobs based on platform specific configurations.
Signed-off-by Viresh Kumar <[email protected]>--- scripts/dtc/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)scripts/dtc/Makefile +0
-0@@ -1,13 +1,17 @@ # SPDX-License-Identifier: GPL-2.0scripts/dtc/Makefile line 10
Quoted 10 lines
scripts/dtc/Makefile +1
-1# scripts/dtc makefile -hostprogs-always-$(CONFIG_DTC) += dtc +hostprogs-always-$(CONFIG_DTC) += dtc 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.oPlease add this comment:
Quoted 2 lines
# The upstream project builds libfdt as a separate library. We are choosing to
# instead directly link the libfdt object files into fdtoverly
My bad, I checked this again and you gave the exact same comment during V4 as well. Sorry about missing this earlier.
Signature · 1 line
viresh
PATCH v6 3/6 scripts: dtc: Remove the unused fdtdump.c file
In reply to Viresh KumarThis was copied from external DTC repository long back and isn't used anymore. Over that the dtc tool can be used to generate the dts source back from the dtb. Remove the unused fdtdump.c file.
--- scripts/dtc/fdtdump.c | 163 ------------------------------------------ 1 file changed, 163 deletions(-) delete mode 100644 scripts/dtc/fdtdump.c
scripts/dtc/fdtdump.c deleted +0 -163
@@ -1,163 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* -* fdtdump.c - Contributed by Pantelis Antoniou <pantelis.antoniou AT gmail.com> -*/ - -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include <fdt.h> -#include <libfdt_env.h> - -#include "util.h" - -#define ALIGN (x, a) (((x) + ((a) - 1)) & ~((a) - 1)) -#define PALIGN (p, a) ((void *)(ALIGN((unsigned long)(p), (a)))) -#define GET_CELL (p) (p += 4, *((const uint32_t *)(p-4))) - -static void print_data (const char *data,int len) -{ -int i; -const char *p = data; - -/* no data, don't print */ -if (len ==0 ) -return ; - -if (util_is_printable_string (data, len)) { -printf (" = \"%s\"" , (const char *)data); - }else if ((len %4 ) ==0 ) { -printf (" = <" ); -for (i =0 ; i < len; i +=4 ) -printf ("0x%08x%s" ,fdt32_to_cpu (GET_CELL (p)), - i < (len -4 ) ?" " :"" ); -printf (">" ); - }else { -printf (" = [" ); -for (i =0 ; i < len; i++) -printf ("%02x%s" , *p++, i < len -1 ?" " :"" ); -printf ("]" ); - } -} - -static void dump_blob (void *blob) -{ -struct fdt_header *bph = blob; -uint32_t off_mem_rsvmap =fdt32_to_cpu (bph->off_mem_rsvmap); -uint32_t off_dt =fdt32_to_cpu (bph->off_dt_struct); -uint32_t off_str =fdt32_to_cpu (bph->off_dt_strings); -struct fdt_reserve_entry *p_rsvmap = - (struct fdt_reserve_entry *)((char *)blob + off_mem_rsvmap); -const char *p_struct = (const char *)blob + off_dt; -const char *p_strings = (const char *)blob + off_str; -uint32_t version =fdt32_to_cpu (bph->version); -uint32_t totalsize =fdt32_to_cpu (bph->totalsize); -uint32_t tag; -const char *p, *s, *t; -int depth, sz, shift; -int i; -uint64_t addr, size; - - depth =0 ; - shift =4 ; - -printf ("/dts-v1/;\n" ); -printf ("// magic:\t\t0x%x\n" ,fdt32_to_cpu (bph->magic)); -printf ("// totalsize:\t\t0x%x (%d)\n" , totalsize, totalsize); -printf ("// off_dt_struct:\t0x%x\n" , off_dt); -printf ("// off_dt_strings:\t0x%x\n" , off_str); -printf ("// off_mem_rsvmap:\t0x%x\n" , off_mem_rsvmap); -printf ("// version:\t\t%d\n" , version); -printf ("// last_comp_version:\t%d\n" , -fdt32_to_cpu (bph->last_comp_version)); -if (version >=2 ) -printf ("// boot_cpuid_phys:\t0x%x\n" , -fdt32_to_cpu (bph->boot_cpuid_phys)); - -if (version >=3 ) -printf ("// size_dt_strings:\t0x%x\n" , -fdt32_to_cpu (bph->size_dt_strings)); -if (version >=17 ) -printf ("// size_dt_struct:\t0x%x\n" , -fdt32_to_cpu (bph->size_dt_struct)); -printf ("\n" ); - -for (i =0 ; ; i++) { - addr =fdt64_to_cpu (p_rsvmap[i].address); - size =fdt64_to_cpu (p_rsvmap[i].size); -if (addr ==0 && size ==0 ) -break ; - -printf ("/memreserve/ %llx %llx;\n" , - (unsigned long long )addr, (unsigned long long )size); - } - - p = p_struct; -while ((tag =fdt32_to_cpu (GET_CELL (p))) !=FDT_END ) { - -/* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */ - -if (tag ==FDT_BEGIN_NODE ) { - s = p; - p =PALIGN (p +strlen (s) +1 ,4 ); - -if (*s =='\0' ) - s ="/" ; - -printf ("%*s%s {\n" , depth * shift,"" , s); - - depth++; -continue ; - } - -if (tag ==FDT_END_NODE ) { - depth--; - -printf ("%*s};\n" , depth * shift,"" ); -continue ; - } - -if (tag ==FDT_NOP ) { -printf ("%*s// [NOP]\n" , depth * shift,"" ); -continue ; - } - -if (tag !=FDT_PROP ) { -fprintf (stderr,"%*s ** Unknown tag 0x%08x\n" , depth * shift,"" , tag); -break ; - } - sz =fdt32_to_cpu (GET_CELL (p)); - s = p_strings +fdt32_to_cpu (GET_CELL (p)); -if (version <16 && sz >=8 ) - p =PALIGN (p,8 ); - t = p; - - p =PALIGN (p + sz,4 ); - -printf ("%*s%s" , depth * shift,"" , s); -print_data (t, sz); -printf (";\n" ); - } -} - - -int main (int argc,char *argv[]) -{ -char *buf; - -if (argc <2 ) { -fprintf (stderr,"supply input filename\n" ); -return 5 ; - } - - buf =utilfdt_read (argv[1 ]); -if (buf) -dump_blob (buf); -else -return 10 ; - -return 0 ; -}
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
PATCH v6 4/6 kbuild: Add support to build overlays (%.dtbo)
In reply to Viresh KumarAdd 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.
--- .gitignore | 1 + Makefile | 5 ++++- scripts/Makefile.dtbinst | 3 +++ scripts/Makefile.lib | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-)
.gitignore +1 -0
@@ -18,6 +18,7 @@ *.c.[012]*.* *.dt.yaml *.dtb +*.dtbo *.dtb.S *.dwo *.elf
Makefile +4 -1
@@ -1337,6 +1337,9 @@ ifneq ($(dtstree),) %.dtb: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ +%.dtbo: include/config/kernel.release scripts_dtc + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ + PHONY += dtbs dtbs_install dtbs_check dtbs: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree)
@@ -1816,7 +1819,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
@@ -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 +5 -0
@@ -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
@@ -327,6 +329,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
Re: [PATCH V6 4/6] kbuild: Add support to build overlays (%.dtbo)
Quoted 7 lines · Viresh Kumar
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.
Signed-off-by Viresh Kumar <[email protected]>---
Quoted 82 lines
.gitignore | 1 + Makefile | 5 ++++- scripts/Makefile.dtbinst | 3 +++ scripts/Makefile.lib | 5 +++++ 4 files changed, 13 insertions(+), 1 deletion(-).gitignore +1
-0@@ -18,6 +18,7 @@ *.c.[012]*.* *.dt.yaml *.dtb +*.dtbo *.dtb.S *.dwo *.elfMakefile +4
-1@@ -1337,6 +1337,9 @@ ifneq ($(dtstree),) %.dtb: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ +%.dtbo: include/config/kernel.release scripts_dtc + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ + PHONY += dtbs dtbs_install dtbs_check dtbs: include/config/kernel.release scripts_dtc $(Q)$(MAKE) $(build)=$(dtstree)@@ -1816,7 +1819,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@@ -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 +5
-1@@ -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@@ -327,6 +329,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 --2.25.0.rc1.19.g042ed3e048af
Signature · 2 lines
Best Regards Masahiro Yamada
PATCH v6 5/6 of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
In reply to Viresh KumarIn order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing overlay_base.dts and testcases_common.dts files to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.
The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsi
drivers/of/unittest-data/overlay_base.dts +1 -89
@@ -2,92 +2,4 @@ /dts-v1/; /plugin/; -/* - * Base device tree that overlays will be applied against. - * - * Do not add any properties in node "/". - * Do not add any nodes other than "/testcase-data-2" in node "/". - * Do not add anything that would result in dtc creating node "/__fixups__". - * dtc will create nodes "/__symbols__" and "/__local_fixups__". - */ - -/ { - testcase-data-2 { - #address-cells = <1>; - #size-cells = <1>; - - electric_1: substation@100 { - compatible = "ot,big-volts-control"; - reg = < 0x00000100 0x100 >; - status = "disabled"; - - hvac_1: hvac-medium-1 { - compatible = "ot,hvac-medium"; - heat-range = < 50 75 >; - cool-range = < 60 80 >; - }; - - spin_ctrl_1: motor-1 { - compatible = "ot,ferris-wheel-motor"; - spin = "clockwise"; - rpm_avail = < 50 >; - }; - - spin_ctrl_2: motor-8 { - compatible = "ot,roller-coaster-motor"; - }; - }; - - rides_1: fairway-1 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "ot,rides"; - status = "disabled"; - orientation = < 127 >; - - ride@100 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "ot,roller-coaster"; - reg = < 0x00000100 0x100 >; - hvac-provider = < &hvac_1 >; - hvac-thermostat = < 29 > ; - hvac-zones = < 14 >; - hvac-zone-names = "operator"; - spin-controller = < &spin_ctrl_2 5 &spin_ctrl_2 7 >; - spin-controller-names = "track_1", "track_2"; - queues = < 2 >; - - track@30 { - reg = < 0x00000030 0x10 >; - }; - - track@40 { - reg = < 0x00000040 0x10 >; - }; - - }; - }; - - lights_1: lights@30000 { - compatible = "ot,work-lights"; - reg = < 0x00030000 0x1000 >; - status = "disabled"; - }; - - lights_2: lights@40000 { - compatible = "ot,show-lights"; - reg = < 0x00040000 0x1000 >; - status = "disabled"; - rate = < 13 138 >; - }; - - retail_1: vending@50000 { - reg = < 0x00050000 0x1000 >; - compatible = "ot,tickets"; - status = "disabled"; - }; - - }; -}; - +#include "overlay_common.dtsi"
drivers/of/unittest-data/overlay_common.dtsi new file +91 -0
91 lines not on this page · raw message
drivers/of/unittest-data/testcases.dts +1 -16
@@ -2,19 +2,4 @@ /dts-v1/; /plugin/; -/ { - testcase-data { - changeset { - prop-update = "hello"; - prop-remove = "world"; - node-remove { - }; - }; - }; -}; -#include "tests-phandle.dtsi" -#include "tests-interrupts.dtsi" -#include "tests-match.dtsi" -#include "tests-address.dtsi" -#include "tests-platform.dtsi" -#include "tests-overlay.dtsi" +#include "testcases_common.dtsi"
drivers/of/unittest-data/testcases_common.dtsi new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0 + +/ { + testcase-data { + changeset { + prop-update = "hello"; + prop-remove = "world"; + node-remove { + }; + }; + }; +}; +#include "tests-phandle.dtsi" +#include "tests-interrupts.dtsi" +#include "tests-match.dtsi" +#include "tests-address.dtsi" +#include "tests-platform.dtsi" +#include "tests-overlay.dtsi"
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
Quoted 27 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsidrivers/of/unittest-data/overlay_base.dts +0
-0
drivers/of/unittest-data/overlay_base.dts line 3
Quoted 2 lines
drivers/of/unittest-data/overlay_base.dts +0
-0@@ -2,92 +2,4 @@ /dts-v1/; /plugin/;
This still makes no sense to me. Is this data intended as a base tree, or as an overlay? If it's an overlay, what are the constraints on the base tree it's supposed to apply to.
This patch is treating it as both in different places, but that's such a bizarre usecase it needs detailed justification. It really looks like the unittest stuff is doing some very bogus stuff that should be fixed first, before trying to do this on top.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
Quoted 35 lines · David Gibson
Quoted 27 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsidrivers/of/unittest-data/overlay_base.dts +0
-0drivers/of/unittest-data/overlay_base.dts line 3
Quoted 2 lines
drivers/of/unittest-data/overlay_base.dts +0
-0@@ -2,92 +2,4 @@ /dts-v1/; /plugin/;This still makes no sense to me. Is this data intended as a base tree, or as an overlay? If it's an overlay, what are the constraints on the base tree it's supposed to apply to.
Quoted 4 lines
This patch is treating it as both in different places, but that's such a bizarre usecase it needs detailed justification. It really looks like the unittest stuff is doing some very bogus stuff that should be fixed first, before trying to do this on top.
I will let Frank respond to that :)
Signature · 1 line
viresh
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
In reply to David GibsonQuoted 23 lines · David Gibson
Quoted 22 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsi
Quoted 11 lines
drivers/of/unittest-data/overlay_base.dts line 3
Quoted 7 lines
drivers/of/unittest-data/overlay_base.dts +0
-0@@ -2,92 +2,4 @@ /dts-v1/; /plugin/;This still makes no sense to me. Is this data intended as a base tree, or as an overlay? If it's an overlay, what are the constraints on the base tree it's supposed to apply to.
I have already replied several times that this should not make sense to anyone unless they read unittest.c and see in detail how these FDTs are abused. I have stated several times that the usage is bizarre and not normal.
Quoted 6 lines
This patch is treating it as both in different places, but that's such a bizarre usecase it needs detailed justification. It really looks like the unittest stuff is doing some very bogus stuff that should be fixed first, before trying to do this on top.
The unittest stuff is bizarre, but it is correct. This patch series does not alter the current usage.
-Frank
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
In reply to Viresh KumarQuoted 13 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>
Quoted 8 lines
--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsi
Frank,
As I mentioned in the cover-letter, I get a build warning right now:
drivers/of/unittest-data/tests-interrupts.dtsi:20.5-28: Warning (interrupts_property): /testcase-data/testcase-device2:#interrupt-cells: size is (4), expected multiple of 8
I think I need to add below diff to this patch to fix this warning, will that be okay ?
drivers/of/unittest-data/testcases.dts +11 -0
@@ -3,3 +3,14 @@ /plugin/; #include "testcases_common.dtsi" + +/ { + testcase-data { + testcase-device2 { + compatible = "testcase-device"; + interrupt-parent = <&test_intc2>; + interrupts = <1>; /* invalid specifier - too short */ + }; + }; + +};
drivers/of/unittest-data/tests-interrupts.dtsi +0 -7
@@ -61,12 +61,5 @@ testcase-device1 { interrupt-parent = <&test_intc0>; interrupts = <1>; }; - - testcase-device2 { - compatible = "testcase-device"; - interrupt-parent = <&test_intc2>; - interrupts = <1>; /* invalid specifier - too short */ - }; }; - };
Signature · 1 line
viresh
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
Hi Viresh,
Quoted 23 lines · Viresh Kumar
Quoted 13 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>Quoted 8 lines
--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsi
Quoted 5 lines
Frank,
As I mentioned in the cover-letter, I get a build warning right now:
drivers/of/unittest-data/tests-interrupts.dtsi:20.5-28: Warning (
interrupts_property): /testcase-data/testcase-device2:#interrupt-cells: size is (4), expected multiple of 8
Thanks for catching that.
Quoted 3 lines
I think I need to add below diff to this patch to fix this warning, will that be okay ?
Nope, the change below won't work because it removes the node testcase-device2 from the tests that unittest.c does (if I am thinking correctly). I will double check my thinking, but I know you are spinning the patch, so I didn't want to delay this reply.
Note that this node has a deliberate error in it "/* invalid specifier - too short */".
I'm not sure why the dtc warning triggers on line 20 instead of line 68. I'll have to go look at the dtc source to better understand the warning.
-Frank
Quoted 38 lines
drivers/of/unittest-data/testcases.dts +11
-0@@ -3,3 +3,14 @@ /plugin/; #include "testcases_common.dtsi" + +/ { + testcase-data { + testcase-device2 { + compatible = "testcase-device"; + interrupt-parent = <&test_intc2>; + interrupts = <1>; /* invalid specifier - too short */ + }; + }; + +};drivers/of/unittest-data/tests-interrupts.dtsi +0
-7@@ -61,12 +61,5 @@ testcase-device1 { interrupt-parent = <&test_intc0>; interrupts = <1>; }; - - testcase-device2 { - compatible = "testcase-device"; - interrupt-parent = <&test_intc2>; - interrupts = <1>; /* invalid specifier - too short */ - }; }; - };
Re: [PATCH V6 5/6] of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
In reply to Viresh KumarHi Viresh,
Second attempt, I think the first reply did not properly send.
Quoted 23 lines · Viresh Kumar
Quoted 13 lines · Viresh Kumar
In order to build-test the same unit-test files using fdtoverlay tool, move the device nodes from the existing
overlay_base.dtsandtestcases_common.dtsfiles to .dtsi files. The .dts files now include the new .dtsi files, resulting in exactly the same behavior as earlier.The .dtsi files can now be reused for compile time tests using fdtoverlay (will be done in a later patch).
This is required because the base files passed to fdtoverlay tool shouldn't be overlays themselves (i.e. shouldn't have the /plugin/; tag).
Signed-off-by Viresh Kumar <[email protected]>Quoted 8 lines
--- drivers/of/unittest-data/overlay_base.dts | 90 +----------------- drivers/of/unittest-data/overlay_common.dtsi | 91 +++++++++++++++++++ drivers/of/unittest-data/testcases.dts | 17 +--- .../of/unittest-data/testcases_common.dtsi | 18 ++++ 4 files changed, 111 insertions(+), 105 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/testcases_common.dtsi
Quoted 5 lines
Frank,
As I mentioned in the cover-letter, I get a build warning right now:
drivers/of/unittest-data/tests-interrupts.dtsi:20.5-28: Warning (
interrupts_property): /testcase-data/testcase-device2:#interrupt-cells: size is (4), expected multiple of 8
Thanks for catching that.
Quoted 3 lines
I think I need to add below diff to this patch to fix this warning, will that be okay ?
In my first reply, I said "nope", or something to that effect. Upon reflection, it looks like the below diff will fix the problem. This is base on source code inspection and building with the diff applied.
I did not successfully boot my target (I have some issues to resolve after updating the OS on my development host), so I have not verified that unittest is not impacted.
-Frank
Quoted 38 lines
drivers/of/unittest-data/testcases.dts +11
-0@@ -3,3 +3,14 @@ /plugin/; #include "testcases_common.dtsi" + +/ { + testcase-data { + testcase-device2 { + compatible = "testcase-device"; + interrupt-parent = <&test_intc2>; + interrupts = <1>; /* invalid specifier - too short */ + }; + }; + +};drivers/of/unittest-data/tests-interrupts.dtsi +0
-7@@ -61,12 +61,5 @@ testcase-device1 { interrupt-parent = <&test_intc0>; interrupts = <1>; }; - - testcase-device2 { - compatible = "testcase-device"; - interrupt-parent = <&test_intc2>; - interrupts = <1>; /* invalid specifier - too short */ - }; }; - };
PATCH v6 6/6 of: unittest: Statically apply overlays using fdtoverlay
In reply to Viresh KumarNow that fdtoverlay is part of the kernel build, start using it to test the unitest overlays we have by applying them statically. Create a new base file static_base.dts which includes other .dtsi files.
Some unittest overlays deliberately contain errors that unittest checks for. These overlays will cause fdtoverlay to fail, and are thus not included in the static_test.dtb.
--- drivers/of/unittest-data/Makefile | 51 ++++++++++++++++++++++++ drivers/of/unittest-data/static_base.dts | 5 +++ 2 files changed, 56 insertions(+) create mode 100644 drivers/of/unittest-data/static_base.dts
drivers/of/unittest-data/Makefile +51 -0
@@ -34,7 +34,58 @@ DTC_FLAGS_overlay += -@ DTC_FLAGS_overlay_bad_phandle += -@ DTC_FLAGS_overlay_bad_symbol += -@ DTC_FLAGS_overlay_base += -@ +DTC_FLAGS_static_base += -@ DTC_FLAGS_testcases += -@ # suppress warnings about intentional errors DTC_FLAGS_testcases += -Wno-interrupts_property + +# Apply overlays statically with fdtoverlay. This is a build time test that +# the overlays can be applied successfully by fdtoverlay. This does not +# guarantee that the overlays can be applied successfully at run time by +# unittest, but it provides a bit of build time test coverage for those +# who do not execute unittest. +# +# The overlays are applied on top of static_base.dtb to create static_test.dtb +# If fdtoverlay detects an error than the kernel build will fail. +# static_test.dtb is not consumed by unittest. +# +# Some unittest overlays deliberately contain errors that unittest checks for. +# These overlays will cause fdtoverlay to fail, and are thus not included +# in the static test: +# overlay_bad_add_dup_node.dtb \ +# overlay_bad_add_dup_prop.dtb \ +# overlay_bad_phandle.dtb \ +# overlay_bad_symbol.dtb \ +# overlay_base.dtb \ + +apply_static_overlay := overlay.dtb \ + overlay_0.dtb \ + overlay_1.dtb \ + overlay_2.dtb \ + overlay_3.dtb \ + overlay_4.dtb \ + overlay_5.dtb \ + overlay_6.dtb \ + overlay_7.dtb \ + overlay_8.dtb \ + overlay_9.dtb \ + overlay_10.dtb \ + overlay_11.dtb \ + overlay_12.dtb \ + overlay_13.dtb \ + overlay_15.dtb \ + overlay_gpio_01.dtb \ + overlay_gpio_02a.dtb \ + overlay_gpio_02b.dtb \ + overlay_gpio_03.dtb \ + overlay_gpio_04a.dtb \ + overlay_gpio_04b.dtb + +quiet_cmd_fdtoverlay = FDTOVERLAY $@ + cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $^ + +$(obj)/static_test.dtb: $(obj)/static_base.dtb $(addprefix $(obj)/,$(apply_static_overlay)) + $(call if_changed,fdtoverlay) + +always-$(CONFIG_OF_OVERLAY) += static_test.dtb
drivers/of/unittest-data/static_base.dts new file +5 -0
@@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "overlay_common.dtsi" +#include "testcases_common.dtsi"
Signature · 1 line
2.25.0.rc1.19.g042ed3e048af
Re: [PATCH V6 6/6] of: unittest: Statically apply overlays using fdtoverlay
Quoted 39 lines · Viresh Kumar
Now that fdtoverlay is part of the kernel build, start using it to test the unitest overlays we have by applying them statically. Create a new base file
static_base.dtswhich includes other .dtsi files.Some unittest overlays deliberately contain errors that unittest checks for. These overlays will cause fdtoverlay to fail, and are thus not included in the static_test.dtb.
Signed-off-by Viresh Kumar <[email protected]>--- drivers/of/unittest-data/Makefile | 51 ++++++++++++++++++++++++ drivers/of/unittest-data/static_base.dts | 5 +++ 2 files changed, 56 insertions(+) create mode 100644 drivers/of/unittest-data/static_base.dtsdrivers/of/unittest-data/Makefile +12
-0@@ -34,7 +34,58 @@ DTC_FLAGS_overlay += -@ DTC_FLAGS_overlay_bad_phandle += -@ DTC_FLAGS_overlay_bad_symbol += -@ DTC_FLAGS_overlay_base += -@ +DTC_FLAGS_static_base += -@ DTC_FLAGS_testcases += -@ # suppress warnings about intentional errors DTC_FLAGS_testcases += -Wno-interrupts_property + +# Apply overlays statically with fdtoverlay. This is a build time test that +# the overlays can be applied successfully by fdtoverlay. This does not +# guarantee that the overlays can be applied successfully at run time by +# unittest, but it provides a bit of build time test coverage for those +# who do not execute unittest. +# +# The overlays are applied on top of static_base.dtb to create static_test.dtb +# If fdtoverlay detects an error than the kernel build will fail. +# static_test.dtb is not consumed by unittest. +#
drivers/of/unittest-data/Makefile DTC_FLAGS_overlay += -@ · line 62
Quoted 10 lines
drivers/of/unittest-data/Makefile +10
-0+# Some unittest overlays deliberately contain errors that unittest checks for. +# These overlays will cause fdtoverlay to fail, and are thus not included +# in the static test: +# overlay_bad_add_dup_node.dtb \ +# overlay_bad_add_dup_prop.dtb \ +# overlay_bad_phandle.dtb \ +# overlay_bad_symbol.dtb \ +# overlay_base.dtb \ + +apply_static_overlay := overlay.dtb \
rename apply_static_overlay to apply_static_overlay_2:
apply_static_overlay_2 := overlay.dtb
Then the remainder of apply_static_overlay becomes apply_static_overlay_1:
apply_static_overlay_1 :=
Quoted 19 lines
drivers/of/unittest-data/Makefile +19
-0+ overlay_0.dtb \ + overlay_1.dtb \ + overlay_2.dtb \ + overlay_3.dtb \ + overlay_4.dtb \ + overlay_5.dtb \ + overlay_6.dtb \ + overlay_7.dtb \ + overlay_8.dtb \ + overlay_9.dtb \ + overlay_10.dtb \ + overlay_11.dtb \ + overlay_12.dtb \ + overlay_13.dtb \ + overlay_15.dtb \ + overlay_gpio_01.dtb \ + overlay_gpio_02a.dtb \ + overlay_gpio_02b.dtb \ + overlay_gpio_03.dtb \
drivers/of/unittest-data/Makefile DTC_FLAGS_overlay += -@ · line 89
Quoted 10 lines
drivers/of/unittest-data/Makefile +8
-0+ overlay_gpio_04a.dtb \ + overlay_gpio_04b.dtb + +quiet_cmd_fdtoverlay = FDTOVERLAY $@ + cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $^ + +$(obj)/static_test.dtb: $(obj)/static_base.dtb $(addprefix $(obj)/,$(apply_static_overlay)) + $(call if_changed,fdtoverlay)
Split the static_test.dtb into _1 and _2:
Quoted 17 lines
+$(obj)/static_test_1.dtb: $(obj)/static_base_1.dtb $(addprefix $(obj)/,$(apply_static_overlay_1))
drivers/of/unittest-data/Makefile +5
-0+ $(call if_changed,fdtoverlay) +$(obj)/static_test_2.dtb: $(obj)/static_base_2.dtb $(addprefix $(obj)/,$(apply_static_overlay_2)) + $(call if_changed,fdtoverlay) + +always-$(CONFIG_OF_OVERLAY) += static_test.dtbdrivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +0
-0
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@
Quoted 5 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "overlay_common.dtsi" +#include "testcases_common.dtsi"
Split static_base.dts into static_base_1.dts and static_base_2.dts:
static_base_1.dts:
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@
Quoted 4 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +4
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "testcases_common.dtsi"
static_base_2.dts:
Quoted 4 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +4
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "overlay_common.dtsi"
Re: [PATCH V6 6/6] of: unittest: Statically apply overlays using fdtoverlay
Quoted 93 lines · Frank Rowand
Quoted 39 lines · Viresh Kumar
Now that fdtoverlay is part of the kernel build, start using it to test the unitest overlays we have by applying them statically. Create a new base file
static_base.dtswhich includes other .dtsi files.Some unittest overlays deliberately contain errors that unittest checks for. These overlays will cause fdtoverlay to fail, and are thus not included in the static_test.dtb.
Signed-off-by Viresh Kumar <[email protected]>--- drivers/of/unittest-data/Makefile | 51 ++++++++++++++++++++++++ drivers/of/unittest-data/static_base.dts | 5 +++ 2 files changed, 56 insertions(+) create mode 100644 drivers/of/unittest-data/static_base.dtsdrivers/of/unittest-data/Makefile +12
-0@@ -34,7 +34,58 @@ DTC_FLAGS_overlay += -@ DTC_FLAGS_overlay_bad_phandle += -@ DTC_FLAGS_overlay_bad_symbol += -@ DTC_FLAGS_overlay_base += -@ +DTC_FLAGS_static_base += -@ DTC_FLAGS_testcases += -@ # suppress warnings about intentional errors DTC_FLAGS_testcases += -Wno-interrupts_property + +# Apply overlays statically with fdtoverlay. This is a build time test that +# the overlays can be applied successfully by fdtoverlay. This does not +# guarantee that the overlays can be applied successfully at run time by +# unittest, but it provides a bit of build time test coverage for those +# who do not execute unittest. +# +# The overlays are applied on top of static_base.dtb to create static_test.dtb +# If fdtoverlay detects an error than the kernel build will fail. +# static_test.dtb is not consumed by unittest. +#drivers/of/unittest-data/Makefile DTC_FLAGS_overlay += -@ · line 62
Quoted 10 lines
drivers/of/unittest-data/Makefile +10
-0+# Some unittest overlays deliberately contain errors that unittest checks for. +# These overlays will cause fdtoverlay to fail, and are thus not included +# in the static test: +# overlay_bad_add_dup_node.dtb \ +# overlay_bad_add_dup_prop.dtb \ +# overlay_bad_phandle.dtb \ +# overlay_bad_symbol.dtb \ +# overlay_base.dtb \ + +apply_static_overlay := overlay.dtb \rename
apply_static_overlaytoapply_static_overlay_2:
apply_static_overlay_2:= overlay.dtbThen the remainder of
apply_static_overlaybecomesapply_static_overlay_1:
apply_static_overlay_1:=Quoted 19 lines
drivers/of/unittest-data/Makefile +19
-0+ overlay_0.dtb \ + overlay_1.dtb \ + overlay_2.dtb \ + overlay_3.dtb \ + overlay_4.dtb \ + overlay_5.dtb \ + overlay_6.dtb \ + overlay_7.dtb \ + overlay_8.dtb \ + overlay_9.dtb \ + overlay_10.dtb \ + overlay_11.dtb \ + overlay_12.dtb \ + overlay_13.dtb \ + overlay_15.dtb \ + overlay_gpio_01.dtb \ + overlay_gpio_02a.dtb \ + overlay_gpio_02b.dtb \ + overlay_gpio_03.dtb \drivers/of/unittest-data/Makefile DTC_FLAGS_overlay += -@ · line 89
Quoted 10 lines
drivers/of/unittest-data/Makefile +8
-0+ overlay_gpio_04a.dtb \ + overlay_gpio_04b.dtb + +quiet_cmd_fdtoverlay = FDTOVERLAY $@ + cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $^ + +$(obj)/static_test.dtb: $(obj)/static_base.dtb $(addprefix $(obj)/,$(apply_static_overlay)) + $(call if_changed,fdtoverlay)Split the static_test.dtb into _1 and _2:
Quoted 2 lines
+$(obj)/static_test_1.dtb: $(obj)/static_base_1.dtb $(addprefix $(obj)/,$(apply_static_overlay_1))
drivers/of/unittest-data/Makefile +1
-0+ $(call if_changed,fdtoverlay)
Quoted 6 lines
drivers/of/unittest-data/Makefile DTC_FLAGS_overlay += -@ · line 91
Quoted 6 lines
+$(obj)/static_test_2.dtb: $(obj)/static_base_2.dtb $(addprefix $(obj)/,$(apply_static_overlay_2))
drivers/of/unittest-data/Makefile +3
-0+ $(call if_changed,fdtoverlay) + +always-$(CONFIG_OF_OVERLAY) += static_test.dtb
and of source the config line becomes static_test_1.dtb and static_test_2.dtb
Hopefully I haven't missed any other details...
-Frank
Quoted 30 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@
Quoted 13 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +5
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "overlay_common.dtsi" +#include "testcases_common.dtsi"Split
static_base.dtsintostatic_base_1.dtsandstatic_base_2.dts:
static_base_1.dts:drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@
Quoted 4 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +4
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "testcases_common.dtsi"
static_base_2.dts:Quoted 4 lines
drivers/of/unittest-data/static_base.dt> @@ -0,0 +1,5 @@ new file +4
-0+// SPDX-License-Identifier: GPL-2.0 +/dts-v1/; + +#include "overlay_common.dtsi"
Quoted 13 lines · Viresh Kumar
Hi Frank/Rob,
This patchset makes necessary changes to the kernel to add support for building overlays (%.dtbo) and the required fdtoverlay tool. This also builds static_test.dtb using most of the existing overlay tests present in
drivers/of/unittest-data/for better test coverage.Note that in order for anyone to test this stuff, you need to manually run the ./update-dtc-source.sh script once to fetch the necessary changes from the external DTC project (i.e.
fdtoverlay.cand this[1] patch).
Quoted 4 lines
Also note that Frank has already shared his concerns towards the error reporting done by fdtoverlay tool [2], and David said it is not that straight forward to make such changes in fdtoverlay. I have still included the patch in this series for completeness.
I started to reply to this email with questions for David about how to improve the fdtoverlay error reporting. But then decided that instead of trying to paraphrase the comments in v4 of this patch series, it would be more efficient to ask in the v4 thread. So my questions are over there...
-Frank
Quoted 57 lines
FWIW, with fdtoverlay we generate a new build warning now, not sure why though:
drivers/of/unittest-data/tests-interrupts.dtsi:20.5-28: Warning (
interrupts_property): /testcase-data/testcase-device2:#interrupt-cells: size is (4), expected multiple of 8V6:
- Create separate rules for dtbo-s and separate entries in .gitignore in 4/6 (Masahiro).
- A new file layout for handling all overlays for existing and new tests 5/6 (Frank).
- Includeoverlay.dtsas well now in 6/6 (Frank).V5:
- Don't reuse
DTC_SOURCEforfdtoverlay.cin patch 1/5 (Frank).- Update .gitignore and
scripts/Makefile.dtbinst, drop dtbo-y syntax andDTC_FLAGS+= -@ in patch 4/5 (Masahiro).- Remove the intermediate dtb, rename output to static_test.dtb, don't use overlay.dtb and overlay_base.dtb for static builds, improved layout/comments in
Makefilefor patch 5/5 (Frank).--
Viresh[1] https://github.com/dgibson/dtc/commit/163f0469bf2ed8b2fe5aa15bc796b93c70243ddc
[2] https://lore.kernel.org/lkml/[email protected]/Viresh Kumar (6):
scripts: dtc: Fetchfdtoverlay.cfrom external DTC project
scripts: dtc: Build fdtoverlay tool
scripts: dtc: Remove the unusedfdtdump.cfile
kbuild: Add support to build overlays (%.dtbo)
of: unittest: Createoverlay_common.dtsiandtestcases_common.dtsi
of: unittest: Statically apply overlays using fdtoverlay.gitignore | 1 + Makefile | 5 +- drivers/of/unittest-data/Makefile | 51 ++++++ drivers/of/unittest-data/overlay_base.dts | 90 +--------- drivers/of/unittest-data/overlay_common.dtsi | 91 ++++++++++ drivers/of/unittest-data/static_base.dts | 5 + drivers/of/unittest-data/testcases.dts | 17 +- .../of/unittest-data/testcases_common.dtsi | 18 ++ scripts/Makefile.dtbinst | 3 + scripts/Makefile.lib | 5 + scripts/dtc/Makefile | 6 +- scripts/dtc/fdtdump.c | 163 ------------------ scripts/dtc/update-dtc-source.sh | 3 +- 13 files changed, 187 insertions(+), 271 deletions(-) create mode 100644 drivers/of/unittest-data/overlay_common.dtsi create mode 100644 drivers/of/unittest-data/static_base.dts create mode 100644 drivers/of/unittest-data/testcases_common.dtsi delete mode 100644 scripts/dtc/fdtdump.c