Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. # Copyright (c) 2014 The Linux Foundation. All rights reserved.
  2. #
  3. include $(TOPDIR)/rules.mk
  4. include $(INCLUDE_DIR)/image.mk
  5. UBIFS_OPTS = -m 2048 -e 124KiB -c 4096 -U -F
  6. KERNEL_LOADADDR := 0x42208000
  7. define Image/Prepare
  8. $(CP) $(LINUX_DIR)/vmlinux $(KDIR)/$(IMG_PREFIX)-vmlinux.elf
  9. mkimage -A arm -O linux -T filesystem -C none \
  10. -a $(KERNEL_LOADADDR) -e $(KERNEL_LOADADDR) \
  11. -n 'ARM OpenWrt fakeroot' \
  12. -s $(KDIR_TMP)/root.dummy-uImage.tmp
  13. echo -ne '\xff' > $(KDIR_TMP)/root.dummy
  14. cat $(KDIR_TMP)/root.dummy $(KDIR_TMP)/root.dummy-uImage.tmp > $(KDIR)/root.dummy
  15. endef
  16. define Image/BuildKernel
  17. $(CP) $(KDIR)/$(IMG_PREFIX)-vmlinux.elf $(BIN_DIR)
  18. endef
  19. define Image/Build/squashfs
  20. cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-raw
  21. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  22. endef
  23. define Image/Build
  24. $(call Image/Build/$(1),$(1))
  25. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1)-root.img bs=2k conv=sync
  26. endef
  27. define Build/append-file
  28. cat $(1) >> $@
  29. endef
  30. define Device/Default
  31. PROFILES := Default
  32. KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
  33. KERNEL_INITRAMFS_PREFIX := $$(IMG_PREFIX)-$(1)-initramfs
  34. KERNEL_PREFIX := $$(IMAGE_PREFIX)
  35. SUPPORTED_DEVICES = $$(BOARD_NAME)
  36. IMAGE/sysupgrade.tar = sysupgrade-tar | append-metadata
  37. endef
  38. define Device/LegacyImage
  39. KERNEL_SUFFIX := -uImage
  40. KERNEL = kernel-bin | append-dtb | uImage none
  41. KERNEL_NAME := zImage
  42. endef
  43. define Device/FitImage
  44. KERNEL_SUFFIX := -fit-uImage.itb
  45. KERNEL = kernel-bin | gzip | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb
  46. KERNEL_NAME := Image
  47. endef
  48. define Device/UbiFit
  49. KERNEL_IN_UBI := 1
  50. IMAGES := nand-factory.ubi nand-sysupgrade.tar
  51. IMAGE/nand-factory.ubi := append-ubi
  52. IMAGE/nand-sysupgrade.tar := sysupgrade-tar | append-metadata
  53. endef
  54. define Device/DniImage
  55. PROFILES += $$(DEVICE_NAME)
  56. FILESYSTEMS := squashfs
  57. KERNEL_SUFFIX := -uImage
  58. KERNEL_INITRAMFS := kernel-bin | append-dtb | uImage none
  59. KERNEL = kernel-bin | append-dtb | pad-to $$$$(($$(KERNEL_SIZE)-2*64-1)) | uImage none | append-file $(KDIR)/root.dummy
  60. KERNEL_NAME := zImage
  61. NETGEAR_BOARD_ID :=
  62. NETGEAR_HW_ID :=
  63. UBINIZE_OPTS := -E 5
  64. IMAGES := factory.img sysupgrade.tar
  65. IMAGE/factory.img := append-kernel | append-ubi | netgear-dni
  66. endef
  67. DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_HW_ID
  68. define Device/TpSafeImage
  69. PROFILES += $$(DEVICE_NAME)
  70. FILESYSTEMS := squashfs
  71. KERNEL_SUFFIX := -uImage
  72. KERNEL = kernel-bin | append-dtb | uImage none
  73. KERNEL_NAME := zImage
  74. TPLINK_BOARD_NAME :=
  75. IMAGES := factory.bin sysupgrade.bin
  76. IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
  77. IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | append-metadata
  78. endef
  79. DEVICE_VARS += TPLINK_BOARD_NAME
  80. define Device/ZyXELImage
  81. PROFILES += $$(DEVICE_NAME)
  82. FILESYSTEMS := squashfs
  83. KERNEL_SUFFIX := -uImage
  84. KERNEL = kernel-bin | append-dtb | uImage none | pad-to $${KERNEL_SIZE}
  85. KERNEL_NAME := zImage
  86. IMAGES := sysupgrade.tar mmcblk0p5-rootfs.bin mmcblk0p4-kernel.bin
  87. IMAGE/sysupgrade.tar/squashfs := append-rootfs | pad-to $$$${BLOCKSIZE} | sysupgrade-tar rootfs=$$$$@ | append-metadata
  88. IMAGE/mmcblk0p5-rootfs.bin := append-rootfs | pad-rootfs | pad-to $$$${BLOCKSIZE}
  89. IMAGE/mmcblk0p4-kernel.bin := append-kernel
  90. endef
  91. define Device/AP148
  92. $(call Device/FitImage)
  93. $(call Device/UbiFit)
  94. DEVICE_DTS := qcom-ipq8064-ap148
  95. BLOCKSIZE := 128k
  96. PAGESIZE := 2048
  97. BOARD_NAME := ap148
  98. DEVICE_TITLE := Qualcomm AP148
  99. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  100. endef
  101. define Device/AP148-legacy
  102. $(call Device/LegacyImage)
  103. $(call Device/UbiFit)
  104. DEVICE_DTS := qcom-ipq8064-ap148
  105. BLOCKSIZE := 128k
  106. PAGESIZE := 2048
  107. BOARD_NAME := ap148
  108. DEVICE_TITLE := Qualcomm AP148 (legacy)
  109. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  110. endef
  111. define Device/C2600
  112. $(call Device/TpSafeImage)
  113. DEVICE_DTS := qcom-ipq8064-c2600
  114. BLOCKSIZE := 128k
  115. PAGESIZE := 2048
  116. BOARD_NAME := c2600
  117. TPLINK_BOARD_NAME := C2600
  118. DEVICE_TITLE := TP-Link Archer C2600
  119. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  120. endef
  121. define Device/D7800
  122. $(call Device/DniImage)
  123. DEVICE_DTS := qcom-ipq8064-d7800
  124. KERNEL_SIZE := 2097152
  125. NETGEAR_BOARD_ID := D7800
  126. NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4
  127. BLOCKSIZE := 128k
  128. PAGESIZE := 2048
  129. BOARD_NAME := d7800
  130. DEVICE_TITLE := Netgear Nighthawk X4 D7800
  131. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  132. endef
  133. define Device/DB149
  134. $(call Device/FitImage)
  135. DEVICE_DTS := qcom-ipq8064-db149
  136. KERNEL_INSTALL := 1
  137. BOARD_NAME := db149
  138. DEVICE_TITLE := Qualcomm DB149
  139. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  140. endef
  141. define Device/EA8500
  142. $(call Device/LegacyImage)
  143. DEVICE_DTS := qcom-ipq8064-ea8500
  144. PAGESIZE := 2048
  145. BLOCKSIZE := 128k
  146. KERNEL_SIZE := 3072k
  147. FILESYSTEMS := squashfs
  148. KERNEL = kernel-bin | append-dtb | uImage none | append-file $(KDIR)/root.dummy
  149. PROFILES += $$(DEVICE_NAME)
  150. BOARD_NAME := ea8500
  151. UBINIZE_OPTS := -E 5
  152. IMAGES := factory.bin sysupgrade.tar
  153. IMAGE/factory.bin := append-kernel | pad-to $$$${KERNEL_SIZE} | append-ubi
  154. DEVICE_TITLE := Linksys EA8500
  155. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  156. endef
  157. define Device/R7500
  158. $(call Device/DniImage)
  159. DEVICE_DTS := qcom-ipq8064-r7500
  160. KERNEL_SIZE := 2097152
  161. NETGEAR_BOARD_ID := R7500
  162. NETGEAR_HW_ID := 29764841+0+128+256+3x3+4x4
  163. BLOCKSIZE := 128k
  164. PAGESIZE := 2048
  165. BOARD_NAME := r7500
  166. DEVICE_TITLE := Netgear Nighthawk X4 R7500
  167. DEVICE_PACKAGES := ath10k-firmware-qca988x
  168. endef
  169. define Device/R7500v2
  170. $(call Device/DniImage)
  171. DEVICE_DTS := qcom-ipq8064-r7500v2
  172. KERNEL_SIZE := 2097152
  173. NETGEAR_BOARD_ID := R7500v2
  174. NETGEAR_HW_ID := 29764958+0+128+512+3x3+4x4
  175. BLOCKSIZE := 128k
  176. PAGESIZE := 2048
  177. BOARD_NAME := r7500v2
  178. DEVICE_TITLE := Netgear Nighthawk X4 R7500v2
  179. DEVICE_PACKAGES := ath10k-firmware-qca99x0 ath10k-firmware-qca988x
  180. endef
  181. define Device/R7800
  182. $(call Device/DniImage)
  183. DEVICE_DTS := qcom-ipq8065-r7800
  184. KERNEL_SIZE := 2097152
  185. NETGEAR_BOARD_ID := R7800
  186. NETGEAR_HW_ID := 29764958+0+128+512+4x4+4x4+cascade
  187. BLOCKSIZE := 128k
  188. PAGESIZE := 2048
  189. BOARD_NAME := r7800
  190. DEVICE_TITLE := Netgear Nighthawk X4S R7800
  191. DEVICE_PACKAGES := ath10k-firmware-qca9984
  192. endef
  193. define Device/NBG6817
  194. DEVICE_DTS := qcom-ipq8065-nbg6817
  195. KERNEL_SIZE := 4096k
  196. BLOCKSIZE := 64k
  197. BOARD_NAME := nbg6817
  198. DEVICE_TITLE := ZyXEL NBG6817
  199. DEVICE_PACKAGES := ath10k-firmware-qca9984 e2fsprogs kmod-fs-ext4 losetup
  200. $(call Device/ZyXELImage)
  201. endef
  202. define Device/VR2600v
  203. PROFILES += $$(DEVICE_NAME)
  204. FILESYSTEMS := squashfs
  205. KERNEL_SUFFIX := -uImage
  206. KERNEL = kernel-bin | append-dtb | uImage none
  207. KERNEL_NAME := zImage
  208. KERNEL_SIZE := 2097152
  209. DEVICE_DTS := qcom-ipq8064-vr2600v
  210. BLOCKSIZE := 128k
  211. PAGESIZE := 2048
  212. BOARD_NAME := vr2600v
  213. DEVICE_TITLE := TP-Link Archer VR2600v
  214. DEVICE_PACKAGES := ath10k-firmware-qca99x0
  215. IMAGES := sysupgrade.bin
  216. IMAGE/sysupgrade.bin := pad-extra 512 | append-kernel | pad-to $$$${KERNEL_SIZE} | append-rootfs | pad-rootfs | append-metadata
  217. endef
  218. TARGET_DEVICES += AP148 AP148-legacy C2600 D7800 DB149 EA8500 R7500 R7500v2 R7800 NBG6817 VR2600v
  219. $(eval $(call BuildImage))