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