blob: 2133417412f6c95b0e445d2d6b85bdf0fe53b7ed [file] [log] [blame]
Michael Bestas3952f6c2016-08-26 01:12:08 +03001#----------------------------------------------------------------------
2# Generate device tree image (dt.img)
3#----------------------------------------------------------------------
4ifeq ($(strip $(BOARD_CUSTOM_BOOTIMG_MK)),)
5ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true)
Simon Shields8d96edd2018-04-05 15:02:29 +10006INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
7
8ifeq ($(strip $(BOARD_KERNEL_PREBUILT_DT)),)
Michael Bestas3952f6c2016-08-26 01:12:08 +03009
10ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
Luca Stefani5c60e4f2017-08-17 19:28:48 +020011DTBTOOL_NAME := dtbToolLineage
Michael Bestas3952f6c2016-08-26 01:12:08 +030012else
13DTBTOOL_NAME := $(TARGET_CUSTOM_DTBTOOL)
14endif
15
16DTBTOOL := $(HOST_OUT_EXECUTABLES)/$(DTBTOOL_NAME)$(HOST_EXECUTABLE_SUFFIX)
17
Michael Bestas3952f6c2016-08-26 01:12:08 +030018ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
Luca Stefani5c60e4f2017-08-17 19:28:48 +020019# dtbToolLineage will search subdirectories
Michael Bestas3952f6c2016-08-26 01:12:08 +030020possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/
21else
22# Most specific paths must come first in possible_dtb_dirs
23possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/ $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/
24endif
25
26define build-dtimage-target
27 $(call pretty,"Target dt image: $@")
28 $(hide) for dir in $(possible_dtb_dirs); do \
29 if [ -d "$$dir" ]; then \
30 dtb_dir="$$dir"; \
31 break; \
32 fi; \
33 done; \
34 $(DTBTOOL) $(BOARD_DTBTOOL_ARGS) -o $@ -s $(BOARD_KERNEL_PAGESIZE) -p $(KERNEL_OUT)/scripts/dtc/ "$$dtb_dir";
35 $(hide) chmod a+r $@
36endef
37
Dan Pasanenefe48232017-01-24 14:09:10 -060038ifeq ($(strip $(BOARD_KERNEL_LZ4C_DT)),true)
39LZ4_DT_IMAGE := $(PRODUCT_OUT)/dt-lz4.img
40endif
41
Michael Bestas3952f6c2016-08-26 01:12:08 +030042$(INSTALLED_DTIMAGE_TARGET): $(DTBTOOL) $(INSTALLED_KERNEL_TARGET)
43 $(build-dtimage-target)
Dan Pasanenefe48232017-01-24 14:09:10 -060044ifeq ($(strip $(BOARD_KERNEL_LZ4C_DT)),true)
Dan Pasanenac126892019-10-07 12:55:32 -050045 prebuilts/tools-lineage/${HOST_OS}-x86/bin/lz4 -9 < $@ > $(LZ4_DT_IMAGE)
Dan Pasanenefe48232017-01-24 14:09:10 -060046 $(hide) $(ACP) $(LZ4_DT_IMAGE) $@
47endif
Michael Bestas3952f6c2016-08-26 01:12:08 +030048 @echo "Made DT image: $@"
49
Simon Shields8d96edd2018-04-05 15:02:29 +100050else
51
52$(INSTALLED_DTIMAGE_TARGET) : $(BOARD_KERNEL_PREBUILT_DT) | $(ACP)
53 $(transform-prebuilt-to-target)
54
55endif # BOARD_KERNEL_PREBUILT_DT
56
Michael Bestas3952f6c2016-08-26 01:12:08 +030057ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DTIMAGE_TARGET)
58ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(INSTALLED_DTIMAGE_TARGET)
59
60.PHONY: dtimage
61dtimage: $(INSTALLED_DTIMAGE_TARGET)
62
Simon Shields8d96edd2018-04-05 15:02:29 +100063
Michael Bestas3952f6c2016-08-26 01:12:08 +030064endif
65endif