This introduces config variables that allow adding additional fragments to the Barbox device tree(s). Example uses are adjusting the flash partition layout, adding barebox state varibles, or adding an I2C device. These can be now be done with build configuration only, without needing to patch the existing dts files in the Barebox source. The advantage is greater when an external build system, such as Yocto or Buildroot, is being used to build Barebox. The build system can drop in a dts fragment to partition flash and build from unaltered Barebox source. This avoids the need for cumbersome maintenance of patch files to modify Barebox's source for each flash partition layout. Two variables are added, which function identically. The idea is that one can be used in Barebox in-tree or out-of-tree defconfig files and the other injected by an external build system. Injecting the latter variable will not clobber the value of the former. Preprocessing the dts file gains another layer, where a generated dts source consisting of an include directive for the original dts source is followed by more includes for each fragment. This is piped to the existing preprocessor call on stdin to avoid another temporary file. cpp/dtc will correctly identify errors in the source files they occur in. The -MT option is used so the cpp auto-dependencies reference the original dts source and not the generated code passed on stdin. Signed-off-by: Trent Piepho <trent.piepho@xxxxxxxxxxxxxxxxx> --- common/Kconfig | 20 ++++++++++++++++++++ scripts/Makefile.lib | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/common/Kconfig b/common/Kconfig index a9feae2ae..1b95ded87 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -1091,6 +1091,26 @@ config SYSTEMD_OF_WATCHDOG in the kernel device tree. If the kernel is booted without a device tree or with one that lacks aliases, nothing is added. +config EXTRA_DTS_FRAGMENTS + string "additional dts file fragments" + depends on OFTREE + help + List of dts fragment files that will be appended to Barebox's device + tree(s) source when building the dtb file(s). If multiple files are + listed, they will be appended in order. Relative filenames will use + the dtc include search path. + +config EXTERNAL_DTS_FRAGMENTS + string "external dts file fragments" + depends on OFTREE + help + This is like EXTRA_DTS_FRAGMENTS, but it's intended that it not be put + into Barebox defconfig files and instead used by an external build + system, like Yocto or buildroot, to add dts fragments from outside the + Barebox source tree into the Barebox build. The build system can + override this variable without modifying anything set by the Barebox + defconfig. + menu "OP-TEE loading" config OPTEE_SIZE diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 80d76b177..093dd3cdd 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -201,6 +201,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \ + -Wp,-MT,$(basename $(notdir $@)).o \ -I$(srctree)/arch/$(SRCARCH)/dts/include \ -I$(srctree)/dts/include \ -I$(srctree)/include \ @@ -335,8 +336,12 @@ cmd_dt_S_dtb = $(srctree)/scripts/gen-dtb-s $(subst -,_,$(*F)) $< $(CONFIG_IMD) $(obj)/%.dtb.S: $(obj)/%.dtb $(srctree)/scripts/gen-dtb-s FORCE $(call if_changed,dt_S_dtb) +dts-frags = $(subst $(quote),,$(CONFIG_EXTRA_DTS_FRAGMENTS) $(CONFIG_EXTERNAL_DTS_FRAGMENTS)) quiet_cmd_dtc = DTC $@ -cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ +# For compatibility between make 4.2 and 4.3 +H := \# +cmd_dtc = /bin/echo -e $(foreach f,$< $(dts-frags),'$(H)include "$(f)"\n') | \ + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \ $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ -i $(srctree)/arch/$(SRCARCH)/dts $(DTC_FLAGS) \ -i $(srctree)/dts/src/$(SRCARCH) \ -- 2.31.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox