Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. ifneq ($(1),)
  14. $(CP) $(DTS_DIR)/$(1).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb
  15. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000)
  16. $(CP) $(KDIR)/fit-$(1).itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage.itb
  17. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  18. $(call Image/BuildKernel/MkFIT,$(1),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).dtb,none,0x10008000,0x10008000,-initramfs)
  19. $(CP) $(KDIR)/fit-$(1)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(1)-fit-uImage-initramfs.itb
  20. endif
  21. endif
  22. $(CP) $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
  23. $(call Image/BuildKernel/MkuImage, \
  24. none, 0x10008000, 0x10008000, \
  25. $(BIN_DIR)/$(IMG_PREFIX)-zImage, \
  26. $(BIN_DIR)/$(IMG_PREFIX)-uImage \
  27. )
  28. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  29. $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
  30. $(call Image/BuildKernel/MkuImage, \
  31. none, 0x10008000, 0x10008000, \
  32. $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
  33. $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
  34. )
  35. endif
  36. endef
  37. define Image/InstallKernel/Template
  38. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL)$(CONFIG_TARGET_imx6_VENTANA),)
  39. $(INSTALL_DIR) $(TARGET_DIR)/boot
  40. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_UIMAGE)$(CONFIG_TARGET_imx6_VENTANA),)
  41. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/
  42. ln -sf $(IMG_PREFIX)-uImage $(TARGET_DIR)/boot/uImage
  43. endif
  44. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_ZIMAGE),)
  45. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/
  46. ln -sf $(IMG_PREFIX)-zImage $(TARGET_DIR)/boot/zImage
  47. endif
  48. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_FIT),)
  49. $(foreach dts,$(shell echo $(1)), \
  50. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts)-fit-uImage.itb $(TARGET_DIR)/boot/
  51. )
  52. endif
  53. endif
  54. ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB)$(CONFIG_TARGET_imx6_VENTANA),)
  55. $(INSTALL_DIR) $(TARGET_DIR)/boot
  56. $(foreach dts,$(shell echo $(1)), \
  57. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/ ; \
  58. ln -sf $(IMG_PREFIX)-$(dts).dtb $(TARGET_DIR)/boot/$(dts).dtb ; \
  59. )
  60. endif
  61. endef
  62. define Image/Build/squashfs
  63. $(call prepare_generic_squashfs,$(KDIR)/root.$(1))
  64. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin bs=128k conv=sync
  65. [ -f "$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-uImage.itb" ] && ( \
  66. dd if=$(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-uImage.itb bs=2048k conv=sync; \
  67. dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
  68. ) > $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-fit-$(1).bin || true
  69. endef
  70. define Image/mkfs/targz
  71. $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
  72. endef
  73. define ubifs_imx_gateworks_ventana
  74. # Micron MT29F1G08ABAD/MT29F2G08ABAE/MT29F4G08ABAD/MT29F8G08ADAD NAND
  75. $(eval VENTANA_UBIFS_OPTS:="-m 2048 -e 124KiB -c 8124")
  76. $(eval VENTANA_UBI_OPTS:="-m 2048 -p 128KiB -s 2048")
  77. $(call Image/mkfs/ubifs)
  78. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubifs
  79. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_normal.ubi
  80. # Micron MT29F8G08ABAC/MT29F16G08ADAC 1GB/2GB NAND
  81. $(eval VENTANA_UBIFS_OPTS:="-m 4096 -e 248KiB -c 8124")
  82. $(eval VENTANA_UBI_OPTS:="-m 4096 -p 256KiB -s 4096")
  83. $(call Image/mkfs/ubifs)
  84. $(CP) $(KDIR)/root.ubifs $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubifs
  85. $(CP) $(KDIR)/root.ubi $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-rootfs_large.ubi
  86. endef
  87. define Image/Build/ubifs
  88. true
  89. endef
  90. define Image/Build/ubi
  91. true
  92. endef
  93. Image/BuildKernel/Template/Generic=$(call Image/BuildKernel/Template)
  94. Image/InstallKernel/Template/Generic=$(call Image/InstallKernel/Template)
  95. Image/BuildKernel/Template/IMX6DL_WANDBOARD=$(call Image/BuildKernel/Template,imx6dl-wandboard)
  96. Image/InstallKernel/Template/IMX6DL_WANDBOARD=$(call Image/InstallKernel/Template,imx6dl-wandboard)
  97. Image/BuildKernel/Template/VENTANA=$(foreach dts,$(shell echo $(VENTANA_DTS)),$(call Image/BuildKernel/Template,$(dts)))
  98. Image/InstallKernel/Template/VENTANA=$(call Image/InstallKernel/Template,$(VENTANA_DTS))
  99. Image/ubifs/VENTANA=$(call ubifs_imx_gateworks_ventana)
  100. define Image/BuildKernel
  101. $(call Image/BuildKernel/Template/$(PROFILE))
  102. endef
  103. define Image/InstallKernel
  104. $(call Image/InstallKernel/Template/$(PROFILE))
  105. $(if $(Image/ubifs/$(PROFILE)), \
  106. $(call Image/ubifs/$(PROFILE))
  107. )
  108. endef
  109. define Image/Build
  110. $(if $(Image/Build/$(1)), \
  111. $(call Image/Build/$(1),$(1)), \
  112. $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(call sanitize_profile_name)-$(1).img \
  113. )
  114. endef
  115. $(eval $(call BuildImage))