Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #
  2. # Copyright (C) 2013 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. define sanitize_profile_name
  10. $(shell echo $(PROFILE) | tr '[:upper:]' '[:lower:]' | sed 's/_/-/g')
  11. endef
  12. define Image/BuildKernel/Template
  13. $(CP) $(LINUX_DIR)/arch/arm/boot/dts/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
  14. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000)
  15. $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
  16. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  17. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000,-initramfs)
  18. $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
  19. endif
  20. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  21. $(call Image/BuildKernel/MkuImage, \
  22. none, 0x10008000, 0x10008000, \
  23. $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
  24. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  25. )
  26. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  27. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  28. $(call Image/BuildKernel/MkuImage, \
  29. none, 0x10008000, 0x10008000, \
  30. $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
  31. $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
  32. )
  33. endif
  34. endef
  35. define Image/InstallKernel/Template
  36. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
  37. $(INSTALL_DIR) $(TARGET_DIR)/boot
  38. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE),)
  39. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
  40. ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
  41. endif
  42. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
  43. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
  44. ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
  45. endif
  46. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
  47. $(foreach dts,$(shell echo $(1)), \
  48. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts)-fit-uImage.itb $(TARGET_DIR)/boot/
  49. )
  50. endif
  51. endif
  52. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
  53. $(INSTALL_DIR) $(TARGET_DIR)/boot
  54. $(foreach dts,$(shell echo $(1)), \
  55. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/ ; \
  56. ln -sf $(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/$(dts).dtb ; \
  57. )
  58. endif
  59. endef
  60. define Image/Build/squashfs
  61. $(call prepare_generic_squashfs,$(KDIR)/root.$(1))
  62. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin bs=128k conv=sync
  63. ( \
  64. dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-uImage.itb bs=2048k conv=sync; \
  65. dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
  66. ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-$(1).bin
  67. endef
  68. define Image/mkfs/targz
  69. $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
  70. endef
  71. define ubifs_imx_gateworks_ventana
  72. # Micron MT29F1G08ABAD/MT29F2G08ABAE/MT29F4G08ABAD/MT29F8G08ADAD NAND
  73. $(eval VENTANA_UBIFS_OPTS:="-m 2048 -e 124KiB -c 8124")
  74. $(eval VENTANA_UBI_OPTS:="-m 2048 -p 128KiB -s 2048")
  75. $(call Image/mkfs/ubifs)
  76. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubifs
  77. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubi
  78. # Micron MT29F8G08ABAC/MT29F16G08ADAC 1GB/2GB NAND
  79. $(eval VENTANA_UBIFS_OPTS:="-m 4096 -e 248KiB -c 8124")
  80. $(eval VENTANA_UBI_OPTS:="-m 4096 -p 256KiB -s 4096")
  81. $(call Image/mkfs/ubifs)
  82. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubifs
  83. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubi
  84. endef
  85. define Image/Build/ubifs
  86. true
  87. endef
  88. define Image/Build/ubi
  89. true
  90. endef
  91. Image/BuildKernel/Template/generic=$(call Image/BuildKernel/Template)
  92. Image/InstallKernel/Template/generic=$(call Image/InstallKernel/Template)
  93. Image/BuildKernel/Template/IMX6DL_WANDBOARD=$(call Image/BuildKernel/Template,imx6dl-wandboard)
  94. Image/InstallKernel/Template/IMX6DL_WANDBOARD=$(call Image/InstallKernel/Template,imx6dl-wandboard)
  95. Image/BuildKernel/Template/VENTANA=$(foreach dts,$(shell echo $(VENTANA_DTS)),$(call Image/BuildKernel/Template,$(dts)))
  96. Image/InstallKernel/Template/VENTANA=$(call Image/InstallKernel/Template,$(VENTANA_DTS))
  97. Image/ubifs/VENTANA=$(call ubifs_imx_gateworks_ventana)
  98. define Image/BuildKernel
  99. $(call Image/BuildKernel/Template/$(PROFILE))
  100. endef
  101. define Image/InstallKernel
  102. $(call Image/InstallKernel/Template/$(PROFILE))
  103. $(if $(Image/ubifs/$(PROFILE)), \
  104. $(call Image/ubifs/$(PROFILE))
  105. )
  106. endef
  107. define Image/Build
  108. $(if $(Image/Build/$(1)), \
  109. $(call Image/Build/$(1),$(1)), \
  110. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  111. )
  112. endef
  113. $(eval $(call BuildImage))