Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. $(STAGING_DIR_HOST)/bin/e2fsck -pDf [email protected] > /dev/null
  16. endef
  17. define Build/boot-script
  18. $(STAGING_DIR_HOST)/bin/mkimage -A powerpc -T script -C none -n "$(PROFILE) Boot Script" \
  19. -d mbl_boot.scr \
  20. [email protected]
  21. endef
  22. define Build/export-dtb
  23. cp $(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb $@
  24. endef
  25. define Build/MuImage-initramfs
  26. rm -rf [email protected] [email protected]
  27. dd if=/dev/zero [email protected] bs=32 count=1 conv=sync
  28. # Netgear used an old uboot that doesn't have FIT support.
  29. # So we are stuck with either a full ext2/4 fs in a initrd.
  30. # ... or we try to make the "multi" image approach to work
  31. # for us.
  32. #
  33. # Sadly, the "multi" image has to consists of three
  34. # "fixed" parts in the following "fixed" order:
  35. # 1. The kernel which is in $@
  36. # 2. The (fake) initrd which is in [email protected]
  37. # 3. The device tree binary which is in [email protected]
  38. #
  39. # Now, given that we use the function for the kernel which
  40. # already has a initramfs image inside, we still have to
  41. # add a "fake" initrd (which a mkimage header) in the second
  42. # part of the legacy multi image. Since we need to put the
  43. # device tree stuff into part 3.
  44. -$(STAGING_DIR_HOST)/bin/mkimage -A $(LINUX_KARCH) -O linux -T multi -C $(1) \
  45. -a $(KERNEL_LOADADDR) -e $(KERNEL_ENTRY) -n '$(BOARD_NAME) initramfs' \
  46. -d $@:[email protected]:$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb [email protected]
  47. mv [email protected] $@
  48. rm -rf [email protected]
  49. endef
  50. define Build/prepend-dtb
  51. cat "$(KDIR)/image-$(firstword $(DEVICE_DTS)).dtb" "$@" > "[email protected]"
  52. mv "[email protected]" "$@"
  53. endef
  54. define Image/cpiogz
  55. ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9n >$(KDIR_TMP)/$(IMG_PREFIX)-rootfs.cpio.gz )
  56. endef
  57. define Device/Default
  58. PROFILES := Default
  59. KERNEL_DEPENDS = $$(wildcard ../dts/$$(DEVICE_DTS).dts)
  60. DEVICE_DTS :=
  61. KERNEL_ENTRY := 0x00000000
  62. KERNEL_LOADADDR := 0x00000000
  63. DEVICE_DTS_DIR := ../dts
  64. DEVICE_DTS = $(subst _,-,$(1))
  65. endef
  66. include $(SUBTARGET).mk
  67. $(eval $(call BuildImage))