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