Makefile 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 Image/Prepare
  10. rm -f $(KDIR)/fs_mark
  11. echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
  12. $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
  13. # For UBI we want only one extra block
  14. rm -f $(KDIR)/ubi_mark
  15. echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
  16. endef
  17. define Build/lzma-d16
  18. $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) [email protected]
  19. mv [email protected] $@
  20. endef
  21. # Similar to Build/tplink-safeloader but uses TRX instead of clean kernel
  22. define Build/bcm53xx-tplink-safeloader
  23. $(STAGING_DIR_HOST)/bin/trx \
  24. -o [email protected] \
  25. -m 33554432 \
  26. -f $(IMAGE_KERNEL) -a 1024
  27. $(STAGING_DIR_HOST)/bin/tplink-safeloader \
  28. -B $(TPLINK_BOARD) \
  29. -k [email protected] \
  30. -r $@ \
  31. -j \
  32. -o [email protected]
  33. mv [email protected] $@
  34. rm [email protected]
  35. endef
  36. define Build/buffalo-wzr-header
  37. $(eval product=$(word 1,$(1)))
  38. $(eval region=$(word 2,$(1)))
  39. ( \
  40. echo $(product)_$(BUFFALO_TAG_VERSION)_$(BUFFALO_TAG_MINOR)_$(region)_$(BUFFALO_TAG_PLATFORM); \
  41. echo filelen=$$(stat -c%s $@); \
  42. cat $@ \
  43. ) > [email protected]
  44. mv [email protected] $@
  45. endef
  46. # TRX with only one (kernel) partition
  47. define Build/trx
  48. $(STAGING_DIR_HOST)/bin/trx \
  49. -o [email protected] \
  50. -m 33554432 \
  51. -f $@
  52. mv [email protected] $@
  53. endef
  54. define Build/trx-serial
  55. $(STAGING_DIR_HOST)/bin/otrx create [email protected] \
  56. -f $(IMAGE_KERNEL) -a 1024 \
  57. -f $@ -a 0x10000 -A $(KDIR)/fs_mark
  58. mv [email protected] $@
  59. endef
  60. define Build/trx-nand
  61. # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
  62. # if it grows up between releases
  63. # root: UBI with one extra block containing UBI mark to trigger erasing
  64. # rest of partition
  65. $(STAGING_DIR_HOST)/bin/otrx create [email protected] \
  66. -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
  67. -f $@ \
  68. -A $(KDIR)/ubi_mark -a 0x20000
  69. mv [email protected] $@
  70. endef
  71. define Build/asus-trx
  72. $(STAGING_DIR_HOST)/bin/asustrx \
  73. -p $(PRODUCTID) -i $@ -o [email protected]
  74. mv [email protected] $@
  75. endef
  76. define Build/seama-nand
  77. # Seama entity
  78. $(STAGING_DIR_HOST)/bin/oseama \
  79. entity [email protected] \
  80. -m "dev=/dev/mtdblock/7" \
  81. -m "type=firmware" \
  82. -f $(IMAGE_KERNEL) \
  83. -b 0x400000 \
  84. -f $@ \
  85. -f $(KDIR)/ubi_mark
  86. # Seama container
  87. $(STAGING_DIR_HOST)/bin/seama \
  88. -s $@ \
  89. -m "signature=$(SIGNATURE)" \
  90. -i [email protected]
  91. endef
  92. DEVICE_VARS += PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION TPLINK_BOARD
  93. DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
  94. IEEE8021X := wpad-mini
  95. B43 := $(IEEE8021X) kmod-b43
  96. BRCMFMAC_43602A1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-43602a1-pcie
  97. BRCMFMAC_4366B1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-4366b1-pcie
  98. BRCMFMAC_4366C0 := $(IEEE8021X) kmod-brcmfmac
  99. USB2_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-phy-bcm-ns-usb2
  100. USB2_PACKAGES += kmod-usb-ledtrig-usbport
  101. USB3_PACKAGES := $(USB2_PACKAGES) kmod-usb3 kmod-phy-bcm-ns-usb3
  102. define Device/Default
  103. # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
  104. # extract the full dtb name based on the device info
  105. DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
  106. KERNEL := kernel-bin | append-dtb | lzma-d16
  107. KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
  108. KERNEL_INITRAMFS_SUFFIX := .trx
  109. KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16 | trx
  110. FILESYSTEMS := squashfs
  111. KERNEL_NAME := zImage
  112. IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
  113. IMAGES := trx
  114. BLOCKSIZE := 128k
  115. PAGESIZE := 2048
  116. IMAGE/trx := append-ubi | trx-nand
  117. endef
  118. define Device/asus
  119. IMAGES := trx
  120. IMAGE/trx := append-ubi | trx-nand | asus-trx
  121. endef
  122. define Device/asus-rt-ac56u
  123. DEVICE_TITLE := Asus RT-AC56U
  124. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  125. endef
  126. TARGET_DEVICES += asus-rt-ac56u
  127. define Device/asus-rt-ac68u
  128. DEVICE_TITLE := Asus RT-AC68U
  129. DEVICE_PACKAGES := $(USB3_PACKAGES)
  130. endef
  131. TARGET_DEVICES += asus-rt-ac68u
  132. define Device/asus-rt-ac87u
  133. DEVICE_TITLE := Asus RT-AC87U
  134. DEVICE_PACKAGES := $(USB3_PACKAGES)
  135. endef
  136. TARGET_DEVICES += asus-rt-ac87u
  137. define Device/asus-rt-n18u
  138. DEVICE_TITLE := Asus RT-N18U
  139. DEVICE_PACKAGES := $(USB3_PACKAGES)
  140. endef
  141. TARGET_DEVICES += asus-rt-n18u
  142. # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
  143. # kernels.
  144. # We should have two initramfs images for Buffalo: plain initramfs kernel and
  145. # TRX with initramfs kernel. It's not possible right now so let's just build
  146. # plain initramfs kernel as it may be more useful.
  147. define Device/buffalo/Default
  148. KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
  149. KERNEL_INITRAMFS = $$(KERNEL)
  150. endef
  151. define Device/buffalo-wxr-1900dhp
  152. $(call Device/buffalo/Default)
  153. DEVICE_TITLE := Buffalo WXR-1900DHP
  154. DEVICE_PACKAGES := $(USB3_PACKAGES)
  155. endef
  156. TARGET_DEVICES += buffalo-wxr-1900dhp
  157. define Device/buffalo-wzr-600dhp2
  158. $(call Device/buffalo/Default)
  159. DEVICE_TITLE := Buffalo WZR-600DHP2
  160. DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
  161. endef
  162. TARGET_DEVICES += buffalo-wzr-600dhp2
  163. define Device/buffalo-wzr-900dhp
  164. $(call Device/buffalo/Default)
  165. DEVICE_TITLE := Buffalo WZR-900DHP
  166. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  167. BUFFALO_TAG_PLATFORM := bcm
  168. BUFFALO_TAG_VERSION := 9.99
  169. BUFFALO_TAG_MINOR := 9.99
  170. IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
  171. IMAGE/factory-DHP-EU.bin := \
  172. append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
  173. buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
  174. buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
  175. buffalo-dhp-image
  176. IMAGE/factory-DHP2-JP.bin := \
  177. append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
  178. buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
  179. buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
  180. buffalo-dhp-image
  181. endef
  182. TARGET_DEVICES += buffalo-wzr-900dhp
  183. define Device/buffalo-wzr-1750dhp
  184. $(call Device/buffalo/Default)
  185. DEVICE_TITLE := Buffalo WZR-1750DHP
  186. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  187. endef
  188. TARGET_DEVICES += buffalo-wzr-1750dhp
  189. define Device/dlink
  190. IMAGES := bin
  191. IMAGE/bin := append-ubi | seama-nand
  192. endef
  193. define Device/dlink-dir-885l
  194. DEVICE_TITLE := D-Link DIR-885L
  195. DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
  196. $(Device/dlink)
  197. SIGNATURE := wrgac42_dlink.2015_dir885l
  198. endef
  199. TARGET_DEVICES += dlink-dir-885l
  200. # Linksys devices are disabled due to problem with 2 TRX partitions
  201. define Device/linksys-ea6300-v1
  202. DEVICE_TITLE := Linksys EA6300 V1
  203. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  204. endef
  205. # TARGET_DEVICES += linksys-ea6300-v1
  206. define Device/linksys-ea9200
  207. DEVICE_TITLE := Linksys EA9200 V1
  208. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  209. endef
  210. # TARGET_DEVICES += linksys-ea9200
  211. define Device/linksys-ea9500
  212. DEVICE_TITLE := Linksys EA9500
  213. DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
  214. DEVICE_DTS := bcm47094-linksys-panamera
  215. endef
  216. # TARGET_DEVICES += linksys-ea9500
  217. define Device/netgear
  218. IMAGES := chk
  219. IMAGE/chk := append-ubi | trx-nand | netgear-chk
  220. NETGEAR_REGION := 1
  221. endef
  222. define Device/netgear-r6250
  223. DEVICE_TITLE := Netgear R6250
  224. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  225. $(Device/netgear)
  226. NETGEAR_BOARD_ID := U12H245T00_NETGEAR
  227. endef
  228. TARGET_DEVICES += netgear-r6250
  229. define Device/netgear-r6300-v2
  230. DEVICE_TITLE := Netgear R6300 V2
  231. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  232. $(Device/netgear)
  233. NETGEAR_BOARD_ID := U12H240T00_NETGEAR
  234. endef
  235. TARGET_DEVICES += netgear-r6300-v2
  236. define Device/netgear-r7000
  237. DEVICE_TITLE := Netgear R7000
  238. DEVICE_PACKAGES := $(USB3_PACKAGES)
  239. $(Device/netgear)
  240. NETGEAR_BOARD_ID := U12H270T00_NETGEAR
  241. endef
  242. TARGET_DEVICES += netgear-r7000
  243. define Device/netgear-r7900
  244. DEVICE_TITLE := Netgear R7900
  245. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  246. $(Device/netgear)
  247. NETGEAR_BOARD_ID := U12H315T30_NETGEAR
  248. endef
  249. TARGET_DEVICES += netgear-r7900
  250. define Device/netgear-r8000
  251. DEVICE_TITLE := Netgear R8000
  252. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  253. $(Device/netgear)
  254. NETGEAR_BOARD_ID := U12H315T00_NETGEAR
  255. endef
  256. TARGET_DEVICES += netgear-r8000
  257. define Device/netgear-r8500
  258. DEVICE_TITLE := Netgear R8500
  259. DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
  260. $(Device/netgear)
  261. NETGEAR_BOARD_ID := U12H334T00_NETGEAR
  262. endef
  263. # TARGET_DEVICES += netgear-r8500
  264. define Device/smartrg-sr400ac
  265. DEVICE_TITLE := SmartRG SR400ac
  266. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  267. IMAGES := trx
  268. IMAGE/trx := append-rootfs | trx-serial
  269. KERNEL_INITRAMFS_SUFFIX := .bin
  270. KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
  271. endef
  272. TARGET_DEVICES += smartrg-sr400ac
  273. define Device/tenda-ac9
  274. DEVICE_TITLE := Tenda AC9
  275. DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
  276. IMAGES := trx
  277. IMAGE/trx := append-rootfs | trx-serial
  278. endef
  279. TARGET_DEVICES += tenda-ac9
  280. define Device/tplink-archer-c5-v2
  281. DEVICE_TITLE := TP-LINK Archer C5 V2
  282. DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
  283. IMAGES := bin
  284. IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
  285. TPLINK_BOARD := ARCHER-C5-V2
  286. endef
  287. TARGET_DEVICES += tplink-archer-c5-v2
  288. define Device/tplink-archer-c9-v1
  289. DEVICE_TITLE := TP-LINK Archer C9 V1
  290. DEVICE_PACKAGES := $(USB3_PACKAGES)
  291. IMAGES := bin
  292. IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
  293. TPLINK_BOARD := ARCHERC9
  294. endef
  295. TARGET_DEVICES += tplink-archer-c9-v1
  296. $(eval $(call BuildImage))