Message ID | 1449099742-8074-1-git-send-email-mar.kolya@gmail.com |
---|---|
State | Changes Requested |
Headers | show |
On 2015-12-03 00:42, Nikolay Martynov wrote: > Current way of compuling dts files involves calling C preprocessor on > main dts file only. This means that dtsi includes cannot have C-style includes. > > This patch addresses this problem. It uses approach similar to one > use in linux kernel: it preprocesses all dtsi's in current dir into > tmp dir and then uses that tmp dir as include dir for main dts compilation. > > Note: this patch preprocesses onlt *.dtsi, not *.dts, so only *.dtsi > can be includes, but it looks like all current architectures follow this convention. > > This approach should be compatible with all current architectures. > > This patch also updates ramips arch to use new dtsi comilation code. > > Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com> > --- > include/image.mk | 22 +++++++++++++++++----- > target/linux/ramips/image/Makefile | 2 +- > 2 files changed, 18 insertions(+), 6 deletions(-) > > --- a/target/linux/ramips/image/Makefile > +++ b/target/linux/ramips/image/Makefile > @@ -39,7 +39,7 @@ define Device/Default > endef > > define Build/patch-dtb > - $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts > + $(call Image/BuildDTB,../dts/$(DTS).dts,$@.dtb,-I$(LINUX_DIR)/arch/mips/boot/dts -I$(LINUX_DIR)/arch/mips/boot/dts/include) Why did you add those -I options? Isn't that already handled by the common preprocessor options in Image/PreprocessDTS? - Felix
HIi 2015-12-03 9:10 GMT-05:00 Felix Fietkau <nbd@openwrt.org>: > On 2015-12-03 00:42, Nikolay Martynov wrote: >> Current way of compuling dts files involves calling C preprocessor on >> main dts file only. This means that dtsi includes cannot have C-style includes. >> >> This patch addresses this problem. It uses approach similar to one >> use in linux kernel: it preprocesses all dtsi's in current dir into >> tmp dir and then uses that tmp dir as include dir for main dts compilation. >> >> Note: this patch preprocesses onlt *.dtsi, not *.dts, so only *.dtsi >> can be includes, but it looks like all current architectures follow this convention. >> >> This approach should be compatible with all current architectures. >> >> This patch also updates ramips arch to use new dtsi comilation code. >> >> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com> >> --- >> include/image.mk | 22 +++++++++++++++++----- >> target/linux/ramips/image/Makefile | 2 +- >> 2 files changed, 18 insertions(+), 6 deletions(-) >> >> --- a/target/linux/ramips/image/Makefile >> +++ b/target/linux/ramips/image/Makefile >> @@ -39,7 +39,7 @@ define Device/Default >> endef >> >> define Build/patch-dtb >> - $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts >> + $(call Image/BuildDTB,../dts/$(DTS).dts,$@.dtb,-I$(LINUX_DIR)/arch/mips/boot/dts -I$(LINUX_DIR)/arch/mips/boot/dts/include) > Why did you add those -I options? Isn't that already handled by the > common preprocessor options in Image/PreprocessDTS? Unfortunately they are not the same. Kernel arch seems to be mipsel which doesn't match directory name it has to look in. I think this is ralink specific.
On 2015-12-03 15:57, Nikolay Martynov wrote: > HIi > > 2015-12-03 9:10 GMT-05:00 Felix Fietkau <nbd@openwrt.org>: >> On 2015-12-03 00:42, Nikolay Martynov wrote: >>> Current way of compuling dts files involves calling C preprocessor on >>> main dts file only. This means that dtsi includes cannot have C-style includes. >>> >>> This patch addresses this problem. It uses approach similar to one >>> use in linux kernel: it preprocesses all dtsi's in current dir into >>> tmp dir and then uses that tmp dir as include dir for main dts compilation. >>> >>> Note: this patch preprocesses onlt *.dtsi, not *.dts, so only *.dtsi >>> can be includes, but it looks like all current architectures follow this convention. >>> >>> This approach should be compatible with all current architectures. >>> >>> This patch also updates ramips arch to use new dtsi comilation code. >>> >>> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com> >>> --- >>> include/image.mk | 22 +++++++++++++++++----- >>> target/linux/ramips/image/Makefile | 2 +- >>> 2 files changed, 18 insertions(+), 6 deletions(-) >>> >>> --- a/target/linux/ramips/image/Makefile >>> +++ b/target/linux/ramips/image/Makefile >>> @@ -39,7 +39,7 @@ define Device/Default >>> endef >>> >>> define Build/patch-dtb >>> - $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts >>> + $(call Image/BuildDTB,../dts/$(DTS).dts,$@.dtb,-I$(LINUX_DIR)/arch/mips/boot/dts -I$(LINUX_DIR)/arch/mips/boot/dts/include) >> Why did you add those -I options? Isn't that already handled by the >> common preprocessor options in Image/PreprocessDTS? > Unfortunately they are not the same. Kernel arch seems to be mipsel > which doesn't match directory name it has to look in. I think this is > ralink specific. Ah, I see what you mean. This is not ramips specific, it's simply a bug in the code inherited from the Image/BuildDTB template. Please change references to arch/$(ARCH) over to arch/$(LINUX_KARCH), and it should work afterwards. - Felix
diff --git a/include/image.mk b/include/image.mk index fd5e3f4..7ce1dc5 100644 --- a/include/image.mk +++ b/include/image.mk @@ -138,19 +138,31 @@ define Image/BuildKernel/MkFIT endef # $(1) source dts file -# $(2) target dtb file +# $(2) target dts file # $(3) extra CPP flags -# $(4) extra DTC flags -define Image/BuildDTB +define Image/PreprocessDTS $(CPP) -nostdinc -x assembler-with-cpp \ -I$(LINUX_DIR)/arch/$(ARCH)/boot/dts \ -I$(LINUX_DIR)/arch/$(ARCH)/boot/dts/include \ -undef -D__DTS__ $(3) \ - -o $(2).tmp $(1) + -o $(2) $(1); +endef + + +# $(1) source dts file +# $(2) target dtb file +# $(3) extra CPP flags +# $(4) extra DTC flags +define Image/BuildDTB + mkdir -p $(2).inc.tmp + $(foreach inc,$(wildcard $(dir $(1))*.dtsi), \ + $(call Image/PreprocessDTS,$(inc),$(2).inc.tmp/$(notdir $(inc)),$(3))) + $(call Image/PreprocessDTS,$(1),$(2).tmp,$(3)) $(LINUX_DIR)/scripts/dtc/dtc -O dtb \ - -i$(dir $(1)) $(4) \ + -i$(2).inc.tmp $(4) \ -o $(2) $(2).tmp $(RM) $(2).tmp + $(RM) -rf $(2).inc.tmp endef define Image/mkfs/jffs2/sub diff --git a/target/linux/ramips/image/Makefile b/target/linux/ramips/image/Makefile index e58d012..00a2923 100644 --- a/target/linux/ramips/image/Makefile +++ b/target/linux/ramips/image/Makefile @@ -39,7 +39,7 @@ define Device/Default endef define Build/patch-dtb - $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts + $(call Image/BuildDTB,../dts/$(DTS).dts,$@.dtb,-I$(LINUX_DIR)/arch/mips/boot/dts -I$(LINUX_DIR)/arch/mips/boot/dts/include) $(STAGING_DIR_HOST)/bin/patch-dtb $@ $@.dtb endef
Current way of compuling dts files involves calling C preprocessor on main dts file only. This means that dtsi includes cannot have C-style includes. This patch addresses this problem. It uses approach similar to one use in linux kernel: it preprocesses all dtsi's in current dir into tmp dir and then uses that tmp dir as include dir for main dts compilation. Note: this patch preprocesses onlt *.dtsi, not *.dts, so only *.dtsi can be includes, but it looks like all current architectures follow this convention. This approach should be compatible with all current architectures. This patch also updates ramips arch to use new dtsi comilation code. Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com> --- include/image.mk | 22 +++++++++++++++++----- target/linux/ramips/image/Makefile | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-)