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