bcm53xx: build a single device per profile
[openwrt/staging/hauke.git] / target / linux / bcm53xx / image / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # Copyright (C) 2013 OpenWrt.org
4
5 include $(TOPDIR)/rules.mk
6 include $(INCLUDE_DIR)/image.mk
7
8 define Image/Prepare
9 rm -f $(KDIR)/fs_mark
10 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
11 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
12
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
18 define Build/lzma-d16
19 $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
20 mv $@.new $@
21 endef
22
23 # Similar to Build/tplink-safeloader but uses TRX instead of clean kernel
24 define Build/bcm53xx-tplink-safeloader
25 $(STAGING_DIR_HOST)/bin/trx \
26 -o $@.trx \
27 -m 33554432 \
28 -f $(IMAGE_KERNEL) -a 1024
29 $(STAGING_DIR_HOST)/bin/tplink-safeloader \
30 -B $(TPLINK_BOARD) \
31 -k $@.trx \
32 -r $@ \
33 -j \
34 -o $@.new
35 mv $@.new $@
36 rm $@.trx
37 endef
38
39 define Build/buffalo-wzr-header
40 $(eval product=$(word 1,$(1)))
41 $(eval region=$(word 2,$(1)))
42 ( \
43 echo $(product)_$(BUFFALO_TAG_VERSION)_$(BUFFALO_TAG_MINOR)_$(region)_$(BUFFALO_TAG_PLATFORM); \
44 echo filelen=$$(stat -c%s $@); \
45 cat $@ \
46 ) > $@.new
47 mv $@.new $@
48 endef
49
50 # TRX with only one (kernel) partition
51 define Build/trx
52 $(STAGING_DIR_HOST)/bin/trx \
53 -o $@.new \
54 -m 33554432 \
55 -f $@
56 mv $@.new $@
57 endef
58
59 define Build/trx-serial
60 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
61 -f $(IMAGE_KERNEL) -a 1024 \
62 -f $@ -a 0x10000 -A $(KDIR)/fs_mark
63 mv $@.new $@
64 endef
65
66 define Build/trx-nand
67 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
68 # if it grows up between releases
69 # root: UBI with one extra block containing UBI mark to trigger erasing
70 # rest of partition
71 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
72 -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
73 -f $@ \
74 -A $(KDIR)/ubi_mark -a 0x20000
75 mv $@.new $@
76 endef
77
78 define Build/asus-trx
79 $(STAGING_DIR_HOST)/bin/asustrx \
80 -p $(ASUS_PRODUCTID) -i $@ -o $@.new
81 mv $@.new $@
82 endef
83
84 define Build/luxul-lxl
85 $(STAGING_DIR_HOST)/bin/lxlfw create $@.new \
86 -i $@ \
87 -b $(LUXUL_BOARD)
88 mv $@.new $@
89 endef
90
91 define Build/seama-nand
92 # Seama entity
93 $(STAGING_DIR_HOST)/bin/oseama \
94 entity $@.entity \
95 -m "dev=/dev/mtdblock/7" \
96 -m "type=firmware" \
97 -f $(IMAGE_KERNEL) \
98 -b 0x400000 \
99 -f $@ \
100 -f $(KDIR)/ubi_mark
101 # Seama container
102 $(STAGING_DIR_HOST)/bin/seama \
103 -s $@ \
104 -m "signature=$(SIGNATURE)" \
105 -i $@.entity
106 endef
107
108 define Build/dwl8610ap-image
109 mkdir -p $@.tmptar
110 # The DWL8610AP pretends to be a Broadcom reference design
111 echo "bcm953012er" > $@.tmptar/board
112 echo "LVL7" > $@.tmptar/model
113 # Something high beyond what D-Link has put out
114 echo "5.0.0.0" > $@.tmptar/version
115 # Create rootfs.bin, this is just a NAND image including everything
116 cp $@ $@.tmptar/rootfs.bin
117 # Hash the rootfs.bin
118 cat $@.tmptar/rootfs.bin | md5sum > $@.tmptar/rootfs.md5
119 cd $@.tmptar && tar -c -f $@.new *
120 rm -rf $@.tmptar
121 mv $@.new $@
122 endef
123
124 DEVICE_VARS += ASUS_PRODUCTID
125 DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
126 DEVICE_VARS += SIGNATURE
127 DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION TPLINK_BOARD
128 DEVICE_VARS += LUXUL_BOARD
129
130 IEEE8021X := wpad-basic-mbedtls
131 B43 := $(IEEE8021X) kmod-b43
132 BRCMFMAC_43602A1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-43602a1-pcie
133 BRCMFMAC_4366B1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-4366b1-pcie
134 BRCMFMAC_4366C0 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-4366c0-pcie
135 USB2_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-phy-bcm-ns-usb2
136 USB2_PACKAGES += kmod-usb-ledtrig-usbport
137 USB3_PACKAGES := $(USB2_PACKAGES) kmod-usb3 kmod-phy-bcm-ns-usb3
138
139 define Device/Default
140 PROFILES = Generic $$(DEVICE_NAME)
141 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
142 # extract the full dtb name based on the device info
143 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(subst _,-,$(1)).dtb)))
144 KERNEL := kernel-bin | append-dtb | lzma-d16
145 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
146 KERNEL_INITRAMFS_SUFFIX := .trx
147 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16 | trx
148 FILESYSTEMS := squashfs
149 KERNEL_NAME := zImage
150 DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1).$$(2)
151 IMAGES := trx
152 BLOCKSIZE := 128k
153 PAGESIZE := 2048
154 IMAGE/trx := append-ubi | trx-nand
155 endef
156
157 define Device/asus
158 DEVICE_VENDOR := ASUS
159 IMAGES := trx
160 IMAGE/trx := append-ubi | trx-nand | asus-trx
161 endef
162
163 define Device/asus_rt-ac3100
164 $(call Device/asus)
165 DEVICE_MODEL := RT-AC3100
166 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
167 ASUS_PRODUCTID := RT-AC3100
168 endef
169 TARGET_DEVICES += asus_rt-ac3100
170
171 define Device/asus_rt-ac56u
172 $(call Device/asus)
173 DEVICE_MODEL := RT-AC56U
174 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
175 ASUS_PRODUCTID := RT-AC56U
176 endef
177 TARGET_DEVICES += asus_rt-ac56u
178
179 define Device/asus_rt-ac68u
180 $(call Device/asus)
181 DEVICE_MODEL := RT-AC68U
182 DEVICE_PACKAGES := $(USB3_PACKAGES)
183 ASUS_PRODUCTID := RT-AC68U
184 endef
185 TARGET_DEVICES += asus_rt-ac68u
186
187 define Device/asus_rt-ac87u
188 $(call Device/asus)
189 DEVICE_MODEL := RT-AC87U
190 DEVICE_PACKAGES := $(USB3_PACKAGES)
191 ASUS_PRODUCTID := RT-AC87U
192 endef
193 TARGET_DEVICES += asus_rt-ac87u
194
195 define Device/asus_rt-ac88u
196 $(call Device/asus)
197 DEVICE_MODEL := RT-AC88U
198 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
199 ASUS_PRODUCTID := RT-AC88U
200 endef
201 TARGET_DEVICES += asus_rt-ac88u
202
203 define Device/asus_rt-n18u
204 $(call Device/asus)
205 DEVICE_MODEL := RT-N18U
206 DEVICE_PACKAGES := $(USB3_PACKAGES)
207 ASUS_PRODUCTID := RT-N18U
208 endef
209 TARGET_DEVICES += asus_rt-n18u
210
211 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
212 # kernels.
213 # We should have two initramfs images for Buffalo: plain initramfs kernel and
214 # TRX with initramfs kernel. It's not possible right now so let's just build
215 # plain initramfs kernel as it may be more useful.
216 define Device/buffalo/Default
217 DEVICE_VENDOR := Buffalo
218 KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
219 KERNEL_INITRAMFS = $$(KERNEL)
220 endef
221
222 define Device/buffalo_wxr-1900dhp
223 $(call Device/buffalo/Default)
224 DEVICE_MODEL := WXR-1900DHP
225 DEVICE_PACKAGES := $(USB3_PACKAGES)
226 endef
227 TARGET_DEVICES += buffalo_wxr-1900dhp
228
229 define Device/buffalo_wzr-600dhp2
230 $(call Device/buffalo/Default)
231 DEVICE_MODEL := WZR-600DHP2
232 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
233 endef
234 TARGET_DEVICES += buffalo_wzr-600dhp2
235
236 define Device/buffalo_wzr-900dhp
237 $(call Device/buffalo/Default)
238 DEVICE_MODEL := WZR-900DHP
239 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
240 BUFFALO_TAG_PLATFORM := bcm
241 BUFFALO_TAG_VERSION := 9.99
242 BUFFALO_TAG_MINOR := 9.99
243 IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
244 IMAGE/factory-DHP-EU.bin := \
245 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
246 buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
247 buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
248 buffalo-dhp-image
249 IMAGE/factory-DHP2-JP.bin := \
250 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
251 buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
252 buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
253 buffalo-dhp-image
254 endef
255 TARGET_DEVICES += buffalo_wzr-900dhp
256
257 define Device/buffalo_wzr-1750dhp
258 $(call Device/buffalo/Default)
259 DEVICE_MODEL := WZR-1750DHP
260 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
261 endef
262 TARGET_DEVICES += buffalo_wzr-1750dhp
263
264 define Device/dlink
265 DEVICE_VENDOR := D-Link
266 IMAGES := bin
267 IMAGE/bin := append-ubi | seama-nand
268 endef
269
270 define Device/dlink_dir-885l
271 DEVICE_MODEL := DIR-885L
272 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
273 $(Device/dlink)
274 SIGNATURE := wrgac42_dlink.2015_dir885l
275 endef
276 TARGET_DEVICES += dlink_dir-885l
277
278 define Device/dlink_dwl-8610ap
279 DEVICE_VENDOR := D-Link
280 DEVICE_MODEL := DWL-8610AP
281 DEVICE_PACKAGES := $(B43)
282 IMAGES := factory.tar
283 IMAGE/factory.tar := append-ubi | trx-nand | dwl8610ap-image
284 endef
285 TARGET_DEVICES += dlink_dwl-8610ap
286
287 define Device/linksys_ea6300-v1
288 DEVICE_VENDOR := Linksys
289 DEVICE_MODEL := EA6300
290 DEVICE_VARIANT := v1
291 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
292 endef
293 TARGET_DEVICES += linksys_ea6300-v1
294
295 define Device/linksys_ea6500-v2
296 DEVICE_VENDOR := Linksys
297 DEVICE_MODEL := EA6500
298 DEVICE_VARIANT := v2
299 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
300 endef
301 TARGET_DEVICES += linksys_ea6500-v2
302
303 define Device/linksys_ea9200
304 DEVICE_VENDOR := Linksys
305 DEVICE_MODEL := EA9200
306 DEVICE_VARIANT := v1
307 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
308 endef
309 TARGET_DEVICES += linksys_ea9200
310
311 define Device/linksys_ea9500
312 DEVICE_VENDOR := Linksys
313 DEVICE_MODEL := EA9500
314 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
315 DEVICE_DTS := bcm47094-linksys-panamera
316 endef
317 TARGET_DEVICES += linksys_ea9500
318
319 define Device/luxul
320 DEVICE_VENDOR := Luxul
321 IMAGES := lxl
322 IMAGE/lxl := append-ubi | trx-nand | luxul-lxl
323 endef
324
325 define Device/luxul_abr-4500
326 $(Device/luxul)
327 DEVICE_MODEL := ABR-4500
328 DEVICE_PACKAGES := $(USB3_PACKAGES)
329 LUXUL_BOARD := ABR-4500
330 endef
331 TARGET_DEVICES += luxul_abr-4500
332
333 define Device/luxul_xap-1610
334 $(Device/luxul)
335 DEVICE_MODEL := XAP-1610
336 DEVICE_PACKAGES := $(BRCMFMAC_4366C0)
337 IMAGE/lxl := append-rootfs | trx-serial | luxul-lxl
338 LUXUL_BOARD := XAP-1610
339 endef
340 TARGET_DEVICES += luxul_xap-1610
341
342 define Device/luxul_xbr-4500
343 $(Device/luxul)
344 DEVICE_MODEL := XBR-4500
345 DEVICE_PACKAGES := $(USB3_PACKAGES)
346 LUXUL_BOARD := XBR-4500
347 endef
348 TARGET_DEVICES += luxul_xbr-4500
349
350 define Device/luxul_xwr-3150
351 $(Device/luxul)
352 DEVICE_MODEL := XWR-3150
353 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
354 DEVICE_DTS := bcm47094-luxul-xwr-3150-v1
355 LUXUL_BOARD := XWR-3150
356 endef
357 TARGET_DEVICES += luxul_xwr-3150
358
359 define Device/meraki_mr26
360 DEVICE_VENDOR := Meraki
361 DEVICE_MODEL := MR26
362 DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
363 kmod-hwmon-ina2xx kmod-leds-uleds nu801
364 DEVICE_DTS := bcm53015-meraki-mr26
365 # resize the initramfs to fit the size of the existing part.safe.
366 KERNEL_LOADADDR := 0x00008000
367 KERNEL_INITRAMFS_SUFFIX := .bin
368 KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip | pad-to 9310208
369 # LZMA is not supported by the uboot
370 KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
371 IMAGES += sysupgrade.bin
372 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
373 endef
374 TARGET_DEVICES += meraki_mr26
375
376 define Device/meraki_mr32
377 DEVICE_VENDOR := Meraki
378 DEVICE_MODEL := MR32
379 DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
380 kmod-leds-pwm kmod-hwmon-ina2xx kmod-bluetooth
381 DEVICE_DTS := bcm53016-meraki-mr32
382 # Meraki FW r23 tries to resize the part.safe partition before it will
383 # flash the image. This is a bit of a problem, since resizing will fail
384 # if the partition is smaller than the old one.
385 KERNEL_LOADADDR := 0x00008000
386 KERNEL_INITRAMFS_SUFFIX := .bin
387 DEVICE_DTS_DELIMITER := @
388 DEVICE_DTS_CONFIG := config@1
389 KERNEL_INITRAMFS := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb | \
390 pad-to 10362880
391 KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb
392 IMAGES += sysupgrade.bin
393 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
394
395 # The loader is specifically looking for fdt@2:
396 # [ 3.190000] find_itb_subimage: error finding fdt@2: FDT_ERR_NOTFOUND
397 # The image won't boot, if it isn't found. :(
398 DEVICE_FDT_NUM := 2
399 endef
400 TARGET_DEVICES += meraki_mr32
401
402 define Device/netgear
403 DEVICE_VENDOR := NETGEAR
404 IMAGES := chk
405 IMAGE/chk := append-ubi | trx-nand | netgear-chk
406 NETGEAR_REGION := 1
407 endef
408
409 define Device/netgear_r6250
410 DEVICE_MODEL := R6250
411 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
412 $(Device/netgear)
413 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
414 endef
415 TARGET_DEVICES += netgear_r6250
416
417 define Device/netgear_r6300-v2
418 DEVICE_MODEL := R6300
419 DEVICE_VARIANT := v2
420 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
421 $(Device/netgear)
422 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
423 endef
424 TARGET_DEVICES += netgear_r6300-v2
425
426 define Device/netgear_r7000
427 DEVICE_MODEL := R7000
428 DEVICE_PACKAGES := $(USB3_PACKAGES)
429 $(Device/netgear)
430 NETGEAR_BOARD_ID := U12H270T00_NETGEAR
431 endef
432 TARGET_DEVICES += netgear_r7000
433
434 define Device/netgear_r7900
435 DEVICE_MODEL := R7900
436 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
437 $(Device/netgear)
438 NETGEAR_BOARD_ID := U12H315T30_NETGEAR
439 endef
440 TARGET_DEVICES += netgear_r7900
441
442 define Device/netgear_r8000
443 DEVICE_MODEL := R8000
444 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
445 $(Device/netgear)
446 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
447 endef
448 TARGET_DEVICES += netgear_r8000
449
450 define Device/netgear_r8500
451 DEVICE_MODEL := R8500
452 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
453 $(Device/netgear)
454 NETGEAR_BOARD_ID := U12H334T00_NETGEAR
455 DEFAULT := n
456 endef
457 TARGET_DEVICES += netgear_r8500
458
459 define Device/smartrg_sr400ac
460 DEVICE_VENDOR := SmartRG
461 DEVICE_MODEL := SR400ac
462 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
463 IMAGES := trx
464 IMAGE/trx := append-rootfs | trx-serial
465 KERNEL_INITRAMFS_SUFFIX := .bin
466 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
467 endef
468 TARGET_DEVICES += smartrg_sr400ac
469
470 define Device/phicomm_k3
471 DEVICE_VENDOR := PHICOMM
472 DEVICE_MODEL := K3
473 DEVICE_ALT0_VENDOR := Wavlink
474 DEVICE_ALT0_MODEL := QUANTUM DAX
475 DEVICE_ALT1_VENDOR := Wavlink
476 DEVICE_ALT1_MODEL := WL-WN538A8
477 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
478 IMAGES := trx
479 endef
480 TARGET_DEVICES += phicomm_k3
481
482 define Device/tenda_ac9
483 DEVICE_VENDOR := Tenda
484 DEVICE_MODEL := AC9
485 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
486 IMAGES := trx
487 IMAGE/trx := append-rootfs | trx-serial
488 endef
489 TARGET_DEVICES += tenda_ac9
490
491 define Device/tplink_archer-c5-v2
492 DEVICE_VENDOR := TP-Link
493 DEVICE_MODEL := Archer C5
494 DEVICE_VARIANT := v2
495 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
496 IMAGES := bin
497 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
498 TPLINK_BOARD := ARCHER-C5-V2
499 BROKEN := y
500 endef
501 #TARGET_DEVICES += tplink_archer-c5-v2
502
503 define Device/tplink_archer-c9-v1
504 DEVICE_VENDOR := TP-Link
505 DEVICE_MODEL := Archer C9
506 DEVICE_VARIANT := v1
507 DEVICE_PACKAGES := $(USB3_PACKAGES)
508 IMAGES := bin
509 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
510 TPLINK_BOARD := ARCHERC9
511 BROKEN := y
512 endef
513 #TARGET_DEVICES += tplink_archer-c9-v1
514
515 $(eval $(call BuildImage))