ramips: add support for D-Link COVR-X1860 A1
[openwrt/staging/hauke.git] / target / linux / ramips / image / mt7621.mk
index fc532966c8c1bfb22f954a8bd093e5f6c02a90df..72e0565c422a2a82db4ca657641df654acbe7cfd 100644 (file)
@@ -9,6 +9,14 @@ DEFAULT_SOC := mt7621
 
 DEVICE_VARS += ELECOM_HWNAME LINKSYS_HWNAME DLINK_HWID
 
+define Build/append-dlink-covr-metadata
+       echo -ne '{"supported_devices": "$(1)", "firmware": "' > $@metadata.tmp
+       $(MKHASH) md5 "$@" | head -c32 >> $@metadata.tmp
+       echo '"}' >> $@metadata.tmp
+       fwtool -I $@metadata.tmp $@
+       rm $@metadata.tmp
+endef
+
 define Build/arcadyan-trx
        echo -ne "hsqs" > $@.hsqs
        $(eval trx_magic=$(word 1,$(1)))
@@ -58,6 +66,37 @@ define Build/iodata-mstc-header
        )
 endef
 
+define Build/iodata-mstc-header2
+       $(eval model=$(word 1,$(1)))
+       $(eval model_id=$(word 2,$(1)))
+
+       ( \
+               fw_len_crc=$$(gzip -c $@ | tail -c 8 | \
+                       od -An -tx8 --endian little); \
+               printf "\x03\x1d\x61\x29\x07$(model)" | \
+                       dd bs=21 count=1 conv=sync 2>/dev/null; \
+               printf "0.00.000" | dd bs=16 count=1 conv=sync 2>/dev/null; \
+               printf "$$(echo $(REVISION) | cut -d- -f1 | head -c8)" | \
+                       dd bs=9 count=1 conv=sync 2>/dev/null; \
+               printf "$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)" | \
+                       dd bs=33 count=1 conv=sync 2>/dev/null; \
+               date -d "@$(SOURCE_DATE_EPOCH)" "+%F" | tr -d "\n" | \
+                       dd bs=15 count=1 conv=sync 2>/dev/null; \
+               printf "$$(echo $(model_id) | sed 's/../\\x&/g')" | \
+                       dd bs=8 count=1 conv=sync 2>/dev/null; \
+               printf "$$(echo $$fw_len_crc | sed 's/../\\x&/g')" | \
+                       dd bs=14 count=1 conv=sync 2>/dev/null; \
+               cat $@; \
+       ) > $@.new
+       ( \
+               header_crc="$$(head -c116 $@.new | gzip -c | tail -c8 | \
+                       od -An -tx4 -N4 --endian little)"; \
+               printf "$$(echo $$header_crc | sed 's/../\\x&/g')"; \
+       ) | dd of=$@.new bs=4 oflag=seek_bytes seek=110 conv=notrunc
+
+       mv $@.new $@
+endef
+
 define Build/znet-header
        $(eval version=$(word 1,$(1)))
        ( \
@@ -88,7 +127,7 @@ define Build/belkin-header
 
        ( \
                type_fw_date=$$(printf "01%02x%02x%02x" \
-                       $$(date -d "@$(SOURCE_DATE_EPOCH)" "+%y %m %d")); \
+                       $$(date -d "@$(SOURCE_DATE_EPOCH)" "+%-y %-m %-d")); \
                hw_fw_ver=$$(printf "%02x%02x%02x%02x" \
                        $(hw_ver) $$(echo $(fw_ver) | cut -d. -f-3 | tr . ' ')); \
                fw_len_crc=$$(gzip -c $@ | tail -c 8 | od -An -tx8 | tr -d ' \n'); \
@@ -148,6 +187,15 @@ define Device/dsa-migration
   DEVICE_COMPAT_MESSAGE := Config cannot be migrated from swconfig to DSA
 endef
 
+define Device/nand
+  $(Device/dsa-migration)
+  BLOCKSIZE := 128k
+  KERNEL_SIZE := 4096k
+  PAGESIZE := 2048
+  UBINIZE_OPTS := -E 5
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+
 define Device/adslr_g7
   $(Device/dsa-migration)
   IMAGE_SIZE := 16064k
@@ -169,6 +217,18 @@ define Device/afoundry_ew1200
 endef
 TARGET_DEVICES += afoundry_ew1200
 
+define Device/alfa-network_ax1800rm
+  $(Device/dsa-migration)
+  IMAGE_SIZE := 15488k
+  DEVICE_VENDOR := ALFA Network
+  DEVICE_MODEL := AX1800RM
+  DEVICE_PACKAGES := kmod-mt7915-firmware
+  KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  IMAGES += recovery.bin
+  IMAGE/recovery.bin := append-kernel | append-rootfs | pad-rootfs | check-size
+endef
+TARGET_DEVICES += alfa-network_ax1800rm
+
 define Device/alfa-network_quad-e4g
   $(Device/dsa-migration)
   IMAGE_SIZE := 16064k
@@ -181,17 +241,12 @@ endef
 TARGET_DEVICES += alfa-network_quad-e4g
 
 define Device/ampedwireless_ally_common
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := Amped Wireless
   DEVICE_PACKAGES := kmod-mt7615-firmware
   IMAGE_SIZE := 32768k
-  KERNEL_SIZE := 4096k
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
   KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma -n 'flashable-initramfs' |\
        edimax-header -s CSYS -m RN68 -f 0x001c0000 -S 0x01100000
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
 define Device/ampedwireless_ally-r1900k
@@ -217,7 +272,6 @@ define Device/arcadyan_we420223-99
   IMAGE_SIZE := 32128k
   KERNEL_SIZE := 4352k
   UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 64k
   PAGESIZE := 1
   SUBPAGESIZE := 1
   VID_HDR_OFFSET := 64
@@ -234,6 +288,7 @@ TARGET_DEVICES += arcadyan_we420223-99
 
 define Device/asiarf_ap7621-001
   $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
   IMAGE_SIZE := 16000k
   DEVICE_VENDOR := AsiaRF
   DEVICE_MODEL := AP7621-001
@@ -244,6 +299,7 @@ TARGET_DEVICES += asiarf_ap7621-001
 
 define Device/asiarf_ap7621-nv1
   $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
   IMAGE_SIZE := 16000k
   DEVICE_VENDOR := AsiaRF
   DEVICE_MODEL := AP7621-NV1
@@ -258,7 +314,6 @@ define Device/asus_rp-ac56
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RP-AC56
   IMAGE_SIZE := 16000k
-  BLOCKSIZE := 64k
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 \
        kmod-i2c-ralink kmod-sound-mt7620 -uboot-envtools
   IMAGES += factory.bin
@@ -297,16 +352,11 @@ endef
 TARGET_DEVICES += asus_rt-ac57u-v1
 
 define Device/asus_rt-ac65p
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RT-AC65P
   IMAGE_SIZE := 51200k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615-firmware
@@ -314,16 +364,11 @@ endef
 TARGET_DEVICES += asus_rt-ac65p
 
 define Device/asus_rt-ac85p
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RT-AC85P
   IMAGE_SIZE := 51200k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615-firmware
@@ -343,18 +388,13 @@ endef
 TARGET_DEVICES += asus_rt-n56u-b1
 
 define Device/asus_rt-ax53u
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RT-AX53U
   DEVICE_ALT0_VENDOR := ASUS
   DEVICE_ALT0_MODEL := RT-AX1800U
   IMAGE_SIZE := 51200k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES := kmod-mt7915-firmware kmod-usb3 kmod-usb-ledtrig-usbport
@@ -362,7 +402,7 @@ endef
 TARGET_DEVICES += asus_rt-ax53u
 
 define Device/asus_rt-ax54
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RT-AX54
   DEVICE_ALT0_VENDOR := ASUS
@@ -372,12 +412,7 @@ define Device/asus_rt-ax54
   DEVICE_ALT2_VENDOR := ASUS
   DEVICE_ALT2_MODEL := RT-AX1800S
   IMAGE_SIZE := 51200k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES := kmod-mt7915-firmware
@@ -385,22 +420,18 @@ endef
 TARGET_DEVICES += asus_rt-ax54
 
 define Device/beeline_smartbox-flash
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := Beeline
   DEVICE_MODEL := SmartBox Flash
   IMAGE_SIZE := 32768k
   KERNEL_SIZE := 4352k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
        uImage none | arcadyan-trx 0x746f435d | pad-to $$(KERNEL_SIZE)
   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
        uImage none
   IMAGES += factory.trx
   IMAGE/factory.trx := append-kernel | append-ubi | check-size
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615-firmware uencrypt-mbedtls
 endef
 TARGET_DEVICES += beeline_smartbox-flash
@@ -418,6 +449,23 @@ define Device/beeline_smartbox-giga
 endef
 TARGET_DEVICES += beeline_smartbox-giga
 
+define Device/beeline_smartbox-pro
+  $(Device/sercomm_s1500)
+  DEVICE_VENDOR := Beeline
+  DEVICE_MODEL := SmartBox PRO
+  DEVICE_ALT0_VENDOR := Sercomm
+  DEVICE_ALT0_MODEL := S1500 AWI
+  IMAGE_SIZE := 34816k
+  IMAGE/factory.img := append-kernel | sercomm-kernel-factory | \
+       sercomm-reset-slot1-chksum | append-ubi | check-size | \
+       sercomm-factory-cqr | sercomm-append-tail | sercomm-mkhash
+  SERCOMM_HWID := AWI
+  SERCOMM_HWVER := 10000
+  SERCOMM_ROOTFS2_OFFSET := 0x3d00000
+  SERCOMM_SWVER := 2020
+endef
+TARGET_DEVICES += beeline_smartbox-pro
+
 define Device/beeline_smartbox-turbo
   $(Device/sercomm_dxx)
   IMAGE_SIZE := 32768k
@@ -430,22 +478,29 @@ define Device/beeline_smartbox-turbo
 endef
 TARGET_DEVICES += beeline_smartbox-turbo
 
+define Device/beeline_smartbox-turbo-plus
+  $(Device/sercomm_cxx)
+  IMAGE_SIZE := 32768k
+  SERCOMM_HWID := CQR
+  SERCOMM_HWVER := 10000
+  SERCOMM_SWVER := 2010
+  DEVICE_VENDOR := Beeline
+  DEVICE_MODEL := SmartBox TURBO+
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3
+endef
+TARGET_DEVICES += beeline_smartbox-turbo-plus
+
 define Device/belkin_rt1800
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
+  $(Device/nand)
   IMAGE_SIZE := 49152k
   DEVICE_VENDOR := Belkin
   DEVICE_MODEL := RT1800
   DEVICE_PACKAGES := kmod-mt7915-firmware kmod-usb3
-  UBINIZE_OPTS := -E 5
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
        append-squashfs4-fakeroot
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \
        append-ubi | check-size | belkin-header RT18 1 9.9.9
 endef
@@ -497,6 +552,35 @@ define Device/bolt_arion
 endef
 TARGET_DEVICES += bolt_arion
 
+define Device/comfast_cf-e390ax
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 15808k
+  DEVICE_VENDOR := ComFast
+  DEVICE_MODEL := CF-E390AX
+  DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
+  IMAGES += factory.bin
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
+       check-size | append-metadata
+  IMAGE/factory.bin := append-kernel | append-rootfs | pad-rootfs | check-size
+endef
+TARGET_DEVICES += comfast_cf-e390ax
+
+define Device/comfast_cf-ew72-v2
+    $(Device/dsa-migration)
+    $(Device/uimage-lzma-loader)
+    IMAGE_SIZE := 15808k
+    DEVICE_VENDOR := ComFast
+    DEVICE_MODEL := CF-EW72 V2
+    DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
+        -uboot-envtools
+    IMAGES += factory.bin
+    IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
+        check-size | append-metadata
+    IMAGE/factory.bin := append-kernel | append-rootfs | pad-rootfs | check-size
+endef
+TARGET_DEVICES += comfast_cf-ew72-v2
+
 define Device/cudy_m1800
   $(Device/dsa-migration)
   DEVICE_VENDOR := Cudy
@@ -565,12 +649,34 @@ define Device/cudy_x6-v2
 endef
 TARGET_DEVICES += cudy_x6-v2
 
-define Device/dlink_dap-1620-b1
+define Device/dlink_covr-x1860-a1
+  $(Device/dsa-migration)
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL_SIZE := 8192k
+  IMAGE_SIZE := 40960k
+  DEVICE_VENDOR := D-Link
+  DEVICE_MODEL := COVR-X1860
+  DEVICE_VARIANT := A1
+  DEVICE_PACKAGES := kmod-mt7915-firmware
+  UBINIZE_OPTS := -E 5
+  KERNEL_LOADADDR := 0x82000000
+  KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
+       fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
+       append-squashfs4-fakeroot
+  IMAGES += factory.bin recovery.bin
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  IMAGE/recovery.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \
+       append-ubi | check-size
+  IMAGE/factory.bin := $$(IMAGE/recovery.bin) | \
+       append-dlink-covr-metadata $$(DEVICE_MODEL) | \
+       dlink-sge-image $$(DEVICE_MODEL)
+endef
+TARGET_DEVICES += dlink_covr-x1860-a1
+
+define Device/dlink_dxx-1xx0-x1
   DEVICE_VENDOR := D-Link
-  DEVICE_MODEL := DAP-1620
-  DEVICE_VARIANT := B1
   DEVICE_PACKAGES := kmod-mt7615-firmware rssileds
-  DLINK_HWID := MT76XMT7621-RP-PR2475-NA
   IMAGE_SIZE := 16064k
   IMAGES += factory.bin
   IMAGE/factory.bin := $$(sysupgrade_bin) | \
@@ -579,23 +685,26 @@ define Device/dlink_dap-1620-b1
     append-string $$(DLINK_HWID) | \
     check-size
 endef
+
+define Device/dlink_dap-1620-b1
+  $(Device/dlink_dxx-1xx0-x1)
+  DEVICE_MODEL := DAP-1620
+  DEVICE_VARIANT := B1
+  DLINK_HWID := MT76XMT7621-RP-PR2475-NA
+endef
 TARGET_DEVICES += dlink_dap-1620-b1
 
 define Device/dlink_dap-x1860-a1
-  $(Device/dsa-migration)
+  $(Device/nand)
   IMAGE_SIZE := 53248k
   DEVICE_VENDOR := D-Link
   DEVICE_MODEL := DAP-X1860
   DEVICE_VARIANT := A1
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   KERNEL_SIZE := 8192k
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size | elx-header 011b0060 8844A2D168B45A2D
   DEVICE_PACKAGES := kmod-mt7915-firmware rssileds -uboot-envtools
@@ -608,10 +717,9 @@ define Device/dlink_dir-8xx-a1
   DEVICE_VENDOR := D-Link
   DEVICE_PACKAGES := kmod-mt7615-firmware -uboot-envtools
   KERNEL := $$(KERNEL) | uimage-sgehdr
-  IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
-       check-size | append-metadata
-  IMAGE/factory.bin := append-kernel | append-rootfs | check-size
+  IMAGES += recovery.bin factory.bin
+  IMAGE/recovery.bin := append-kernel | append-rootfs | check-size
+  IMAGE/factory.bin := $$(IMAGE/recovery.bin) | dlink-sge-image $$$$(DEVICE_MODEL)
 endef
 
 define Device/dlink_dir-8xx-r1
@@ -625,19 +733,14 @@ define Device/dlink_dir-8xx-r1
 endef
 
 define Device/dlink_dir-xx60-a1
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
+  $(Device/nand)
   IMAGE_SIZE := 40960k
-  UBINIZE_OPTS := -E 5
   DEVICE_VENDOR := D-Link
   DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 \
        kmod-usb-ledtrig-usbport -uboot-envtools
   KERNEL := $$(KERNEL) | uimage-sgehdr
-  IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
+  IMAGES += recovery.bin
+  IMAGE/recovery.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
 endef
 
@@ -689,6 +792,8 @@ define Device/dlink_dir-853-a3
   $(Device/dlink_dir-xx60-a1)
   DEVICE_MODEL := DIR-853
   DEVICE_VARIANT := A3
+  IMAGES += factory.bin
+  IMAGE/factory.bin := $$(IMAGE/recovery.bin) | dlink-sge-image $$(DEVICE_MODEL)
 endef
 TARGET_DEVICES += dlink_dir-853-a3
 
@@ -759,6 +864,14 @@ define Device/dlink_dir-882-r1
 endef
 TARGET_DEVICES += dlink_dir-882-r1
 
+define Device/dlink_dra-1360-a1
+  $(Device/dlink_dxx-1xx0-x1)
+  DEVICE_MODEL := DRA-1360
+  DEVICE_VARIANT := A1
+  DLINK_HWID := MT76XMT7621-RP-RA1360-NA
+endef
+TARGET_DEVICES += dlink_dra-1360-a1
+
 define Device/dual-q_h721
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
@@ -774,8 +887,8 @@ define Device/d-team_newifi-d2
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
   IMAGE_SIZE := 32448k
-  DEVICE_VENDOR := Newifi
-  DEVICE_MODEL := D2
+  DEVICE_VENDOR := D-Team
+  DEVICE_MODEL := Newifi D2
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 \
        kmod-usb-ledtrig-usbport -uboot-envtools
 endef
@@ -1008,7 +1121,7 @@ define Device/gnubee_gb-pc1
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := GnuBee
-  DEVICE_MODEL := Personal Cloud One
+  DEVICE_MODEL := GB-PC1
   DEVICE_PACKAGES := kmod-ata-ahci kmod-usb3 kmod-sdhci-mt7620 \
        -wpad-basic-mbedtls -uboot-envtools
   IMAGE_SIZE := 32448k
@@ -1019,7 +1132,7 @@ define Device/gnubee_gb-pc2
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := GnuBee
-  DEVICE_MODEL := Personal Cloud Two
+  DEVICE_MODEL := GB-PC2
   DEVICE_PACKAGES := kmod-ata-ahci kmod-usb3 kmod-sdhci-mt7620 \
        -wpad-basic-mbedtls -uboot-envtools
   IMAGE_SIZE := 32448k
@@ -1037,17 +1150,13 @@ endef
 TARGET_DEVICES += hanyang_hyc-g920
 
 define Device/h3c_tx180x
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
+  $(Device/nand)
   KERNEL_SIZE := 8192k
   IMAGE_SIZE := 120832k
-  UBINIZE_OPTS := -E 5
   KERNEL_LOADADDR := 0x82000000
   KERNEL_INITRAMFS := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
   KERNEL := $$(KERNEL_INITRAMFS) | h3c-blank-header
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_VENDOR := H3C
   DEVICE_PACKAGES := kmod-mt7915-firmware
 endef
@@ -1071,12 +1180,8 @@ endef
 TARGET_DEVICES += h3c_tx1806
 
 define Device/haier-sim_wr1800k
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
+  $(Device/nand)
   IMAGE_SIZE := 125440k
-  UBINIZE_OPTS := -E 5
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
@@ -1085,7 +1190,6 @@ ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
   ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \
        haier-sim_wr1800k-factory
 endif
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_PACKAGES := kmod-mt7915-firmware
 endef
 
@@ -1107,15 +1211,10 @@ endef
 TARGET_DEVICES += hilink_hlk-7621a-evb
 
 define Device/hiwifi_hc5962
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
-  UBINIZE_OPTS := -E 5
   IMAGE_SIZE := 32768k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_VENDOR := HiWiFi
@@ -1169,16 +1268,11 @@ endef
 TARGET_DEVICES += iodata_wn-ax1167gr
 
 define Device/iodata_nand
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := I-O DATA
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 51200k
   LOADER_TYPE := bin
   KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | lzma | uImage lzma
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
 # The OEM webinterface expects an kernel with initramfs which has the uImage
@@ -1205,6 +1299,27 @@ define Device/iodata_wn-ax2033gr
 endef
 TARGET_DEVICES += iodata_wn-ax2033gr
 
+define Device/iodata_wn-deax1800gr
+  $(Device/dsa-migration)
+  DEVICE_VENDOR := I-O DATA
+  DEVICE_MODEL := WN-DEAX1800GR
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  KERNEL_SIZE := 6144k
+  IMAGE_SIZE := 47104k
+  UBINIZE_OPTS := -E 5
+  KERNEL_LOADADDR := 0x82000000
+  KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
+       fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  ARTIFACTS := initramfs-factory.bin
+  ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \
+       check-size | xor-image -p 29944a25120984c2 -x | \
+       iodata-mstc-header2 WN-DEAX1800GR 00021003
+  DEVICE_PACKAGES := kmod-mt7915-firmware
+endef
+TARGET_DEVICES += iodata_wn-deax1800gr
+
 define Device/iodata_wn-dx1167r
   $(Device/iodata_nand)
   DEVICE_MODEL := WN-DX1167R
@@ -1279,16 +1394,11 @@ endef
 TARGET_DEVICES += iptime_a3004ns-dual
 
 define Device/iptime_a3004t
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   FILESYSTEMS := squashfs
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 129280k
   UIMAGE_NAME := a3004t
-  UBINIZE_OPTS := -E 5
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_VENDOR := ipTIME
   DEVICE_MODEL := A3004T
   DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 -uboot-envtools
@@ -1328,17 +1438,12 @@ endef
 TARGET_DEVICES += iptime_a8004t
 
 define Device/iptime_ax2004m
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
+  $(Device/nand)
   IMAGE_SIZE := 121344k
-  UBINIZE_OPTS := -E 5
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
   IMAGES += recovery.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/recovery.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size | iptime-crc32 ax2004m
   DEVICE_VENDOR := ipTIME
@@ -1348,14 +1453,9 @@ endef
 TARGET_DEVICES += iptime_ax2004m
 
 define Device/iptime_t5004
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
+  $(Device/nand)
   IMAGE_SIZE := 129280k
-  UBINIZE_OPTS := -E 5
   UIMAGE_NAME := t5004
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_VENDOR := ipTIME
   DEVICE_MODEL := T5004
   DEVICE_PACKAGES := -wpad-basic-mbedtls -uboot-envtools
@@ -1376,15 +1476,10 @@ endef
 TARGET_DEVICES += jcg_jhr-ac876m
 
 define Device/jcg_q20
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 91136k
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_VENDOR := JCG
@@ -1409,7 +1504,6 @@ TARGET_DEVICES += jcg_y2
 define Device/keenetic_kn-3010
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 64k
   IMAGE_SIZE := 31488k
   DEVICE_VENDOR := Keenetic
   DEVICE_MODEL := KN-3010
@@ -1425,8 +1519,8 @@ define Device/lenovo_newifi-d1
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
   IMAGE_SIZE := 32448k
-  DEVICE_VENDOR := Newifi
-  DEVICE_MODEL := D1
+  DEVICE_VENDOR := Lenovo
+  DEVICE_MODEL := Newifi D1
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 kmod-sdhci-mt7620 \
        kmod-usb-ledtrig-usbport -uboot-envtools
   SUPPORTED_DEVICES += newifi-d1
@@ -1434,18 +1528,13 @@ endef
 TARGET_DEVICES += lenovo_newifi-d1
 
 define Device/linksys_e5600
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 26624k
   DEVICE_VENDOR := Linksys
   DEVICE_MODEL := E5600
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap
-  UBINIZE_OPTS := -E 5
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \
        append-ubi | check-size | gemtek-trailer
 endef
@@ -1461,17 +1550,12 @@ endef
 TARGET_DEVICES += linksys_e7350
 
 define Device/linksys_ea7xxx
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 36864k
   DEVICE_VENDOR := Linksys
   DEVICE_PACKAGES := kmod-usb3 kmod-mt7615-firmware
-  UBINIZE_OPTS := -E 5
   IMAGES := sysupgrade.bin factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | check-size | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | \
        append-ubi | check-size | linksys-image type=$$$$(LINKSYS_HWNAME)
 endef
@@ -1558,7 +1642,6 @@ TARGET_DEVICES += mediatek_ap-mt7621a-v60
 
 define Device/mediatek_mt7621-eval-board
   $(Device/dsa-migration)
-  BLOCKSIZE := 64k
   IMAGE_SIZE := 15104k
   DEVICE_VENDOR := MediaTek
   DEVICE_MODEL := MT7621 EVB
@@ -1567,10 +1650,21 @@ define Device/mediatek_mt7621-eval-board
 endef
 TARGET_DEVICES += mediatek_mt7621-eval-board
 
+define Device/meig_slt866
+  $(Device/dsa-migration)
+  IMAGE_SIZE := 15104k
+  DEVICE_VENDOR := MeiG
+  DEVICE_MODEL := SLT866
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
+       kmod-usb-net-qmi-wwan kmod-usb-serial-option kmod-usb3 \
+       kmod-usb-net-rndis
+endef
+TARGET_DEVICES += meig_slt866
+
 define Device/mercusys_mr70x-v1
   $(Device/dsa-migration)
   $(Device/tplink-safeloader)
-  DEVICE_VENDOR := Mercusys
+  DEVICE_VENDOR := MERCUSYS
   DEVICE_MODEL := MR70X
   DEVICE_VARIANT := v1
   DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
@@ -1583,7 +1677,6 @@ TARGET_DEVICES += mercusys_mr70x-v1
 define Device/MikroTik
   $(Device/dsa-migration)
   DEVICE_VENDOR := MikroTik
-  BLOCKSIZE := 64k
   IMAGE_SIZE := 16128k
   DEVICE_PACKAGES := kmod-usb3 -uboot-envtools
   KERNEL_NAME := vmlinuz
@@ -1656,26 +1749,48 @@ endef
 TARGET_DEVICES += mtc_wr1201
 
 define Device/mts_wg430223
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := MTS
   DEVICE_MODEL := WG430223
   IMAGE_SIZE := 32768k
   KERNEL_SIZE := 4352k
-  UBINIZE_OPTS := -E 5
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \
        uImage none | arcadyan-trx 0x53485231 | pad-to $$(KERNEL_SIZE)
   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \
        uImage none
   IMAGES += factory.trx
   IMAGE/factory.trx := append-kernel | append-ubi | check-size
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_PACKAGES := kmod-mt7615-firmware uencrypt-mbedtls
 endef
 TARGET_DEVICES += mts_wg430223
 
+define Device/netgear_eax12
+  $(Device/nand)
+  DEVICE_VENDOR := NETGEAR
+  DEVICE_MODEL := EAX12
+  DEVICE_ALT0_VENDOR := NETGEAR
+  DEVICE_ALT0_MODEL := EAX11
+  DEVICE_ALT0_VARIANT := v2
+  DEVICE_ALT1_VENDOR := NETGEAR
+  DEVICE_ALT1_MODEL := EAX15
+  DEVICE_ALT1_VARIANT := v2
+  DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
+  NETGEAR_ENC_MODEL := EAX12
+  NETGEAR_ENC_REGION := US
+  NETGEAR_ENC_HW_ID_LIST := 1010000004540000_NETGEAR
+  NETGEAR_ENC_MODEL_LIST := EAX12;EAX11v2;EAX15v2
+  IMAGE_SIZE := 57344k
+  KERNEL_LOADADDR := 0x82000000
+  KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
+       fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
+       append-squashfs4-fakeroot
+  IMAGES += factory.img
+  IMAGE/factory.img := append-kernel | pad-to $$(KERNEL_SIZE) | \
+       append-ubi | check-size | netgear-encrypted-factory
+endef
+TARGET_DEVICES += netgear_eax12
+
 define Device/netgear_ex6150
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
@@ -1690,17 +1805,12 @@ endef
 TARGET_DEVICES += netgear_ex6150
 
 define Device/netgear_sercomm_nand
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
-  UBINIZE_OPTS := -E 5
   IMAGES += factory.img kernel.bin rootfs.bin
   IMAGE/factory.img := pad-extra 2048k | append-kernel | pad-to 6144k | \
        append-ubi | pad-to $$$$(BLOCKSIZE) | sercom-footer | pad-to 128 | \
        zip $$$$(SERCOMM_HWNAME).bin | sercom-seal
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/kernel.bin := append-kernel
   IMAGE/rootfs.bin := append-ubi | check-size
   DEVICE_VENDOR := NETGEAR
@@ -1851,17 +1961,13 @@ endef
 TARGET_DEVICES += netgear_wac124
 
 define Device/netgear_wax202
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := NETGEAR
   DEVICE_MODEL := WAX202
   DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
   NETGEAR_ENC_MODEL := WAX202
   NETGEAR_ENC_REGION := US
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
   IMAGE_SIZE := 38912k
-  KERNEL_SIZE := 4096k
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
@@ -1869,7 +1975,6 @@ define Device/netgear_wax202
   IMAGES += factory.img
   IMAGE/factory.img := append-kernel | pad-to $$(KERNEL_SIZE) | \
        append-ubi | check-size | netgear-encrypted-factory
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += netgear_wax202
 
@@ -1892,18 +1997,13 @@ endef
 TARGET_DEVICES += netgear_wndr3700-v5
 
 define Device/netis_wf2881
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   FILESYSTEMS := squashfs
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 129280k
-  UBINIZE_OPTS := -E 5
   UIMAGE_NAME := WF2881_0.0.00
   KERNEL_INITRAMFS := $$(KERNEL) | netis-tail WF2881
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_VENDOR := NETIS
@@ -1947,14 +2047,9 @@ endef
 TARGET_DEVICES += planex_vr500
 
 define Device/raisecom_msg1500-x-00
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 129280k
-  UBINIZE_OPTS := -E 5
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   DEVICE_VENDOR := RAISECOM
   DEVICE_MODEL := MSG1500
   DEVICE_VARIANT := X.00
@@ -2001,13 +2096,9 @@ endef
 TARGET_DEVICES += samknows_whitebox-v8
 
 define Device/sercomm_na502
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   IMAGE_SIZE := 20480k
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-  UBINIZE_OPTS := -E 5
-  KERNEL_SIZE := 4096k
   DEVICE_VENDOR := SERCOMM
   DEVICE_MODEL := NA502
   DEVICE_PACKAGES := kmod-mt76x2 kmod-mt7603 kmod-usb3 -uboot-envtools
@@ -2015,13 +2106,8 @@ endef
 TARGET_DEVICES += sercomm_na502
 
 define Device/sercomm_na502s
-  $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
+  $(Device/nand)
   IMAGE_SIZE := 20971520
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
-  UBINIZE_OPTS := -E 5
-  KERNEL_SIZE := 4096k
   DEVICE_VENDOR := SERCOMM
   DEVICE_MODEL := NA502S
   DEVICE_PACKAGES := kmod-mt76x2 kmod-mt7603 kmod-usb3 kmod-usb-serial \
@@ -2088,7 +2174,7 @@ define Device/telco-electronics_x1
   IMAGE_SIZE := 16064k
   DEVICE_VENDOR := Telco Electronics
   DEVICE_MODEL := X1
-  DEVICE_PACKAGES := kmod-usb3 kmod-mt76 -uboot-envtools
+  DEVICE_PACKAGES := kmod-usb3 kmod-mt7603 kmod-mt76x2 -uboot-envtools
 endef
 TARGET_DEVICES += telco-electronics_x1
 
@@ -2135,6 +2221,16 @@ define Device/totolink_x5000r
 endef
 TARGET_DEVICES += totolink_x5000r
 
+define Device/tozed_zlt-s12-pro
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 16064k
+  DEVICE_VENDOR := TOZED
+  DEVICE_MODEL := ZLT S12 PRO
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 comgt-ncm -uboot-envtools
+endef
+TARGET_DEVICES += tozed_zlt-s12-pro
+
 define Device/tplink_archer-ax23-v1
   $(Device/dsa-migration)
   $(Device/tplink-safeloader)
@@ -2213,6 +2309,19 @@ define Device/tplink_eap235-wall-v1
 endef
 TARGET_DEVICES += tplink_eap235-wall-v1
 
+define Device/tplink_eap613-v1
+  $(Device/dsa-migration)
+  $(Device/tplink-safeloader)
+  DEVICE_MODEL := EAP613
+  DEVICE_VARIANT := v1
+  DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
+  TPLINK_BOARD_ID := EAP610-V3
+  KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | pad-to 64k
+  KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
+  IMAGE_SIZE := 13248k
+endef
+TARGET_DEVICES += tplink_eap613-v1
+
 define Device/tplink_eap615-wall-v1
   $(Device/dsa-migration)
   $(Device/tplink-safeloader)
@@ -2227,12 +2336,8 @@ endef
 TARGET_DEVICES += tplink_eap615-wall-v1
 
 define Device/tplink_ec330-g5u-v1
-  $(Device/dsa-migration)
+  $(Device/nand)
   LOADER := bin
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
-  KERNEL_SIZE := 4096k
   IMAGE_SIZE := 49152k
   DEVICE_VENDOR := TP-Link
   DEVICE_MODEL := EC330-G5u
@@ -2249,24 +2354,19 @@ define Device/tplink_ec330-g5u-v1
   IMAGES += factory.bin
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | \
        append-ubi | check-size
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata | check-size
 endef
 TARGET_DEVICES += tplink_ec330-g5u-v1
 
 define Device/tplink_er605-v2
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := TP-Link
   DEVICE_MODEL := ER605
   DEVICE_VARIANT := v2
   DEVICE_PACKAGES := -wpad-basic-mbedtls kmod-usb3 -uboot-envtools
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
   KERNEL_IN_UBI := 1
   KERNEL_LOADADDR := 0x82000000
   KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
   IMAGES += sysupgrade.tar
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE_SIZE := 127744k
 endef
 TARGET_DEVICES += tplink_er605-v2
@@ -2279,6 +2379,9 @@ define Device/tplink_mr600-v2-eu
   TPLINK_FLASHLAYOUT := 16Mltq
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615e kmod-mt7663-firmware-ap \
                kmod-usb-net-qmi-wwan uqmi kmod-usb3 -uboot-envtools
+  IMAGE/factory.bin := tplink-v2-image -e -a 0x10000
+  IMAGE/sysupgrade.bin := tplink-v2-image -s -e -a 0x10000 | check-size | \
+       append-metadata
   KERNEL := $(KERNEL_DTB) | uImage lzma
   KERNEL_INITRAMFS := $$(KERNEL) | tplink-v2-header
   TPLINK_BOARD_ID := MR600-V2-EU
@@ -2490,7 +2593,6 @@ TARGET_DEVICES += wavlink_wl-wn533a8
 
 define Device/wavlink_ws-wn572hp3-4g
   $(Device/dsa-migration)
-  BLOCKSIZE := 64k
   DEVICE_VENDOR := Wavlink
   DEVICE_MODEL := WS-WN572HP3
   DEVICE_VARIANT := 4G
@@ -2505,6 +2607,20 @@ define Device/wavlink_ws-wn572hp3-4g
 endef
 TARGET_DEVICES += wavlink_ws-wn572hp3-4g
 
+
+define Device/wavlink_wl-wn573hx1
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 15808k
+  DEVICE_VENDOR := Wavlink
+  DEVICE_MODEL := WL-WN573HX1
+  DEVICE_PACKAGES := kmod-mt7915-firmware -uboot-envtools
+  IMAGES += factory.bin
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | \
+       check-size | append-metadata
+  IMAGE/factory.bin := append-kernel | append-rootfs | pad-rootfs | check-size
+endef
+TARGET_DEVICES += wavlink_wl-wn573hx1
+
 define Device/wevo_11acnas
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
@@ -2532,6 +2648,24 @@ define Device/wevo_w2914ns-v2
 endef
 TARGET_DEVICES += wevo_w2914ns-v2
 
+define Device/wifire_s1500-nbn
+  $(Device/sercomm_s1500)
+  DEVICE_VENDOR := WiFire
+  DEVICE_MODEL := S1500.NBN
+  DEVICE_ALT0_VENDOR := Sercomm
+  DEVICE_ALT0_MODEL := S1500 BUC
+  IMAGE_SIZE := 51200k
+  IMAGE/factory.img := append-kernel | sercomm-kernel-factory | \
+       sercomm-reset-slot1-chksum | append-ubi | check-size | \
+       sercomm-factory-cqr | sercomm-fix-buc-pid | sercomm-mkhash | \
+       sercomm-crypto
+  SERCOMM_HWID := BUC
+  SERCOMM_HWVER := 10000
+  SERCOMM_ROOTFS2_OFFSET := 0x4d00000
+  SERCOMM_SWVER := 2015
+endef
+TARGET_DEVICES += wifire_s1500-nbn
+
 define Device/winstars_ws-wn583a6
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
@@ -2546,17 +2680,12 @@ endef
 TARGET_DEVICES += winstars_ws-wn583a6
 
 define Device/xiaomi_nand_separate
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := Xiaomi
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
-  UBINIZE_OPTS := -E 5
   IMAGES += kernel1.bin rootfs0.bin
   IMAGE/kernel1.bin := append-kernel
   IMAGE/rootfs0.bin := append-ubi | check-size
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
 define Device/xiaomi_mi-router-3g
@@ -2582,17 +2711,12 @@ endef
 TARGET_DEVICES += xiaomi_mi-router-3g-v2
 
 define Device/xiaomi_mi-router-3-pro
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE:= 4096k
-  UBINIZE_OPTS := -E 5
   IMAGE_SIZE := 255488k
   DEVICE_VENDOR := Xiaomi
   DEVICE_MODEL := Mi Router 3 Pro
   IMAGES += factory.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport
@@ -2640,16 +2764,11 @@ endef
 TARGET_DEVICES += xiaomi_mi-router-ac2100
 
 define Device/xiaomi_mi-router-cr660x
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
   DEVICE_VENDOR := Xiaomi
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
-  UBINIZE_OPTS := -E 5
   IMAGE_SIZE := 128512k
   IMAGES += firmware.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
   IMAGE/firmware.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
   DEVICE_PACKAGES += kmod-mt7915-firmware
@@ -2826,6 +2945,18 @@ define Device/zbtlink_zbt-wg1608-16m
 endef
 TARGET_DEVICES += zbtlink_zbt-wg1608-16m
 
+define Device/zbtlink_zbt-wg1608-32m
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 32448k
+  DEVICE_VENDOR := Zbtlink
+  DEVICE_MODEL := ZBT-WG1608
+  DEVICE_VARIANT := 32M
+  DEVICE_PACKAGES := kmod-sdhci-mt7620 kmod-mt7603 kmod-mt7615e \
+       kmod-mt7663-firmware-ap kmod-usb3 kmod-usb-ledtrig-usbport
+endef
+TARGET_DEVICES += zbtlink_zbt-wg1608-32m
+
 define Device/zbtlink_zbt-wg2626
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
@@ -2875,12 +3006,10 @@ endef
 TARGET_DEVICES += zio_freezio
 
 define Device/zyxel_lte3301-plus
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
+  $(Device/nand)
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := LTE3301-PLUS
+  KERNEL_SIZE := 31488k
   DEVICE_PACKAGES := kmod-mt7615-firmware kmod-usb3 kmod-usb-ledtrig-usbport \
        kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi
   KERNEL := $(KERNEL_DTB) | uImage lzma | \
@@ -2888,38 +3017,45 @@ define Device/zyxel_lte3301-plus
   KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma | \
        zytrx-header $$(DEVICE_MODEL) 9.99(ABQU.1)$$(VERSION_DIST)-recovery
   KERNEL_INITRAMFS_SUFFIX := -recovery.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += zyxel_lte3301-plus
 
+define Device/zyxel_lte5398-m904
+  $(Device/nand)
+  DEVICE_VENDOR := ZyXEL
+  DEVICE_MODEL := LTE5398-M904
+  KERNEL_SIZE := 31488k
+  DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware kmod-usb3 uqmi \
+  kmod-usb-net-qmi-wwan kmod-usb-serial-option kmod-usb-ledtrig-usbport
+  KERNEL := $(KERNEL_DTB) | uImage lzma | \
+       zytrx-header $$(DEVICE_MODEL) $$(VERSION_DIST)-$$(REVISION)
+  KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma | \
+       zytrx-header $$(DEVICE_MODEL) 9.99(ABQU.1)$$(VERSION_DIST)-recovery
+  KERNEL_INITRAMFS_SUFFIX := -recovery.bin
+endef
+TARGET_DEVICES += zyxel_lte5398-m904
+
 define Device/zyxel_nr7101
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  UBINIZE_OPTS := -E 5
+  $(Device/nand)
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := NR7101
+  KERNEL_SIZE := 31488k
   DEVICE_PACKAGES := kmod-mt7603 kmod-usb3 kmod-usb-net-qmi-wwan kmod-usb-serial-option uqmi
   KERNEL := $(KERNEL_DTB) | uImage lzma | zytrx-header $$(DEVICE_MODEL) $$(VERSION_DIST)-$$(REVISION)
   KERNEL_INITRAMFS := $(KERNEL_DTB) | uImage lzma | zytrx-header $$(DEVICE_MODEL) 9.99(ABUV.9)$$(VERSION_DIST)-recovery
   KERNEL_INITRAMFS_SUFFIX := -recovery.bin
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += zyxel_nr7101
 
 define Device/zyxel_nwa-ax
-  $(Device/dsa-migration)
+  $(Device/nand)
   DEVICE_VENDOR := ZyXEL
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
   KERNEL_SIZE := 8192k
-  UBINIZE_OPTS := -E 5
   DEVICE_PACKAGES := kmod-mt7915-firmware zyxel-bootconfig
   KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
   IMAGES += factory.bin ramboot-factory.bin
   IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | zyxel-nwa-fit
   IMAGE/ramboot-factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 
 define Device/zyxel_nwa50ax
@@ -2935,33 +3071,24 @@ endef
 TARGET_DEVICES += zyxel_nwa55axe
 
 define Device/zyxel_wap6805
-  $(Device/dsa-migration)
+  $(Device/nand)
   $(Device/uimage-lzma-loader)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
-  KERNEL_SIZE := 4096k
-  UBINIZE_OPTS := -E 5
   IMAGE_SIZE := 32448k
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := WAP6805
   DEVICE_PACKAGES := kmod-mt7603 kmod-mt7621-qtn-rgmii -uboot-envtools
   KERNEL := $$(KERNEL/lzma-loader) | uImage none | uimage-padhdr 160
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += zyxel_wap6805
 
 define Device/zyxel_wsm20
-  $(Device/dsa-migration)
-  BLOCKSIZE := 128k
-  PAGESIZE := 2048
+  $(Device/nand)
   KERNEL_SIZE := 8192k
   IMAGE_SIZE := 41943040
-  UBINIZE_OPTS := -E 5
   DEVICE_VENDOR := ZyXEL
   DEVICE_MODEL := WSM20
   DEVICE_PACKAGES := kmod-mt7915-firmware
   KERNEL := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0
   KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | znet-header V1.00(ABZF.0)C0
-  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
 endef
 TARGET_DEVICES += zyxel_wsm20