From b116aff27c56dbc9132d847f7134eb7e4cc26aa3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 25 Nov 2016 20:15:58 -0700 Subject: binman: Allow configuration options to be used in .dts files It is sometimes useful to be able to reference configuration options in a device tree source file. Add the necessary includes so that this works. Signed-off-by: Simon Glass Reviewed-by: Bin Meng Tested-by: Bin Meng --- scripts/Makefile.lib | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 956a8a9b044..a237b7bf859 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -168,6 +168,11 @@ ld_flags = $(LDFLAGS) $(ldflags-y) dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts \ -I$(srctree)/arch/$(ARCH)/dts/include \ + -Iinclude \ + -I$(srctree)/include \ + -I$(srctree)/arch/$(ARCH)/include \ + -include $(srctree)/include/linux/kconfig.h \ + -D__ASSEMBLY__ \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into -- cgit v1.3.1 From 6d427c6b1fa0ae97e7c484229d137c6a1f8a4118 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 25 Nov 2016 20:15:59 -0700 Subject: binman: Automatically include a U-Boot .dtsi file For boards that need U-Boot-specific additions to the device tree, it is a minor annoyance to have to add these each time the tree is synced with upstream. Add a means to include a file (e.g. u-boot.dtsi) automatically into the .dts file before it is compiled. The file uses is the first one that exists in this list: arch//dts/-u-boot.dtsi arch//dts/-u-boot.dtsi arch//dts/-u-boot.dtsi arch//dts/-u-boot.dtsi arch//dts/u-boot.dtsi Signed-off-by: Simon Glass Suggested-by: Tom Rini Reviewed-by: Bin Meng Tested-by: Bin Meng --- scripts/Makefile.lib | 20 +++++++++++++++++++- tools/binman/README | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index a237b7bf859..60265f4d32d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -164,6 +164,21 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE) \ ld_flags = $(LDFLAGS) $(ldflags-y) +dts_dir = $(srctree)/arch/$(ARCH)/dts + +# Try these files in order to find the U-Boot-specific .dtsi include file +u_boot_dtsi_options = $(wildcard $(dts_dir)/$(basename $(notdir $<))-u-boot.dtsi) \ + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_SOC))-u-boot.dtsi) \ + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_CPU))-u-boot.dtsi) \ + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_VENDOR))-u-boot.dtsi) \ + $(wildcard $(dts_dir)/u-boot.dtsi) + +# Uncomment for debugging +# $(warning u_boot_dtsi_options: $(u_boot_dtsi_options)) + +# We use the first match +u_boot_dtsi = $(firstword $(u_boot_dtsi_options)) + # Modified for U-Boot dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts \ @@ -293,8 +308,11 @@ $(obj)/%.dtb.S: $(obj)/%.dtb quiet_cmd_dtc = DTC $@ # Modified for U-Boot +# Bring in any U-Boot-specific include after the '/dts-v1/;' header cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ - $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + cat $< $(if $(u-boot-dtsi),\ + | sed 's%^/ {$$%\#include \"$(u-boot-dtsi)\"\n&%') | \ + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \ $(DTC) -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \ diff --git a/tools/binman/README b/tools/binman/README index 45e741e3b39..cb47e73599a 100644 --- a/tools/binman/README +++ b/tools/binman/README @@ -422,6 +422,45 @@ stage the position and size of entries should not be adjusted. step. +Automatic .dtsi inclusion +------------------------- + +It is sometimes inconvenient to add a 'binman' node to the .dts file for each +board. This can be done by using #include to bring in a common file. Another +approach supported by the U-Boot build system is to automatically include +a common header. You can then put the binman node (and anything else that is +specific to U-Boot, such as u-boot,dm-pre-reloc properies) in that header +file. + +Binman will search for the following files in arch//dts: + + -u-boot.dtsi where is the base name of the .dts file + -u-boot.dtsi + -u-boot.dtsi + -u-boot.dtsi + u-boot.dtsi + +U-Boot will only use the first one that it finds. If you need to include a +more general file you can do that from the more specific file using #include. +If you are having trouble figuring out what is going on, you can uncomment +the 'warning' line in scripts/Makefile.lib to see what it has found: + + # Uncomment for debugging + # $(warning binman_dtsi_options: $(binman_dtsi_options)) + + +Code coverage +------------- + +Binman is a critical tool and is designed to be very testable. Entry +implementations target 100% test coverage. Run 'binman -T' to check this. + +To enable Python test coverage on Debian-type distributions (e.g. Ubuntu): + + $ sudo apt-get install python-pip python-pytest + $ sudo pip install coverage + + Advanced Features / Technical docs ---------------------------------- -- cgit v1.3.1 From 61b994a386eb6f631dc1c2194d4cce9b1a43542c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 25 Nov 2016 20:16:01 -0700 Subject: sunxi: Use binman for sunxi boards Move sunxi boards to use binman. This involves adding the image definition to the device tree and using it in the Makefile. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- Makefile | 6 ++---- arch/arm/dts/sunxi-u-boot.dtsi | 14 ++++++++++++++ scripts/Makefile.lib | 4 ++-- 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 arch/arm/dts/sunxi-u-boot.dtsi (limited to 'scripts') diff --git a/Makefile b/Makefile index 7688e875331..f5f82d203cc 100644 --- a/Makefile +++ b/Makefile @@ -1114,10 +1114,8 @@ u-boot-x86-16bit.bin: u-boot FORCE endif ifneq ($(CONFIG_ARCH_SUNXI),) -OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \ - --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff -u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE - $(call if_changed,pad_cat) +u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img u-boot.dtb FORCE + $(call if_changed,binman) endif ifneq ($(CONFIG_TEGRA),) diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi new file mode 100644 index 00000000000..5adfd9bca2e --- /dev/null +++ b/arch/arm/dts/sunxi-u-boot.dtsi @@ -0,0 +1,14 @@ +#include + +/ { + binman { + filename = "u-boot-sunxi-with-spl.bin"; + pad-byte = <0xff>; + blob { + filename = "spl/sunxi-spl.bin"; + }; + u-boot-img { + pos = ; + }; + }; +}; diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 60265f4d32d..348de2dbf81 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -310,8 +310,8 @@ quiet_cmd_dtc = DTC $@ # Modified for U-Boot # Bring in any U-Boot-specific include after the '/dts-v1/;' header cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ - cat $< $(if $(u-boot-dtsi),\ - | sed 's%^/ {$$%\#include \"$(u-boot-dtsi)\"\n&%') | \ + cat $< $(if $(u_boot_dtsi),\ + | sed 's%^/ {$$%\#include \"$(u_boot_dtsi)\"\n&%') | \ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \ $(DTC) -O dtb -o $@ -b 0 \ -i $(dir $<) $(DTC_FLAGS) \ -- cgit v1.3.1