Makefile 2.5 KB

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