[source] build: allow calling append-dtb from image build commands

LEDE Commits lede-commits at lists.infradead.org
Thu Nov 2 08:01:29 PDT 2017


nbd pushed a commit to source.git, branch master:
https://git.lede-project.org/986d9deb3b24bc72e9e7ecf93affbc3f188bb926

commit 986d9deb3b24bc72e9e7ecf93affbc3f188bb926
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Thu Nov 2 13:28:26 2017 +0100

    build: allow calling append-dtb from image build commands
    
    mpc85xx uses this for firmware image files, since the dtb data is not
    directly part of the kernel image. This causes build failures in the
    image builder.
    
    Fix this by adding a separate build step that runs this call earlier,
    reusing the generated file for any calls from kernel or image build
    commands.
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 include/image-commands.mk |  3 +--
 include/image.mk          | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/image-commands.mk b/include/image-commands.mk
index aaece70..1ec5252 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -102,8 +102,7 @@ define Build/tplink-safeloader
 endef
 
 define Build/append-dtb
-	$(call Image/BuildDTB,$(if $(DEVICE_DTS_DIR),$(DEVICE_DTS_DIR),$(DTS_DIR))/$(DEVICE_DTS).dts,$@.dtb)
-	cat $@.dtb >> $@
+	cat $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb >> $@
 endef
 
 define Build/install-dtb
diff --git a/include/image.mk b/include/image.mk
index fc6bf06..9ab139c 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -435,7 +435,23 @@ define Device/Build/compile
 
 endef
 
+ifndef IB
+define Device/Build/dtb
+  $(KDIR)/image-$(1).dtb: FORCE
+	$(call Image/BuildDTB,$(2)/$(1).dts,$$@)
+
+  $(3): $(KDIR)/image-$(1).dtb
+endef
+endif
+
 define Device/Build/kernel
+  $$(eval $$(foreach dts,$$(DEVICE_DTS), \
+	$$(call Device/Build/dtb,$$(dts), \
+		$$(if $$(DEVICE_DTS_DIR),$$(DEVICE_DTS_DIR),$$(DTS_DIR)),\
+		$$(KDIR_KERNEL_IMAGE) $(KDIR)/$$(KERNEL_INITRAMFS_NAME) \
+	) \
+  ))
+
   $(KDIR)/$$(KERNEL_NAME):: image_prepare
   $$(_TARGET): $$(if $$(KERNEL_INSTALL),$(BIN_DIR)/$$(KERNEL_IMAGE))
   $(call Device/Export,$$(KDIR_KERNEL_IMAGE),$(1))



More information about the lede-commits mailing list