Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 1 | #---------------------------------------------------------------------- |
| 2 | # Generate device tree image (dt.img) |
| 3 | #---------------------------------------------------------------------- |
| 4 | ifeq ($(strip $(BOARD_CUSTOM_BOOTIMG_MK)),) |
| 5 | ifeq ($(strip $(BOARD_KERNEL_SEPARATED_DT)),true) |
Simon Shields | 8d96edd | 2018-04-05 15:02:29 +1000 | [diff] [blame] | 6 | INSTALLED_DTIMAGE_TARGET := $(PRODUCT_OUT)/dt.img |
| 7 | |
| 8 | ifeq ($(strip $(BOARD_KERNEL_PREBUILT_DT)),) |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 9 | |
| 10 | ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),) |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 11 | DTBTOOL_NAME := dtbToolLineage |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 12 | else |
| 13 | DTBTOOL_NAME := $(TARGET_CUSTOM_DTBTOOL) |
| 14 | endif |
| 15 | |
| 16 | DTBTOOL := $(HOST_OUT_EXECUTABLES)/$(DTBTOOL_NAME)$(HOST_EXECUTABLE_SUFFIX) |
| 17 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 18 | ifeq ($(strip $(TARGET_CUSTOM_DTBTOOL)),) |
Luca Stefani | 5c60e4f | 2017-08-17 19:28:48 +0200 | [diff] [blame] | 19 | # dtbToolLineage will search subdirectories |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 20 | possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/ |
| 21 | else |
| 22 | # Most specific paths must come first in possible_dtb_dirs |
| 23 | possible_dtb_dirs = $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/dts/ $(KERNEL_OUT)/arch/$(KERNEL_ARCH)/boot/ |
| 24 | endif |
| 25 | |
| 26 | define 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 $@ |
| 36 | endef |
| 37 | |
Dan Pasanen | efe4823 | 2017-01-24 14:09:10 -0600 | [diff] [blame] | 38 | ifeq ($(strip $(BOARD_KERNEL_LZ4C_DT)),true) |
| 39 | LZ4_DT_IMAGE := $(PRODUCT_OUT)/dt-lz4.img |
| 40 | endif |
| 41 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 42 | $(INSTALLED_DTIMAGE_TARGET): $(DTBTOOL) $(INSTALLED_KERNEL_TARGET) |
| 43 | $(build-dtimage-target) |
Dan Pasanen | efe4823 | 2017-01-24 14:09:10 -0600 | [diff] [blame] | 44 | ifeq ($(strip $(BOARD_KERNEL_LZ4C_DT)),true) |
| 45 | lz4 -9 < $@ > $(LZ4_DT_IMAGE) || lz4c -c1 -y $@ $(LZ4_DT_IMAGE) |
| 46 | $(hide) $(ACP) $(LZ4_DT_IMAGE) $@ |
| 47 | endif |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 48 | @echo "Made DT image: $@" |
| 49 | |
Simon Shields | 8d96edd | 2018-04-05 15:02:29 +1000 | [diff] [blame] | 50 | else |
| 51 | |
| 52 | $(INSTALLED_DTIMAGE_TARGET) : $(BOARD_KERNEL_PREBUILT_DT) | $(ACP) |
| 53 | $(transform-prebuilt-to-target) |
| 54 | |
| 55 | endif # BOARD_KERNEL_PREBUILT_DT |
| 56 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 57 | ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DTIMAGE_TARGET) |
| 58 | ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(INSTALLED_DTIMAGE_TARGET) |
| 59 | |
| 60 | .PHONY: dtimage |
| 61 | dtimage: $(INSTALLED_DTIMAGE_TARGET) |
| 62 | |
Simon Shields | 8d96edd | 2018-04-05 15:02:29 +1000 | [diff] [blame] | 63 | |
Michael Bestas | 3952f6c | 2016-08-26 01:12:08 +0300 | [diff] [blame] | 64 | endif |
| 65 | endif |