blob: 1e7adb6f96f6aeb0163416e486fd2cb1f98a061b [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)
6ifneq ($(strip $(BOARD_KERNEL_PREBUILT_DT)),true)
Michael Bestas3952f6c2016-08-26 01:12:08 +03007
8ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
9DTBTOOL_NAME := dtbToolCM
10else
11DTBTOOL_NAME := $(TARGET_CUSTOM_DTBTOOL)
12endif
13
14DTBTOOL := $(HOST_OUT_EXECUTABLES)/$(DTBTOOL_NAME)$(HOST_EXECUTABLE_SUFFIX)
15
16INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img
17
18ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),)
19# dtbToolCM will search subdirectories
20possible_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)
45 lz4 -9 < $@ > $(LZ4_DT_IMAGE) || lz4c -c1 -y $@ $(LZ4_DT_IMAGE)
46 $(hide) $(ACP) $(LZ4_DT_IMAGE) $@
47endif
Michael Bestas3952f6c2016-08-26 01:12:08 +030048 @echo "Made DT image: $@"
49
50ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DTIMAGE_TARGET)
51ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(INSTALLED_DTIMAGE_TARGET)
52
53.PHONY: dtimage
54dtimage: $(INSTALLED_DTIMAGE_TARGET)
55
56endif
57endif
58endif