Commit 6d427c6b1fa0ae97e7c484229d137c6a1f8a4118
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/<arch>/dts/<board.dts>-u-boot.dtsi arch/<arch>/dts/<soc>-u-boot.dtsi arch/<arch>/dts/<cpu>-u-boot.dtsi arch/<arch>/dts/<vendor>-u-boot.dtsi arch/<arch>/dts/u-boot.dtsi Signed-off-by: Simon Glass <sjg@chromium.org> Suggested-by: Tom Rini <trini@konsulko.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Showing 2 changed files with 58 additions and 1 deletions Side-by-side Diff
... | ... | @@ -164,6 +164,21 @@ |
164 | 164 | |
165 | 165 | ld_flags = $(LDFLAGS) $(ldflags-y) |
166 | 166 | |
167 | +dts_dir = $(srctree)/arch/$(ARCH)/dts | |
168 | + | |
169 | +# Try these files in order to find the U-Boot-specific .dtsi include file | |
170 | +u_boot_dtsi_options = $(wildcard $(dts_dir)/$(basename $(notdir $<))-u-boot.dtsi) \ | |
171 | + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_SOC))-u-boot.dtsi) \ | |
172 | + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_CPU))-u-boot.dtsi) \ | |
173 | + $(wildcard $(dts_dir)/$(subst $\",,$(CONFIG_SYS_VENDOR))-u-boot.dtsi) \ | |
174 | + $(wildcard $(dts_dir)/u-boot.dtsi) | |
175 | + | |
176 | +# Uncomment for debugging | |
177 | +# $(warning u_boot_dtsi_options: $(u_boot_dtsi_options)) | |
178 | + | |
179 | +# We use the first match | |
180 | +u_boot_dtsi = $(firstword $(u_boot_dtsi_options)) | |
181 | + | |
167 | 182 | # Modified for U-Boot |
168 | 183 | dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ |
169 | 184 | -I$(srctree)/arch/$(ARCH)/dts \ |
170 | 185 | |
... | ... | @@ -293,8 +308,11 @@ |
293 | 308 | |
294 | 309 | quiet_cmd_dtc = DTC $@ |
295 | 310 | # Modified for U-Boot |
311 | +# Bring in any U-Boot-specific include after the '/dts-v1/;' header | |
296 | 312 | cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ |
297 | - $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ | |
313 | + cat $< $(if $(u-boot-dtsi),\ | |
314 | + | sed 's%^/ {$$%\#include \"$(u-boot-dtsi)\"\n&%') | \ | |
315 | + $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) - ; \ | |
298 | 316 | $(DTC) -O dtb -o $@ -b 0 \ |
299 | 317 | -i $(dir $<) $(DTC_FLAGS) \ |
300 | 318 | -d $(depfile).dtc.tmp $(dtc-tmp) ; \ |
... | ... | @@ -422,6 +422,45 @@ |
422 | 422 | step. |
423 | 423 | |
424 | 424 | |
425 | +Automatic .dtsi inclusion | |
426 | +------------------------- | |
427 | + | |
428 | +It is sometimes inconvenient to add a 'binman' node to the .dts file for each | |
429 | +board. This can be done by using #include to bring in a common file. Another | |
430 | +approach supported by the U-Boot build system is to automatically include | |
431 | +a common header. You can then put the binman node (and anything else that is | |
432 | +specific to U-Boot, such as u-boot,dm-pre-reloc properies) in that header | |
433 | +file. | |
434 | + | |
435 | +Binman will search for the following files in arch/<arch>/dts: | |
436 | + | |
437 | + <dts>-u-boot.dtsi where <dts> is the base name of the .dts file | |
438 | + <CONFIG_SYS_SOC>-u-boot.dtsi | |
439 | + <CONFIG_SYS_CPU>-u-boot.dtsi | |
440 | + <CONFIG_SYS_VENDOR>-u-boot.dtsi | |
441 | + u-boot.dtsi | |
442 | + | |
443 | +U-Boot will only use the first one that it finds. If you need to include a | |
444 | +more general file you can do that from the more specific file using #include. | |
445 | +If you are having trouble figuring out what is going on, you can uncomment | |
446 | +the 'warning' line in scripts/Makefile.lib to see what it has found: | |
447 | + | |
448 | + # Uncomment for debugging | |
449 | + # $(warning binman_dtsi_options: $(binman_dtsi_options)) | |
450 | + | |
451 | + | |
452 | +Code coverage | |
453 | +------------- | |
454 | + | |
455 | +Binman is a critical tool and is designed to be very testable. Entry | |
456 | +implementations target 100% test coverage. Run 'binman -T' to check this. | |
457 | + | |
458 | +To enable Python test coverage on Debian-type distributions (e.g. Ubuntu): | |
459 | + | |
460 | + $ sudo apt-get install python-pip python-pytest | |
461 | + $ sudo pip install coverage | |
462 | + | |
463 | + | |
425 | 464 | Advanced Features / Technical docs |
426 | 465 | ---------------------------------- |
427 | 466 |
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970
-
mentioned in commit ecc970