5158b432b3b1db937d28b5eddffb3ebfc20a1c7d
[openwrt/openwrt.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 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
141 # extract the full dtb name based on the device info
142 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(subst _,-,$(1)).dtb)))
143 KERNEL := kernel-bin | append-dtb | lzma-d16
144 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
145 KERNEL_INITRAMFS_SUFFIX := .trx
146 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16 | trx
147 FILESYSTEMS := squashfs
148 KERNEL_NAME := zImage
149 DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1).$$(2)
150 IMAGES := trx
151 BLOCKSIZE := 128k
152 PAGESIZE := 2048
153 IMAGE/trx := append-ubi | trx-nand
154 endef
155
156 define Device/asus
157 DEVICE_VENDOR := ASUS
158 IMAGES := trx
159 IMAGE/trx := append-ubi | trx-nand | asus-trx
160 endef
161
162 define Device/asus_rt-ac3100
163 $(call Device/asus)
164 DEVICE_MODEL := RT-AC3100
165 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
166 ASUS_PRODUCTID := RT-AC3100
167 endef
168 TARGET_DEVICES += asus_rt-ac3100
169
170 define Device/asus_rt-ac56u
171 $(call Device/asus)
172 DEVICE_MODEL := RT-AC56U
173 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
174 ASUS_PRODUCTID := RT-AC56U
175 endef
176 TARGET_DEVICES += asus_rt-ac56u
177
178 define Device/asus_rt-ac68u
179 $(call Device/asus)
180 DEVICE_MODEL := RT-AC68U
181 DEVICE_PACKAGES := $(USB3_PACKAGES)
182 ASUS_PRODUCTID := RT-AC68U
183 endef
184 TARGET_DEVICES += asus_rt-ac68u
185
186 define Device/asus_rt-ac87u
187 $(call Device/asus)
188 DEVICE_MODEL := RT-AC87U
189 DEVICE_PACKAGES := $(USB3_PACKAGES)
190 ASUS_PRODUCTID := RT-AC87U
191 endef
192 TARGET_DEVICES += asus_rt-ac87u
193
194 define Device/asus_rt-ac88u
195 $(call Device/asus)
196 DEVICE_MODEL := RT-AC88U
197 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
198 ASUS_PRODUCTID := RT-AC88U
199 endef
200 TARGET_DEVICES += asus_rt-ac88u
201
202 define Device/asus_rt-n18u
203 $(call Device/asus)
204 DEVICE_MODEL := RT-N18U
205 DEVICE_PACKAGES := $(USB3_PACKAGES)
206 ASUS_PRODUCTID := RT-N18U
207 endef
208 TARGET_DEVICES += asus_rt-n18u
209
210 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
211 # kernels.
212 # We should have two initramfs images for Buffalo: plain initramfs kernel and
213 # TRX with initramfs kernel. It's not possible right now so let's just build
214 # plain initramfs kernel as it may be more useful.
215 define Device/buffalo/Default
216 DEVICE_VENDOR := Buffalo
217 KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
218 KERNEL_INITRAMFS = $$(KERNEL)
219 endef
220
221 define Device/buffalo_wxr-1900dhp
222 $(call Device/buffalo/Default)
223 DEVICE_MODEL := WXR-1900DHP
224 DEVICE_PACKAGES := $(USB3_PACKAGES)
225 endef
226 TARGET_DEVICES += buffalo_wxr-1900dhp
227
228 define Device/buffalo_wzr-600dhp2
229 $(call Device/buffalo/Default)
230 DEVICE_MODEL := WZR-600DHP2
231 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
232 endef
233 TARGET_DEVICES += buffalo_wzr-600dhp2
234
235 define Device/buffalo_wzr-900dhp
236 $(call Device/buffalo/Default)
237 DEVICE_MODEL := WZR-900DHP
238 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
239 BUFFALO_TAG_PLATFORM := bcm
240 BUFFALO_TAG_VERSION := 9.99
241 BUFFALO_TAG_MINOR := 9.99
242 IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
243 IMAGE/factory-DHP-EU.bin := \
244 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
245 buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
246 buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
247 buffalo-dhp-image
248 IMAGE/factory-DHP2-JP.bin := \
249 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
250 buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
251 buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
252 buffalo-dhp-image
253 endef
254 TARGET_DEVICES += buffalo_wzr-900dhp
255
256 define Device/buffalo_wzr-1750dhp
257 $(call Device/buffalo/Default)
258 DEVICE_MODEL := WZR-1750DHP
259 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
260 endef
261 TARGET_DEVICES += buffalo_wzr-1750dhp
262
263 define Device/dlink
264 DEVICE_VENDOR := D-Link
265 IMAGES := bin
266 IMAGE/bin := append-ubi | seama-nand
267 endef
268
269 define Device/dlink_dir-885l
270 DEVICE_MODEL := DIR-885L
271 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
272 $(Device/dlink)
273 SIGNATURE := wrgac42_dlink.2015_dir885l
274 endef
275 TARGET_DEVICES += dlink_dir-885l
276
277 define Device/dlink_dwl-8610ap
278 DEVICE_VENDOR := D-Link
279 DEVICE_MODEL := DWL-8610AP
280 DEVICE_PACKAGES := $(B43)
281 IMAGES := factory.tar
282 IMAGE/factory.tar := append-ubi | trx-nand | dwl8610ap-image
283 endef
284 TARGET_DEVICES += dlink_dwl-8610ap
285
286 define Device/linksys_ea6300-v1
287 DEVICE_VENDOR := Linksys
288 DEVICE_MODEL := EA6300
289 DEVICE_VARIANT := v1
290 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
291 endef
292 TARGET_DEVICES += linksys_ea6300-v1
293
294 define Device/linksys_ea6500-v2
295 DEVICE_VENDOR := Linksys
296 DEVICE_MODEL := EA6500
297 DEVICE_VARIANT := v2
298 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
299 endef
300 TARGET_DEVICES += linksys_ea6500-v2
301
302 define Device/linksys_ea9200
303 DEVICE_VENDOR := Linksys
304 DEVICE_MODEL := EA9200
305 DEVICE_VARIANT := v1
306 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
307 endef
308 TARGET_DEVICES += linksys_ea9200
309
310 define Device/linksys_ea9500
311 DEVICE_VENDOR := Linksys
312 DEVICE_MODEL := EA9500
313 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
314 DEVICE_DTS := bcm47094-linksys-panamera
315 endef
316 TARGET_DEVICES += linksys_ea9500
317
318 define Device/luxul
319 DEVICE_VENDOR := Luxul
320 IMAGES := lxl
321 IMAGE/lxl := append-ubi | trx-nand | luxul-lxl
322 endef
323
324 define Device/luxul_abr-4500
325 $(Device/luxul)
326 DEVICE_MODEL := ABR-4500
327 DEVICE_PACKAGES := $(USB3_PACKAGES)
328 LUXUL_BOARD := ABR-4500
329 endef
330 TARGET_DEVICES += luxul_abr-4500
331
332 define Device/luxul_xap-1610
333 $(Device/luxul)
334 DEVICE_MODEL := XAP-1610
335 DEVICE_PACKAGES := $(BRCMFMAC_4366C0)
336 IMAGE/lxl := append-rootfs | trx-serial | luxul-lxl
337 LUXUL_BOARD := XAP-1610
338 endef
339 TARGET_DEVICES += luxul_xap-1610
340
341 define Device/luxul_xbr-4500
342 $(Device/luxul)
343 DEVICE_MODEL := XBR-4500
344 DEVICE_PACKAGES := $(USB3_PACKAGES)
345 LUXUL_BOARD := XBR-4500
346 endef
347 TARGET_DEVICES += luxul_xbr-4500
348
349 define Device/luxul_xwr-3150
350 $(Device/luxul)
351 DEVICE_MODEL := XWR-3150
352 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
353 DEVICE_DTS := bcm47094-luxul-xwr-3150-v1
354 LUXUL_BOARD := XWR-3150
355 endef
356 TARGET_DEVICES += luxul_xwr-3150
357
358 define Device/meraki_mr26
359 DEVICE_VENDOR := Meraki
360 DEVICE_MODEL := MR26
361 DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
362 kmod-hwmon-ina2xx kmod-leds-uleds nu801
363 DEVICE_DTS := bcm53015-meraki-mr26
364 # resize the initramfs to fit the size of the existing part.safe.
365 KERNEL_LOADADDR := 0x00008000
366 KERNEL_INITRAMFS_SUFFIX := .bin
367 KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | uImage gzip | pad-to 9310208
368 # LZMA is not supported by the uboot
369 KERNEL := kernel-bin | append-dtb | gzip | uImage gzip
370 IMAGES += sysupgrade.bin
371 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
372 endef
373 TARGET_DEVICES += meraki_mr26
374
375 define Device/meraki_mr32
376 DEVICE_VENDOR := Meraki
377 DEVICE_MODEL := MR32
378 DEVICE_PACKAGES := $(B43) kmod-i2c-bcm-iproc kmod-eeprom-at24 \
379 kmod-leds-pwm kmod-hwmon-ina2xx kmod-bluetooth
380 DEVICE_DTS := bcm53016-meraki-mr32
381 # Meraki FW r23 tries to resize the part.safe partition before it will
382 # flash the image. This is a bit of a problem, since resizing will fail
383 # if the partition is smaller than the old one.
384 KERNEL_LOADADDR := 0x00008000
385 KERNEL_INITRAMFS_SUFFIX := .bin
386 DEVICE_DTS_DELIMITER := @
387 DEVICE_DTS_CONFIG := config@1
388 KERNEL_INITRAMFS := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb | \
389 pad-to 10362880
390 KERNEL := kernel-bin | fit none $$(DTS_DIR)/$$(DEVICE_DTS).dtb
391 IMAGES += sysupgrade.bin
392 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
393
394 # The loader is specifically looking for fdt@2:
395 # [ 3.190000] find_itb_subimage: error finding fdt@2: FDT_ERR_NOTFOUND
396 # The image won't boot, if it isn't found. :(
397 DEVICE_FDT_NUM := 2
398 endef
399 TARGET_DEVICES += meraki_mr32
400
401 define Device/netgear
402 DEVICE_VENDOR := NETGEAR
403 IMAGES := chk
404 IMAGE/chk := append-ubi | trx-nand | netgear-chk
405 NETGEAR_REGION := 1
406 endef
407
408 define Device/netgear_r6250
409 DEVICE_MODEL := R6250
410 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
411 $(Device/netgear)
412 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
413 endef
414 TARGET_DEVICES += netgear_r6250
415
416 define Device/netgear_r6300-v2
417 DEVICE_MODEL := R6300
418 DEVICE_VARIANT := v2
419 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
420 $(Device/netgear)
421 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
422 endef
423 TARGET_DEVICES += netgear_r6300-v2
424
425 define Device/netgear_r7000
426 DEVICE_MODEL := R7000
427 DEVICE_PACKAGES := $(USB3_PACKAGES)
428 $(Device/netgear)
429 NETGEAR_BOARD_ID := U12H270T00_NETGEAR
430 endef
431 TARGET_DEVICES += netgear_r7000
432
433 define Device/netgear_r7900
434 DEVICE_MODEL := R7900
435 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
436 $(Device/netgear)
437 NETGEAR_BOARD_ID := U12H315T30_NETGEAR
438 endef
439 TARGET_DEVICES += netgear_r7900
440
441 define Device/netgear_r8000
442 DEVICE_MODEL := R8000
443 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
444 $(Device/netgear)
445 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
446 endef
447 TARGET_DEVICES += netgear_r8000
448
449 define Device/netgear_r8500
450 DEVICE_MODEL := R8500
451 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
452 $(Device/netgear)
453 NETGEAR_BOARD_ID := U12H334T00_NETGEAR
454 DEFAULT := n
455 endef
456 TARGET_DEVICES += netgear_r8500
457
458 define Device/smartrg_sr400ac
459 DEVICE_VENDOR := SmartRG
460 DEVICE_MODEL := SR400ac
461 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
462 IMAGES := trx
463 IMAGE/trx := append-rootfs | trx-serial
464 KERNEL_INITRAMFS_SUFFIX := .bin
465 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
466 endef
467 TARGET_DEVICES += smartrg_sr400ac
468
469 define Device/phicomm_k3
470 DEVICE_VENDOR := PHICOMM
471 DEVICE_MODEL := K3
472 DEVICE_ALT0_VENDOR := Wavlink
473 DEVICE_ALT0_MODEL := QUANTUM DAX
474 DEVICE_ALT1_VENDOR := Wavlink
475 DEVICE_ALT1_MODEL := WL-WN538A8
476 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
477 IMAGES := trx
478 endef
479 TARGET_DEVICES += phicomm_k3
480
481 define Device/tenda_ac9
482 DEVICE_VENDOR := Tenda
483 DEVICE_MODEL := AC9
484 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
485 IMAGES := trx
486 IMAGE/trx := append-rootfs | trx-serial
487 endef
488 TARGET_DEVICES += tenda_ac9
489
490 define Device/tplink_archer-c5-v2
491 DEVICE_VENDOR := TP-Link
492 DEVICE_MODEL := Archer C5
493 DEVICE_VARIANT := v2
494 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
495 IMAGES := bin
496 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
497 TPLINK_BOARD := ARCHER-C5-V2
498 BROKEN := y
499 endef
500 #TARGET_DEVICES += tplink_archer-c5-v2
501
502 define Device/tplink_archer-c9-v1
503 DEVICE_VENDOR := TP-Link
504 DEVICE_MODEL := Archer C9
505 DEVICE_VARIANT := v1
506 DEVICE_PACKAGES := $(USB3_PACKAGES)
507 IMAGES := bin
508 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
509 TPLINK_BOARD := ARCHERC9
510 BROKEN := y
511 endef
512 #TARGET_DEVICES += tplink_archer-c9-v1
513
514 $(eval $(call BuildImage))