Makefile 7.9 KB

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