[][OpenWrt Dev][Build kernel FIT image after generating squashfs rootfs]

[Description]
Add build prereq for kernel FIT image to be built after generating
squashfs rootfs

[Release-log]
N/A

Change-Id: Ia00648ca3d2d7c121505149ba0c056c087aa5efc
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5602767
diff --git a/openwrt_patches-21.02/121-build-kernel-fit-image-after-generating-squashfs-rootfs.patch b/openwrt_patches-21.02/121-build-kernel-fit-image-after-generating-squashfs-rootfs.patch
new file mode 100644
index 0000000..9d95dd0
--- /dev/null
+++ b/openwrt_patches-21.02/121-build-kernel-fit-image-after-generating-squashfs-rootfs.patch
@@ -0,0 +1,28 @@
+--- a/include/image.mk
++++ b/include/image.mk
+@@ -555,6 +557,16 @@ define Device/Build/kernel
+     ifdef CONFIG_IB
+       install: $$(KDIR_KERNEL_IMAGE)
+     endif
++    ifneq ($$(filter squashfs,$(2)),)
++      # Force squashfs to be built before generating kernel image
++      ROOTFS/squashfs/$(1) := \
++	$(KDIR)/root.squashfs$$(strip \
++		$$(if $$(FS_OPTIONS/squashfs),+fs=$$(call param_mangle,$$(FS_OPTIONS/squashfs))) \
++	)$$(strip \
++		$(if $(TARGET_PER_DEVICE_ROOTFS),+pkg=$$(ROOTFS_ID/$(1))) \
++	)
++      $$(KDIR_KERNEL_IMAGE): $$(ROOTFS/squashfs/$(1))
++    endif
+     $$(KDIR_KERNEL_IMAGE): $(KDIR)/$$(KERNEL_NAME) $(CURDIR)/Makefile $$(KERNEL_DEPENDS) image_prepare
+ 	@rm -f $$@
+ 	$$(call concat_cmd,$$(KERNEL))
+@@ -639,7 +651,7 @@ endef
+ 
+ define Device/Build
+   $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1)))
+-  $(call Device/Build/kernel,$(1))
++  $(call Device/Build/kernel,$(1),$$(filter $(TARGET_FILESYSTEMS),$$(FILESYSTEMS)))
+ 
+   $$(eval $$(foreach compile,$$(COMPILE), \
+     $$(call Device/Build/compile,$$(compile),$(1))))