Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. #
  2. # Copyright (C) 2012-2015 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. JFFS2_BLOCKSIZE = 128k
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/image.mk
  10. LOADADDR:=0x00008000
  11. define Image/Build/DTB
  12. cp $(KDIR)/zImage$(2) $(KDIR)/zImage$(2)-$(1);
  13. cat $(DTS_DIR)/$(1).dtb >> $(KDIR)/zImage$(2)-$(1);
  14. $(call Image/BuildKernel/MkuImage, \
  15. none, $(LOADADDR), $(LOADADDR), \
  16. $(KDIR)/zImage$(2)-$(1), $(KDIR)/uImage$(2)-$(1))
  17. endef
  18. # $(1): Profile Name
  19. # $(2): DTB Name
  20. # $(3): Erase Block Size
  21. # $(4): Page Size
  22. # $(5): Sub-Page Size (optional)
  23. # $(6): VID offset (optional)
  24. define NANDProfile
  25. define Image/BuildKernel/Profile/$(1)
  26. $(call Image/Build/DTB,$(2))
  27. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  28. $(call Image/Build/Profile,$(1)/Initramfs)
  29. endif
  30. endef
  31. define Image/Build/Profile/$(1)/BuildSysupgrade
  32. $(call Image/Build/SysupgradeNAND,$(2),$$(1),$(KDIR)/uImage-$(2))
  33. endef
  34. define Image/Build/Profile/$(1)/Initramfs
  35. $(call Image/Build/DTB,$(2),-initramfs)
  36. cp $(KDIR)/uImage-initramfs-$(2) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-initramfs
  37. endef
  38. define Image/Build/Profile/$(1)/squashfs
  39. $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m $(4) $(if $(5),-s $(5)) $(if $(6),-O $(6)))
  40. endef
  41. PROFILES_LIST += $(1)
  42. endef
  43. # $(1): Profile Name
  44. # $(2): DTB Name
  45. # $(3): Erase Block Size
  46. define UBINORProfile
  47. define Image/BuildKernel/Profile/$(1)
  48. $(call Image/Build/DTB,$(2))
  49. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  50. $(call Image/Build/Profile,$(1)/Initramfs)
  51. endif
  52. endef
  53. define Image/Build/Profile/$(1)/Initramfs
  54. $(call Image/Build/DTB,$(2),-initramfs)
  55. endef
  56. define Image/Build/Profile/$(1)/squashfs
  57. $(call Image/Build/UbinizeImage,$(2),,squashfs, -p $(3) -m 1)
  58. endef
  59. PROFILES_LIST += $(1)
  60. endef
  61. # $(1): Profile Name
  62. # $(2): DTB Name
  63. # $(3): Erase Block Size
  64. define NORProfile
  65. define Image/BuildKernel/Profile/$(1)
  66. $(call Image/Build/DTB,$(2))
  67. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  68. $(call Image/Build/Profile,$(1)/Initramfs)
  69. endif
  70. endef
  71. define Image/Build/Profile/$(1)/Initramfs
  72. $(call Image/Build/DTB,$(2),-initramfs)
  73. endef
  74. define Image/Build/Profile/$(1)/squashfs
  75. ( \
  76. dd if=$(KDIR)/uImage-$(2) bs=$(patsubst %KiB,%k,$(3)) conv=sync; \
  77. dd if=$(KDIR)/root.squashfs bs=$(patsubst %KiB,%k,$(3)) conv=sync; \
  78. ) > $$(BIN_DIR)/$$(IMG_PREFIX)-$(2)-squashfs-firmware.bin
  79. endef
  80. PROFILES_LIST += $(1)
  81. endef
  82. # $(1): Profile Name
  83. # $(2): DTB Name
  84. define MMCProfile
  85. define Image/BuildKernel/Profile/$(1)
  86. $(call Image/Build/DTB,$(2))
  87. cp $(KDIR)/zImage-$(2) $(BIN_DIR)/zImage-$(1);
  88. cp $(DTS_DIR)/$(2).dtb $(BIN_DIR)/$(1).dtb;
  89. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  90. $(call Image/Build/Profile,$(1)/Initramfs)
  91. endif
  92. endef
  93. define Image/Build/Profile/$(1)/Initramfs
  94. $(call Image/Build/DTB,$(2),-initramfs)
  95. cp $(KDIR)/uImage-initramfs-$(2) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-initramfs
  96. endef
  97. PROFILES_LIST += $(1)
  98. endef
  99. # $(1): Profile Name
  100. # $(2): Sub Profiles list
  101. define MultiProfile
  102. define Image/BuildKernel/Profile/$(1)
  103. $(foreach profile, $(2),
  104. $(call Image/BuildKernel/Profile/$(profile)))
  105. endef
  106. define Image/Build/Profile/$(1)/BuildSysupgrade
  107. $(foreach profile, $(2),
  108. $(call Image/Build/Profile/$(profile)/BuildSysupgrade,$$(1)))
  109. endef
  110. define Image/Build/Profile/$(1)/Initramfs
  111. $(foreach profile, $(2),
  112. $(call Image/Build/Profile/$(profile)/Initramfs))
  113. endef
  114. define Image/Build/Profile/$(1)/squashfs
  115. $(foreach profile, $(2),
  116. $(call Image/Build/Profile/$(profile)/squashfs))
  117. endef
  118. endef
  119. # Boards with NAND, without subpages
  120. $(eval $(call NANDProfile,370-DB,armada-370-db,512KiB,4096))
  121. $(eval $(call NANDProfile,370-RD,armada-370-rd,512KiB,4096))
  122. $(eval $(call NANDProfile,385-DB-AP,armada-385-db-ap,256KiB,4096))
  123. $(eval $(call NANDProfile,Mirabox,armada-370-mirabox,512KiB,4096))
  124. $(eval $(call NANDProfile,XP-DB,armada-xp-db,512KiB,4096))
  125. $(eval $(call NANDProfile,XP-GP,armada-xp-gp,512KiB,4096))
  126. # Boards with NAND, with subpages
  127. $(eval $(call NANDProfile,Mamba,armada-xp-linksys-mamba,128KiB,2048,512,2048))
  128. $(eval $(call NANDProfile,Caiman,armada-385-linksys-caiman,128KiB,2048,512,2048))
  129. $(eval $(call NANDProfile,Cobra,armada-385-linksys-cobra,128KiB,2048,512,2048))
  130. $(eval $(call NANDProfile,Rango,armada-385-linksys-rango,128KiB,2048,512,2048))
  131. $(eval $(call NANDProfile,Shelby,armada-385-linksys-shelby,128KiB,2048,512,2048))
  132. # Boards with large NOR, where we want to use UBI
  133. $(eval $(call UBINORProfile,OpenBlocks-AX-3-4,armada-xp-openblocks-ax3-4,128KiB))
  134. # Boards with small NOR, where UBI doesn't make sense
  135. $(eval $(call NORProfile,388-RD,armada-388-rd,256KiB))
  136. $(eval $(call MMCProfile,Solidrun-Clearfog-A1,armada-388-clearfog))
  137. ###
  138. ### Linksys
  139. ###
  140. # Caiman: Linksys WRT1200AC
  141. define Image/Build/Profile/Caiman/squashfs
  142. $(call Image/Build/UbinizeImage,armada-385-linksys-caiman,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
  143. ( \
  144. dd if=$(KDIR)/uImage-armada-385-linksys-caiman bs=6144k conv=sync; \
  145. dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-ubinized.bin \
  146. bs=2048 conv=sync; \
  147. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-caiman-squashfs-factory.img
  148. endef
  149. # Cobra: Linksys WRT1900ACv2
  150. define Image/Build/Profile/Cobra/squashfs
  151. $(call Image/Build/UbinizeImage,armada-385-linksys-cobra,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
  152. ( \
  153. dd if=$(KDIR)/uImage-armada-385-linksys-cobra bs=6144k conv=sync; \
  154. dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-ubinized.bin \
  155. bs=2048 conv=sync; \
  156. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-cobra-squashfs-factory.img
  157. endef
  158. # Mamba: Linksys WRT1900AC
  159. define Image/Build/Profile/Mamba/squashfs
  160. $(call Image/Build/UbinizeImage,armada-xp-linksys-mamba,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
  161. ( \
  162. dd if=$(KDIR)/uImage-armada-xp-linksys-mamba bs=3072k conv=sync; \
  163. dd if=$(KDIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-ubinized.bin \
  164. bs=2048 conv=sync; \
  165. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-xp-linksys-mamba-squashfs-factory.img
  166. endef
  167. # Shelby: Linksys WRT1900ACS
  168. define Image/Build/Profile/Shelby/squashfs
  169. $(call Image/Build/UbinizeImage,armada-385-linksys-shelby,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
  170. ( \
  171. dd if=$(KDIR)/uImage-armada-385-linksys-shelby bs=6144k conv=sync; \
  172. dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-ubinized.bin \
  173. bs=2048 conv=sync; \
  174. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-shelby-squashfs-factory.img
  175. endef
  176. # Rango: Linksys WRT3200ACM
  177. define Image/Build/Profile/Rango/squashfs
  178. $(call Image/Build/UbinizeImage,armada-385-linksys-rango,,squashfs, -p 128KiB -m 2048 -s 512 -O 2048)
  179. ( \
  180. dd if=$(KDIR)/uImage-armada-385-linksys-rango bs=6144k conv=sync; \
  181. dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-linksys-rango-squashfs-ubinized.bin \
  182. bs=2048 conv=sync; \
  183. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-linksys-rango-squashfs-factory.img
  184. endef
  185. ###
  186. ### Marvell
  187. ###
  188. # Marvell Armada 385 Access Point Development board (DB-88F6820-AP)
  189. define Image/Build/Profile/385-DB-AP/squashfs
  190. $(call Image/Build/UbinizeImage,armada-385-db-ap,,squashfs, -p 256KiB -m 4096)
  191. ( \
  192. dd if=$(KDIR)/uImage-armada-385-db-ap bs=8M conv=sync; \
  193. dd if=$(KDIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-ubinized.bin \
  194. bs=4096 conv=sync; \
  195. ) > $(BIN_DIR)/$(IMG_PREFIX)-armada-385-db-ap-squashfs-factory.img
  196. endef
  197. # The Default profile should build everything
  198. $(eval $(call MultiProfile,Default,$(PROFILES_LIST)))
  199. define Image/BuildKernel
  200. $(call Image/BuildKernel/Profile/$(PROFILE))
  201. endef
  202. define Image/Build/squashfs
  203. # Align the squashfs image size before calling the profiles,
  204. # otherwise the size would keep growing
  205. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  206. $(call Image/Build/Profile/$(PROFILE)/squashfs)
  207. endef
  208. define Image/Build
  209. $(call Image/Build/$(1))
  210. $(call Image/Build/Profile/$(PROFILE)/BuildSysupgrade,$(1))
  211. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  212. $(call Image/Build/Profile/$(PROFILE)/Initramfs)
  213. endif
  214. endef
  215. $(eval $(call BuildImage))