Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. include $(TOPDIR)/rules.mk
  3. include $(INCLUDE_DIR)/image.mk
  4. define Build/boot-img
  5. $(RM) -rf [email protected]
  6. mkdir -p [email protected]/boot
  7. $(CP) [email protected] [email protected]/boot/boot.scr
  8. $(CP) $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb [email protected]/boot/$(DEVICE_DTB)
  9. $(CP) $(IMAGE_KERNEL) [email protected]/boot/uImage
  10. genext2fs --block-size $(BLOCKSIZE:%k=%Ki) \
  11. --size-in-blocks $$((1024 * $(CONFIG_TARGET_KERNEL_PARTSIZE))) \
  12. --root [email protected] [email protected]
  13. # convert it to revision 1 - needed for u-boot ext2load
  14. $(STAGING_DIR_HOST)/bin/tune2fs -O filetype [email protected]
  15. # Ignore errors because file system was intentionally broken with tune2fs
  16. -$(STAGING_DIR_HOST)/bin/e2fsck -pDf [email protected] > /dev/null
  17. endef
  18. define Build/boot-script
  19. $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
  20. -d mbl_boot.scr \
  21. [email protected]
  22. endef
  23. define Build/export-dtb
  24. cp $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@
  25. endef
  26. define Build/MuImage-initramfs
  27. rm -rf [email protected] [email protected]
  28. dd if=/dev/zero [email protected] bs=32 count=1 conv=sync
  29. # Netgear used an old uboot that doesn't have FIT support.
  30. # So we are stuck with either a full ext2/4 fs in a initrd.
  31. # ... or we try to make the "multi" image approach to work
  32. # for us.
  33. #
  34. # Sadly, the "multi" image has to consists of three
  35. # "fixed" parts in the following "fixed" order:
  36. # 1. The kernel which is in $@
  37. # 2. The (fake) initrd which is in [email protected]
  38. # 3. The device tree binary which is in [email protected]
  39. #
  40. # Now, given that we use the function for the kernel which
  41. # already has a initramfs image inside, we still have to
  42. # add a "fake" initrd (which a mkimage header) in the second
  43. # part of the legacy multi image. Since we need to put the
  44. # device tree stuff into part 3.
  45. -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi -C $(1) \
  46. -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) -n '$(BOARD_NAME) initramfs' \
  47. -d $@:[email protected]:$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb [email protected]
  48. mv [email protected] $@
  49. rm -rf [email protected]
  50. endef
  51. define Build/prepend-dtb
  52. cat "$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb" "$@" > "[email protected]"
  53. mv "[email protected]" "$@"
  54. endef
  55. define Image/cpiogz
  56. ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
  57. endef
  58. define Device/Default
  59. PROFILES := Default
  60. KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
  61. DEVICE_DTS :=
  62. KERNEL_ENTRY := 0x00000000
  63. KERNEL_LOADADDR := 0x00000000
  64. DEVICE_DTS_DIR := ../dts
  65. DEVICE_DTS = $(subst _,-,$(1))
  66. endef
  67. include $(SUBTARGET).mk
  68. $(eval $(call BuildImage))