From c6502ce3bb87b6a6a85209d3e67736bd2db21bc7 Mon Sep 17 00:00:00 2001
From: Jo-Philipp Wich <jo@mein.io>
Date: Fri, 27 Jan 2017 16:06:31 +0100
Subject: [PATCH] layerscape: put u-boot and ucode images into image staging
 directory

Do not put the u-boot and ucode images into the kernel build directory as this
directory might get removed after kernel updates while the u-boot packages
InstallDev recipe is not getting re-executed because it is still considered
current, leading to image build failures later on due to missing images.

To ensure that built bootloader images persist over kernel version updates in
the buildroot, put them into the new STAGING_DIR_IMAGE directory.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
---
 package/boot/uboot-layerscape-32b/Makefile | 7 ++++---
 package/boot/uboot-layerscape/Makefile     | 3 ++-
 package/firmware/fman-ucode/Makefile       | 3 ++-
 package/firmware/rcw/Makefile              | 3 ++-
 target/linux/layerscape/image/Makefile     | 6 +++---
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/package/boot/uboot-layerscape-32b/Makefile b/package/boot/uboot-layerscape-32b/Makefile
index 852c83a929..cf56eedd30 100644
--- a/package/boot/uboot-layerscape-32b/Makefile
+++ b/package/boot/uboot-layerscape-32b/Makefile
@@ -42,9 +42,10 @@ define Build/Compile
 endef
 
 define Build/InstallDev
-	$(CP) $(PKG_BUILD_DIR)/ls1043ardb-uboot.bin $(KERNEL_BUILD_DIR)/ls1043ardb-32b-uboot.bin
-	$(CP) $(PKG_BUILD_DIR)/ls1046ardb-uboot.bin $(KERNEL_BUILD_DIR)/ls1046ardb-32b-uboot.bin
-	$(CP) $(PKG_BUILD_DIR)/ls1012ardb-uboot.bin.swap $(KERNEL_BUILD_DIR)/ls1012ardb-32b-uboot.bin
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+	$(CP) $(PKG_BUILD_DIR)/ls1043ardb-uboot.bin $(STAGING_DIR_IMAGE)/ls1043ardb-32b-uboot.bin
+	$(CP) $(PKG_BUILD_DIR)/ls1046ardb-uboot.bin $(STAGING_DIR_IMAGE)/ls1046ardb-32b-uboot.bin
+	$(CP) $(PKG_BUILD_DIR)/ls1012ardb-uboot.bin.swap $(STAGING_DIR_IMAGE)/ls1012ardb-32b-uboot.bin
 endef
 
 $(eval $(call BuildPackage,uboot-layerscape-32b))
diff --git a/package/boot/uboot-layerscape/Makefile b/package/boot/uboot-layerscape/Makefile
index f0ab726534..ac3d7aba86 100644
--- a/package/boot/uboot-layerscape/Makefile
+++ b/package/boot/uboot-layerscape/Makefile
@@ -49,7 +49,8 @@ UBOOT_TARGETS := \
 	ls1012ardb
 
 define Build/InstallDev
-	$(INSTALL_DATA) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(KERNEL_BUILD_DIR)/$(BUILD_VARIANT)-64b-uboot.bin
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/$(BUILD_VARIANT)-64b-uboot.bin
 endef
 
 define Package/u-boot/install/default
diff --git a/package/firmware/fman-ucode/Makefile b/package/firmware/fman-ucode/Makefile
index 5a0238dee2..396750f804 100644
--- a/package/firmware/fman-ucode/Makefile
+++ b/package/firmware/fman-ucode/Makefile
@@ -72,7 +72,8 @@ define Build/Compile
 endef
 
 define Package/fman/install/default
-	$(CP) $(PKG_BUILD_DIR)/$(FMAN_CONFIG) $(KDIR)/$(1)-fman.bin
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+	$(CP) $(PKG_BUILD_DIR)/$(FMAN_CONFIG) $(STAGING_DIR_IMAGE)/$(1)-fman.bin
 endef
 
 define Package/fman/install/template
diff --git a/package/firmware/rcw/Makefile b/package/firmware/rcw/Makefile
index d832e6e5d7..bae9c95b6c 100644
--- a/package/firmware/rcw/Makefile
+++ b/package/firmware/rcw/Makefile
@@ -81,7 +81,8 @@ define Build/Compile
 endef
 
 define Package/rcw/install/default
-	$(CP) $(PKG_BUILD_DIR)/$(RCW_CONFIG) $(KDIR)/$(1)-rcw.bin
+	$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
+	$(CP) $(PKG_BUILD_DIR)/$(RCW_CONFIG) $(STAGING_DIR_IMAGE)/$(1)-rcw.bin
 endef
 
 define Package/rcw/install/template
diff --git a/target/linux/layerscape/image/Makefile b/target/linux/layerscape/image/Makefile
index 341d5fbda0..107a3e6eed 100644
--- a/target/linux/layerscape/image/Makefile
+++ b/target/linux/layerscape/image/Makefile
@@ -9,15 +9,15 @@ include $(INCLUDE_DIR)/image.mk
 
 define Build/append-ls-rcw
 	rm -f $@
-	dd if=$(KDIR)/$(1)-rcw.bin >> $@
+	dd if=$(STAGING_DIR_IMAGE)/$(1)-rcw.bin >> $@
 endef
 
 define Build/append-ls-uboot
-	dd if=$(KDIR)/$(1)-$(SUBTARGET)-uboot.bin >> $@
+	dd if=$(STAGING_DIR_IMAGE)/$(1)-$(SUBTARGET)-uboot.bin >> $@
 endef
 
 define Build/append-ls-fman
-	dd if=$(KDIR)/$(1)-fman.bin >> $@
+	dd if=$(STAGING_DIR_IMAGE)/$(1)-fman.bin >> $@
 endef
 
 define Build/append-ls-dtb
-- 
GitLab