1 # SPDX-License-Identifier: GPL-2.0-only
3 # Copyright (C) 2013 OpenWrt.org
5 include $(TOPDIR
)/rules.mk
6 include $(INCLUDE_DIR
)/image.mk
10 echo
-ne
'\xde\xad\xc0\xde' > $(KDIR
)/fs_mark
11 $(call prepare_generic_squashfs
,$(KDIR
)/fs_mark
)
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
19 $(STAGING_DIR_HOST
)/bin
/lzma e
$@
-d16
$(1) $@.new
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 \
28 -f
$(IMAGE_KERNEL
) -a
1024
29 $(STAGING_DIR_HOST
)/bin
/tplink-safeloader \
39 define Build
/buffalo-wzr-header
40 $(eval product
=$(word 1,$(1)))
41 $(eval region
=$(word 2,$(1)))
43 echo
$(product
)_
$(BUFFALO_TAG_VERSION
)_
$(BUFFALO_TAG_MINOR
)_
$(region
)_
$(BUFFALO_TAG_PLATFORM
); \
44 echo filelen
=$$(stat
-c
%s
$@
); \
50 # TRX with only one (kernel) partition
52 $(STAGING_DIR_HOST
)/bin
/trx \
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
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
71 $(STAGING_DIR_HOST
)/bin
/otrx create
$@.new \
72 -f
$(IMAGE_KERNEL
) -a
0x20000 -b
0x400000 \
74 -A
$(KDIR
)/ubi_mark
-a
0x20000
79 $(STAGING_DIR_HOST
)/bin
/asustrx \
80 -p
$(ASUS_PRODUCTID
) -i
$@
-o
$@.new
84 define Build
/luxul-lxl
85 $(STAGING_DIR_HOST
)/bin
/lxlfw create
$@.new \
91 define Build
/seama-nand
93 $(STAGING_DIR_HOST
)/bin
/oseama \
95 -m
"dev=/dev/mtdblock/7" \
102 $(STAGING_DIR_HOST
)/bin
/seama \
104 -m
"signature=$(SIGNATURE)" \
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
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
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)
137 IMAGE
/trx
:= append-ubi | trx-nand
141 DEVICE_VENDOR
:= ASUS
143 IMAGE
/trx
:= append-ubi | trx-nand | asus-trx
146 define Device
/asus_rt-ac56u
148 DEVICE_MODEL
:= RT-AC56U
149 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
150 ASUS_PRODUCTID
:= RT-AC56U
152 TARGET_DEVICES
+= asus_rt-ac56u
154 define Device
/asus_rt-ac68u
156 DEVICE_MODEL
:= RT-AC68U
157 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
158 ASUS_PRODUCTID
:= RT-AC68U
160 TARGET_DEVICES
+= asus_rt-ac68u
162 define Device
/asus_rt-ac87u
164 DEVICE_MODEL
:= RT-AC87U
165 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
166 ASUS_PRODUCTID
:= RT-AC87U
168 TARGET_DEVICES
+= asus_rt-ac87u
170 define Device
/asus_rt-n18u
172 DEVICE_MODEL
:= RT-N18U
173 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
174 ASUS_PRODUCTID
:= RT-N18U
176 TARGET_DEVICES
+= asus_rt-n18u
178 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
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
)
189 define Device
/buffalo_wxr-1900dhp
190 $(call Device
/buffalo
/Default
)
191 DEVICE_MODEL
:= WXR-1900DHP
192 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
194 TARGET_DEVICES
+= buffalo_wxr-1900dhp
196 define Device
/buffalo_wzr-600dhp2
197 $(call Device
/buffalo
/Default
)
198 DEVICE_MODEL
:= WZR-600DHP2
199 DEVICE_PACKAGES
:= $(B43
) $(USB2_PACKAGES
)
201 TARGET_DEVICES
+= buffalo_wzr-600dhp2
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 | \
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 | \
222 TARGET_DEVICES
+= buffalo_wzr-900dhp
224 define Device
/buffalo_wzr-1750dhp
225 $(call Device
/buffalo
/Default
)
226 DEVICE_MODEL
:= WZR-1750DHP
227 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
229 TARGET_DEVICES
+= buffalo_wzr-1750dhp
232 DEVICE_VENDOR
:= D-Link
234 IMAGE
/bin
:= append-ubi | seama-nand
237 define Device
/dlink_dir-885l
238 DEVICE_MODEL
:= DIR-885L
239 DEVICE_PACKAGES
:= $(BRCMFMAC_4366B1
) $(USB3_PACKAGES
)
241 SIGNATURE
:= wrgac42_dlink
.2015_dir885l
243 TARGET_DEVICES
+= dlink_dir-885l
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
250 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
253 TARGET_DEVICES
+= linksys_ea6300-v1
255 define Device
/linksys_ea6500-v2
256 DEVICE_VENDOR
:= Linksys
257 DEVICE_MODEL
:= EA6500
259 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
261 TARGET_DEVICES
+= linksys_ea6500-v2
263 define Device
/linksys_ea9200
264 DEVICE_VENDOR
:= Linksys
265 DEVICE_MODEL
:= EA9200
267 DEVICE_PACKAGES
:= $(BRCMFMAC_43602A1
) $(USB3_PACKAGES
)
270 TARGET_DEVICES
+= linksys_ea9200
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
279 TARGET_DEVICES
+= linksys_ea9500
282 DEVICE_VENDOR
:= Luxul
284 IMAGE
/lxl
:= append-ubi | trx-nand | luxul-lxl
287 define Device
/luxul_abr-4500
289 DEVICE_MODEL
:= ABR-4500
290 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
291 LUXUL_BOARD
:= ABR-4500
293 TARGET_DEVICES
+= luxul_abr-4500
295 define Device
/luxul_xap-1610
297 DEVICE_MODEL
:= XAP-1610
298 DEVICE_PACKAGES
:= $(BRCMFMAC_4366C0
)
299 IMAGE
/lxl
:= append-rootfs | trx-serial | luxul-lxl
300 LUXUL_BOARD
:= XAP-1610
302 TARGET_DEVICES
+= luxul_xap-1610
304 define Device
/luxul_xbr-4500
306 DEVICE_MODEL
:= XBR-4500
307 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
308 LUXUL_BOARD
:= XBR-4500
310 TARGET_DEVICES
+= luxul_xbr-4500
312 define Device
/luxul_xwr-3150
314 DEVICE_MODEL
:= XWR-3150
315 DEVICE_PACKAGES
:= $(BRCMFMAC_4366C0
) $(USB3_PACKAGES
)
316 DEVICE_DTS
:= bcm47094-luxul-xwr-3150-v1
317 LUXUL_BOARD
:= XWR-3150
319 TARGET_DEVICES
+= luxul_xwr-3150
321 define Device
/meraki_mr32
322 DEVICE_VENDOR
:= Meraki
324 DEVICE_PACKAGES
:= $(B43
) kmod-i2c-bcm-iproc kmod-i2c-gpio kmod-eeprom-at24 \
325 kmod-leds-pwm kmod-hwmon-ina2xx kmod-bluetooth
326 DEVICE_DTS
:= bcm53016-meraki-mr32
327 # Meraki FW r23 tries to resize the part.safe partition before it will
328 # flash the image. This is a bit of a problem, since resizing will fail
329 # if the partition is smaller than the old one.
330 KERNEL_LOADADDR
:= 0x00008000
331 KERNEL_INITRAMFS_SUFFIX
:= .bin
332 KERNEL_INITRAMFS
:= kernel-bin | fit none
$$(DTS_DIR
)/$$(DEVICE_DTS
).dtb | \
334 KERNEL
:= kernel-bin | fit none
$$(DTS_DIR
)/$$(DEVICE_DTS
).dtb
335 IMAGES
:= sysupgrade.bin
336 # Currently the only device that uses the new image check
337 IMAGE
/sysupgrade.bin
:= sysupgrade-tar | append-metadata
339 # The loader is specifically looking for fdt@2:
340 # [ 3.190000] find_itb_subimage: error finding fdt@2: FDT_ERR_NOTFOUND
341 # The image won't boot, if it isn't found. :(
344 TARGET_DEVICES
+= meraki_mr32
346 define Device
/netgear
347 DEVICE_VENDOR
:= NETGEAR
349 IMAGE
/chk
:= append-ubi | trx-nand | netgear-chk
353 define Device
/netgear_r6250
354 DEVICE_MODEL
:= R6250
355 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
357 NETGEAR_BOARD_ID
:= U12H245T00_NETGEAR
359 TARGET_DEVICES
+= netgear_r6250
361 define Device
/netgear_r6300-v2
362 DEVICE_MODEL
:= R6300
364 DEVICE_PACKAGES
:= $(B43
) $(USB3_PACKAGES
)
366 NETGEAR_BOARD_ID
:= U12H240T00_NETGEAR
368 TARGET_DEVICES
+= netgear_r6300-v2
370 define Device
/netgear_r7000
371 DEVICE_MODEL
:= R7000
372 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
374 NETGEAR_BOARD_ID
:= U12H270T00_NETGEAR
376 TARGET_DEVICES
+= netgear_r7000
378 define Device
/netgear_r7900
379 DEVICE_MODEL
:= R7900
380 DEVICE_PACKAGES
:= $(BRCMFMAC_43602A1
) $(USB3_PACKAGES
)
382 NETGEAR_BOARD_ID
:= U12H315T30_NETGEAR
384 TARGET_DEVICES
+= netgear_r7900
386 define Device
/netgear_r8000
387 DEVICE_MODEL
:= R8000
388 DEVICE_PACKAGES
:= $(BRCMFMAC_43602A1
) $(USB3_PACKAGES
)
390 NETGEAR_BOARD_ID
:= U12H315T00_NETGEAR
392 TARGET_DEVICES
+= netgear_r8000
394 define Device
/netgear_r8500
395 DEVICE_MODEL
:= R8500
396 DEVICE_PACKAGES
:= $(BRCMFMAC_4366B1
) $(USB3_PACKAGES
)
398 NETGEAR_BOARD_ID
:= U12H334T00_NETGEAR
401 TARGET_DEVICES
+= netgear_r8500
403 define Device
/smartrg_sr400ac
404 DEVICE_VENDOR
:= SmartRG
405 DEVICE_MODEL
:= SR400ac
406 DEVICE_PACKAGES
:= $(BRCMFMAC_43602A1
) $(USB3_PACKAGES
)
408 IMAGE
/trx
:= append-rootfs | trx-serial
409 KERNEL_INITRAMFS_SUFFIX
:= .bin
410 KERNEL_INITRAMFS
:= kernel-bin | append-dtb | lzma-d16
412 TARGET_DEVICES
+= smartrg_sr400ac
414 define Device
/phicomm_k3
415 DEVICE_VENDOR
:= PHICOMM
417 DEVICE_PACKAGES
:= $(BRCMFMAC_4366C0
) $(USB3_PACKAGES
)
420 TARGET_DEVICES
+= phicomm_k3
422 define Device
/tenda_ac9
423 DEVICE_VENDOR
:= Tenda
425 DEVICE_PACKAGES
:= $(B43
) $(USB2_PACKAGES
)
427 IMAGE
/trx
:= append-rootfs | trx-serial
429 TARGET_DEVICES
+= tenda_ac9
431 define Device
/tplink_archer-c5-v2
432 DEVICE_VENDOR
:= TP-Link
433 DEVICE_MODEL
:= Archer C5
435 DEVICE_PACKAGES
:= $(B43
) $(USB2_PACKAGES
)
437 IMAGE
/bin
:= append-rootfs | bcm53xx-tplink-safeloader
438 TPLINK_BOARD
:= ARCHER-C5-V2
441 TARGET_DEVICES
+= tplink_archer-c5-v2
443 define Device
/tplink_archer-c9-v1
444 DEVICE_VENDOR
:= TP-Link
445 DEVICE_MODEL
:= Archer C9
447 DEVICE_PACKAGES
:= $(USB3_PACKAGES
)
449 IMAGE
/bin
:= append-rootfs | bcm53xx-tplink-safeloader
450 TPLINK_BOARD
:= ARCHERC9
453 TARGET_DEVICES
+= tplink_archer-c9-v1
455 $(eval
$(call BuildImage
))