Makefile 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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/luxul-xap-1410
  218. DEVICE_TITLE := Luxul XAP-1410
  219. IMAGE/trx := append-rootfs | trx-serial
  220. endef
  221. TARGET_DEVICES += luxul-xap-1410
  222. define Device/luxul-xap-1510
  223. DEVICE_TITLE := Luxul XAP-1510
  224. IMAGE/trx := append-rootfs | trx-serial
  225. endef
  226. TARGET_DEVICES += luxul-xap-1510
  227. define Device/luxul-xwc-1000
  228. DEVICE_TITLE := Luxul XWC-1000
  229. IMAGE/trx := append-rootfs | trx-serial
  230. endef
  231. TARGET_DEVICES += luxul-xwc-1000
  232. define Device/luxul-xwr-1200
  233. DEVICE_TITLE := Luxul XWR-1200
  234. DEVICE_PACKAGES := $(USB2_PACKAGES)
  235. endef
  236. TARGET_DEVICES += luxul-xwr-1200
  237. define Device/luxul-xwr-3100
  238. DEVICE_TITLE := Luxul XWR-3100
  239. DEVICE_PACKAGES := $(IEEE8021X) kmod-brcmfmac $(USB3_PACKAGES)
  240. endef
  241. TARGET_DEVICES += luxul-xwr-3100
  242. define Device/netgear
  243. IMAGES := chk
  244. IMAGE/chk := append-ubi | trx-nand | netgear-chk
  245. NETGEAR_REGION := 1
  246. endef
  247. define Device/netgear-r6250
  248. DEVICE_TITLE := Netgear R6250
  249. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  250. $(Device/netgear)
  251. NETGEAR_BOARD_ID := U12H245T00_NETGEAR
  252. endef
  253. TARGET_DEVICES += netgear-r6250
  254. define Device/netgear-r6300-v2
  255. DEVICE_TITLE := Netgear R6300 V2
  256. DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
  257. $(Device/netgear)
  258. NETGEAR_BOARD_ID := U12H240T00_NETGEAR
  259. endef
  260. TARGET_DEVICES += netgear-r6300-v2
  261. define Device/netgear-r7000
  262. DEVICE_TITLE := Netgear R7000
  263. DEVICE_PACKAGES := $(USB3_PACKAGES)
  264. $(Device/netgear)
  265. NETGEAR_BOARD_ID := U12H270T00_NETGEAR
  266. endef
  267. TARGET_DEVICES += netgear-r7000
  268. define Device/netgear-r7900
  269. DEVICE_TITLE := Netgear R7900
  270. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  271. $(Device/netgear)
  272. NETGEAR_BOARD_ID := U12H315T30_NETGEAR
  273. endef
  274. TARGET_DEVICES += netgear-r7900
  275. define Device/netgear-r8000
  276. DEVICE_TITLE := Netgear R8000
  277. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  278. $(Device/netgear)
  279. NETGEAR_BOARD_ID := U12H315T00_NETGEAR
  280. endef
  281. TARGET_DEVICES += netgear-r8000
  282. define Device/netgear-r8500
  283. DEVICE_TITLE := Netgear R8500
  284. DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
  285. $(Device/netgear)
  286. NETGEAR_BOARD_ID := U12H334T00_NETGEAR
  287. endef
  288. # TARGET_DEVICES += netgear-r8500
  289. define Device/smartrg-sr400ac
  290. DEVICE_TITLE := SmartRG SR400ac
  291. DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
  292. IMAGES := trx
  293. IMAGE/trx := append-rootfs | trx-serial
  294. KERNEL_INITRAMFS_SUFFIX := .bin
  295. KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
  296. endef
  297. TARGET_DEVICES += smartrg-sr400ac
  298. define Device/tenda-ac9
  299. DEVICE_TITLE := Tenda AC9
  300. DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
  301. IMAGES := trx
  302. IMAGE/trx := append-rootfs | trx-serial
  303. endef
  304. TARGET_DEVICES += tenda-ac9
  305. define Device/tplink-archer-c5-v2
  306. DEVICE_TITLE := TP-LINK Archer C5 V2
  307. DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
  308. IMAGES := bin
  309. IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
  310. TPLINK_BOARD := ARCHER-C5-V2
  311. endef
  312. TARGET_DEVICES += tplink-archer-c5-v2
  313. define Device/tplink-archer-c9-v1
  314. DEVICE_TITLE := TP-LINK Archer C9 V1
  315. DEVICE_PACKAGES := $(USB3_PACKAGES)
  316. IMAGES := bin
  317. IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
  318. TPLINK_BOARD := ARCHERC9
  319. endef
  320. TARGET_DEVICES += tplink-archer-c9-v1
  321. $(eval $(call BuildImage))