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