ramips: add subtarget for mt7688
[openwrt/staging/chunkeey.git] / target / linux / ramips / image / Makefile
index 02485ba..409ff26 100644 (file)
@@ -22,21 +22,52 @@ define Image/Build/Initramfs
        $(call Image/Build/Profile/$(PROFILE),initramfs)
 endef
 
-ifeq ($(CONFIG_SOC_RT288X),y)
-define kernel_entry
--a 0x88000000 -e 0x88000000
+DEVICE_VARS += DTS
+
+loadaddr-y := 0x80000000
+loadaddr-$(CONFIG_TARGET_ramips_rt288x) := 0x88000000
+loadaddr-$(CONFIG_TARGET_ramips_mt7621) := 0x80001000
+
+KERNEL_LOADADDR := $(loadaddr-y)
+
+KERNEL_DTB = kernel-bin | patch-dtb | lzma
+define Device/Default
+  KERNEL := $(KERNEL_DTB) | uImage lzma
+  IMAGES := sysupgrade.bin
+  IMAGE_SIZE := $(ralink_default_fw_size_8M)
+  IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
 endef
-else
-ifeq ($(CONFIG_SOC_MT7621),y)
-define kernel_entry
--a 0x80001000 -e 0x80001000
+
+define Build/patch-dtb
+       $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $@.dtb ../dts/$(DTS).dts
+       $(STAGING_DIR_HOST)/bin/patch-dtb $@ $@.dtb
 endef
-else
-define kernel_entry
--a 0x80000000 -e 0x80000000
+
+define Build/trx
+       $(STAGING_DIR_HOST)/bin/trx \
+               -o $@ \
+               -m $(IMAGE_SIZE) \
+               -f $(word 1,$^) \
+               -a 4 -f $(word 2,$^)
+endef
+
+define Build/seama
+       $(STAGING_DIR_HOST)/bin/seama -i $@ $(1)
+       mv $@.seama $@
+endef
+
+define Build/seama-seal
+       $(call Build/seama,-s $@.seama $(1))
+endef
+
+define Build/relocate-kernel
+       ( \
+               dd if=$(KDIR)/loader.bin bs=32 conv=sync && \
+               perl -e '@s = stat("$@"); print pack("V", @s[7])' && \
+               cat $@ \
+       ) > $@.new
+       mv $@.new $@
 endef
-endif
-endif
 
 define MkCombineduImage
        $(call PatchKernelLzma,$(2),$(3))
@@ -59,7 +90,7 @@ endef
 # $(3), output filename
 define MkImage
        $(eval imagename=$(if $(4),$(4),MIPS OpenWrt Linux-$(LINUX_VERSION)))
-       -mkimage -A mips -O linux -T kernel -C $(1) $(call kernel_entry)\
+       -mkimage -A mips -O linux -T kernel -C $(1) -a $(loadaddr-y) -e $(loadaddr-y) \
                -n "$(imagename)" \
                -d $(2) $(3)
 endef
@@ -79,6 +110,23 @@ define MkImageSysupgrade/squashfs
        fi
 endef
 
+define MkImageTpl/squashfs
+       $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin)
+       $(STAGING_DIR_HOST)/bin/mktplinkfw2 -V "ver. 2.0" -B "$(2)" -j \
+               -o $(KDIR)/$(output_name) \
+               -k $(KDIR)/vmlinux-$(1)$(4).bin.lzma \
+               -r $(KDIR)/root.$(1)
+       $(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name)
+endef
+
+define MkImageTpl/initramfs
+       $(eval output_name=$(IMG_PREFIX)-$(2)-$(1).bin)
+       $(STAGING_DIR_HOST)/bin/mktplinkfw2 -V "ver. 2.0" -B "$(2)" -c \
+               -o $(KDIR)/$(output_name) \
+               -k $(KDIR)/vmlinux-$(1).bin.lzma
+       $(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name)
+endef
+
 # $(1), lowercase board name like "mt7620a_v22sg"
 # $(2), DTS filename without .dts extension
 # $(3), optional filename suffix, e.g. "-initramfs"
@@ -108,6 +156,16 @@ define BuildFirmware/OF
        $(call MkImageSysupgrade/$(1),$(1),$(2),$(4),$(6))
 endef
 
+define BuildFirmware/OF/tplink
+       $(call PatchKernelLzmaDtb,$(1),$(2),$(4))
+       $(call MkImageTpl/$(1),$(1),$(2),$(4),$(5))
+endef
+
+define BuildFirmware/OF/tplink/initramfs
+       $(call PatchKernelLzmaDtb,$(2),$(3),-initramfs)
+       $(call MkImageTpl/$(1),$(1),$(2),$(4),$(5))
+endef
+
 # $(1), squashfs/initramfs
 # $(2), lowercase board name
 # $(3), DTS filename without .dts extension
@@ -136,6 +194,8 @@ BuildFirmware/Default4M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(
 ralink_default_fw_size_8M=8060928
 BuildFirmware/Default8M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_8M),$(4))
 BuildFirmware/Default8M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4))
+BuildFirmware/Tplink/squashfs=$(call BuildFirmware/OF/tplink,$(1),$(2),$(3),$(4))
+BuildFirmware/Tplink/initramfs=$(call BuildFirmware/OF/tplink/initramfs,$(1),$(2),$(3),$(4))
 
 ralink_default_fw_size_16M=16121856
 BuildFirmware/Default16M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_16M),$(4))
@@ -335,6 +395,8 @@ Image/Build/Profile/V11STFE=$(call BuildFirmware/Default4M/$(1),$(1),v11st-fe,V1
 
 Image/Build/Profile/WLITX4AG300N=$(call BuildFirmware/Default4M/$(1),$(1),wli-tx4-ag300n,WLI-TX4-AG300N)
 
+Image/Build/Profile/WZRAGL300NH=$(call BuildFirmware/Default4M/$(1),$(1),wzr-agl300nh,WZR-AGL300NH)
+
 ifeq ($(SUBTARGET),rt288x)
 define Image/Build/Profile/Default
        $(call Image/Build/Profile/AR670W,$(1))
@@ -343,6 +405,7 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/RTN15,$(1))
        $(call Image/Build/Profile/V11STFE,$(1))
        $(call Image/Build/Profile/WLITX4AG300N,$(1))
+       $(call Image/Build/Profile/WZRAGL300NH,$(1))
 endef
 endif
 
@@ -451,6 +514,7 @@ define BuildFirmware/DCS930/squashfs
 endef
 BuildFirmware/DCS930/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
 Image/Build/Profile/DCS930=$(call BuildFirmware/DCS930/$(1),$(1),dcs-930,DCS-930)
+Image/Build/Profile/DCS930LB1=$(call BuildFirmware/DCS930/$(1),$(1),dcs-930l-b1,DCS-930L-B1)
 
 Image/Build/Profile/ESR-9753=$(call BuildFirmware/Default4M/$(1),$(1),esr-9753,ESR-9753)
 
@@ -489,6 +553,10 @@ Image/Build/Profile/M4=$(call BuildFirmware/PorayDualSize/$(1),$(1),m4,M4)
 Image/Build/Profile/MOFI3500-3GN=$(call BuildFirmware/Default8M/$(1),$(1),mofi3500-3gn,MOFI3500-3GN)
 
 # Kernel name should be "Linux Kernel Image" to make the OpenWrt image installable from factory Web UI
+Image/Build/Profile/3G150B=$(call BuildFirmware/Default4M/$(1),$(1),3g150b,3G150B,Linux Kernel Image)
+
+Image/Build/Profile/MR102N=$(call BuildFirmware/Default8M/$(1),$(1),mr-102n,MR-102N)
+
 Image/Build/Profile/MPRA1=$(call BuildFirmware/Default4M/$(1),$(1),mpr-a1,MPRA1,Linux Kernel Image)
 Image/Build/Profile/MPRA2=$(call BuildFirmware/Default8M/$(1),$(1),mpr-a2,MPRA2,Linux Kernel Image)
 
@@ -504,10 +572,16 @@ Image/Build/Profile/NCS601W=$(call BuildFirmware/Default8M/$(1),$(1),ncs601W,NCS
 nw718_mtd_size=3801088
 Image/Build/Profile/NW718=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),nw718m,NW718,$(nw718_mtd_size),ARA1B4NCRNW718;1,factory)
 
+Image/Build/Profile/M2M=$(call BuildFirmware/Default8M/$(1),$(1),m2m,M2M,Linux Kernel Image)
+
 Image/Build/Profile/OMNI-EMB=$(call BuildFirmware/Default8M/$(1),$(1),omni-emb,OMNI-EMB)
 
 Image/Build/Profile/OMNI-PLUG=$(call BuildFirmware/Default8M/$(1),$(1),omni-plug,OMNI-PLUG)
 
+Image/Build/Profile/OLINUXINO-RT5350F=$(call BuildFirmware/Default8M/$(1),$(1),olinuxino-rt5350f,OLINUXINO-RT5350F)
+
+Image/Build/Profile/OLINUXINO-RT5350F-EVB=$(call BuildFirmware/Default8M/$(1),$(1),olinuxino-rt5350f-evb,OLINUXINO-RT5350F-EVB)
+
 Image/Build/Profile/PSR-680W=$(call BuildFirmware/Default4M/$(1),$(1),psr-680w,PSR-680W)
 
 Image/Build/Profile/PWH2004=$(call BuildFirmware/Default8M/$(1),$(1),pwh2004,PWH2004)
@@ -534,6 +608,9 @@ Image/Build/Profile/W502U=$(call BuildFirmware/Default8M/$(1),$(1),w502u,W502U)
 
 Image/Build/Profile/WCR150GN=$(call BuildFirmware/Default4M/$(1),$(1),wcr150gn,WCR150GN)
 
+
+Image/Build/Profile/MZK-DP150N=$(call BuildFirmware/Default4M/$(1),$(1),mzk-dp150n,MZK-DP150N)
+
 buffalo_whrg300n_mtd_size=3801088
 define BuildFirmware/WHRG300N/squashfs
        $(call BuildFirmware/Default4M/$(1),$(1),whr-g300n,WHR-G300N)
@@ -596,12 +673,7 @@ Image/Build/Profile/WNCE2001=$(call BuildFirmware/WNCE2001/$(1),$(1),wnce2001,WN
 
 Image/Build/Profile/WR512-3GN=$(call BuildFirmware/DefaultDualSize/$(1),$(1),wr512-3ng,WR512-3GN)
 
-define BuildFirmware/WT1520/initramfs
-       $(call BuildFirmware/OF/initramfs,$(1),$(2),$(3),$(4))
-endef
-BuildFirmware/WT1520/squashfs=$(call BuildFirmware/Default4M/squashfs,$(1),$(2),$(3),$(4))
-
-Image/Build/Profile/WT1520=$(call BuildFirmware/WT1520/$(1),$(1),wt1520,WT1520,WT1520)
+Image/Build/Profile/WT1520=$(call BuildFirmware/PorayDualSize/$(1),$(1),wt1520,WT1520)
 
 Image/Build/Profile/UR-326N4G=$(call BuildFirmware/Default4M/$(1),$(1),ur-326n4g,UR-326N4G)
 
@@ -619,6 +691,7 @@ ifeq ($(SUBTARGET),rt305x)
 define Image/Build/Profile/Default
        $(call Image/Build/Profile/3G6200N,$(1))
        $(call Image/Build/Profile/3G6200NL,$(1))
+       $(call Image/Build/Profile/3G150B,$(1))
        $(call Image/Build/Profile/3G300M,$(1))
        $(call Image/Build/Profile/A5-11,$(1))
        $(call Image/Build/Profile/AIR3GII,$(1))
@@ -647,6 +720,7 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/DAP1350,$(1))
        $(call Image/Build/Profile/DAP1350WW,$(1))
        $(call Image/Build/Profile/DCS930,$(1))
+       $(call Image/Build/Profile/DCS930LB1,$(1))
        $(call Image/Build/Profile/ESR-9753,$(1))
        $(call Image/Build/Profile/F7C027,$(1))
        $(call Image/Build/Profile/F5D8235V2,$(1))
@@ -657,9 +731,11 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/HT-TM02,$(1))
        $(call Image/Build/Profile/HW550-3G,$(1))
        $(call Image/Build/Profile/IP2202,$(1))
+       $(call Image/Build/Profile/M2M,$(1))
        $(call Image/Build/Profile/M3,$(1))
        $(call Image/Build/Profile/M4,$(1))
        $(call Image/Build/Profile/MOFI3500-3GN,$(1))
+       $(call Image/Build/Profile/MR102N,$(1))
        $(call Image/Build/Profile/MPRA1,$(1))
        $(call Image/Build/Profile/MPRA2,$(1))
        $(call Image/Build/Profile/MZKW300NH2,$(1))
@@ -668,6 +744,8 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/NW718,$(1))
        $(call Image/Build/Profile/OMNI-EMB,$(1))
        $(call Image/Build/Profile/OMNI-PLUG,$(1))
+       $(call Image/Build/Profile/OLINUXINO-RT5350F,$(1))
+       $(call Image/Build/Profile/OLINUXINO-RT5350F-EVB,$(1))
        $(call Image/Build/Profile/PSR-680W,$(1))
        $(call Image/Build/Profile/PWH2004,$(1))
        $(call Image/Build/Profile/PX4885,$(1))
@@ -696,6 +774,8 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/X5,$(1))
        $(call Image/Build/Profile/X8,$(1))
        $(call Image/Build/Profile/XDXRN502J,$(1))
+       $(call Image/Build/Profile/MZK-DP150N,$(1))
+
 endef
 endif
 
@@ -775,27 +855,47 @@ Image/Build/Profile/MT7620a=$(call BuildFirmware/Default8M/$(1),$(1),mt7620a,MT7
 Image/Build/Profile/MT7620a_MT7610e=$(call BuildFirmware/Default8M/$(1),$(1),mt7620a_mt7610e,MT7620a_MT7610e)
 Image/Build/Profile/MT7620a_MT7530=$(call BuildFirmware/Default8M/$(1),$(1),mt7620a_mt7530,MT7620a_MT7530)
 Image/Build/Profile/MT7620a_V22SG=$(call BuildFirmware/Default8M/$(1),$(1),mt7620a_v22sg,MT7620a_V22SG)
+br100_mtd_size=8126464
+Image/Build/Profile/AIBR100=$(call BuildFirmware/CustomFlash/$(1),$(1),ai-br100,AIBR100,$(br100_mtd_size),Ai-BR)
 Image/Build/Profile/RP-N53=$(call BuildFirmware/Default8M/$(1),$(1),rp_n53,RP-N53)
 whr_300hp2_mtd_size=7012352
 Image/Build/Profile/WHR300HP2=$(call BuildFirmware/CustomFlash/$(1),$(1),whr-300hp2,WHR-300HP2,$(whr_300hp2_mtd_size))
 Image/Build/Profile/WHR600D=$(call BuildFirmware/CustomFlash/$(1),$(1),whr-600d,WHR-600D,$(whr_300hp2_mtd_size))
 whr_1166d_mtd_size=15400960
-Image/Build/Profile/WHR1166D=$(call BuildFirmware/CustomFlash/$(1),$(1),whr-1166d,WHR-1166D,$(whr_1166hd_mtd_size))
+Image/Build/Profile/WHR1166D=$(call BuildFirmware/CustomFlash/$(1),$(1),whr-1166d,WHR-1166D,$(whr_1166d_mtd_size))
 dlink810l_mtd_size=6881280
+Image/Build/Profile/CF-WR800N=$(call BuildFirmware/Default8M/$(1),$(1),cf-wr800n,CF-WR800N)
 Image/Build/Profile/DIR-810L=$(call BuildFirmware/CustomFlash/$(1),$(1),dir-810l,DIR-810L,$(dlink810l_mtd_size))
 na930_mtd_size=20971520
 Image/Build/Profile/NA930=$(call BuildFirmware/CustomFlash/$(1),$(1),na930,NA930,$(na930_mtd_size))
 Image/Build/Profile/MZK-750DHP=$(call BuildFirmware/Default8M/$(1),$(1),mzk-750dhp,MZK-750DHP)
+Image/Build/Profile/OY-0001=$(call BuildFirmware/Default16M/$(1),$(1),oy-0001,OY-0001)
 Image/Build/Profile/Y1=$(call BuildFirmware/Default16M/$(1),$(1),Lenovo-y1,Y1)
 Image/Build/Profile/Y1S=$(call BuildFirmware/Default16M/$(1),$(1),Lenovo-y1s,Y1S)
+Image/Build/Profile/MLW221=$(call BuildFirmware/Default16M/$(1),$(1),mlw221,MLW221)
+Image/Build/Profile/MLWG2=$(call BuildFirmware/Default16M/$(1),$(1),mlwg2,MLWG2)
+Image/Build/Profile/WMR300=$(call BuildFirmware/Default8M/$(1),$(1),wmr-300,WMR300)
+Image/Build/Profile/RT-N14U=$(call BuildFirmware/Default8M/$(1),$(1),rt-n14u,RT-N14U)
+Image/Build/Profile/WR8305RT=$(call BuildFirmware/Default8M/$(1),$(1),wr8305rt,WR8305RT)
+Image/Build/Profile/WRTNODE=$(call BuildFirmware/Default16M/$(1),$(1),wrtnode,WRTNODE)
+Image/Build/Profile/WT3020=$(call BuildFirmware/PorayDualSize/$(1),$(1),wt3020,WT3020)
+Image/Build/Profile/XIAOMI-MIWIFI-MINI=$(call BuildFirmware/Default16M/$(1),$(1),xiaomi-miwifi-mini,XIAOMI-MIWIFI-MINI)
+Image/Build/Profile/ZTE-Q7=$(call BuildFirmware/Default8M/$(1),$(1),zte-q7,ZTE-Q7)
+Image/Build/Profile/ZBT-WA05=$(call BuildFirmware/Default8M/$(1),$(1),zbt-wa05,ZBT-WA05)
+Image/Build/Profile/ArcherC20i=$(call BuildFirmware/Tplink/$(1),$(1),ArcherC20i,ArcherC20i)
+microwrt_mtd_size=16515072
+Image/Build/Profile/MicroWRT=$(call BuildFirmware/CustomFlash/$(1),$(1),microwrt,MicroWRT,$(microwrt_mtd_size))
 
-ifeq ($(SUBTARGET),mt7620a)
+
+ifeq ($(SUBTARGET),mt7620)
 define Image/Build/Profile/Default
        $(call Image/Build/Profile/E1700,$(1))
        $(call Image/Build/Profile/MT7620a,$(1))
        $(call Image/Build/Profile/MT7620a_MT7610e,$(1))
        $(call Image/Build/Profile/MT7620a_MT7530,$(1))
        $(call Image/Build/Profile/MT7620a_V22SG,$(1))
+       $(call Image/Build/Profile/AIBR100,$(1))
+       $(call Image/Build/Profile/CF-WR800N,$(1))
        $(call Image/Build/Profile/RP-N53,$(1))
        $(call Image/Build/Profile/DIR-810L,$(1))
        $(call Image/Build/Profile/WHR300HP2,$(1))
@@ -803,49 +903,79 @@ define Image/Build/Profile/Default
        $(call Image/Build/Profile/WHR1166D,$(1))
        $(call Image/Build/Profile/MZK-750DHP,$(1))
        $(call Image/Build/Profile/NA930,$(1))
+       $(call Image/Build/Profile/OY-0001,$(1))
        $(call Image/Build/Profile/Y1,$(1))
        $(call Image/Build/Profile/Y1S,$(1))
-endef
-endif
-
-
-#
-# MT7620N Profiles
-#
-
-Image/Build/Profile/MLW221=$(call BuildFirmware/Default16M/$(1),$(1),mlw221,MLW221)
-Image/Build/Profile/WMR300=$(call BuildFirmware/Default8M/$(1),$(1),wmr-300,WMR300)
-Image/Build/Profile/RT-N14U=$(call BuildFirmware/Default8M/$(1),$(1),rt-n14u,RT-N14U)
-Image/Build/Profile/WR8305RT=$(call BuildFirmware/Default8M/$(1),$(1),wr8305rt,WR8305RT)
-Image/Build/Profile/WRTNODE=$(call BuildFirmware/Default16M/$(1),$(1),wrtnode,WRTNODE)
-Image/Build/Profile/WT3020=$(call BuildFirmware/DefaultDualSize/$(1),$(1),wt3020,WT3020)
-Image/Build/Profile/ZBT-WA05=$(call BuildFirmware/Default8M/$(1),$(1),zbt-wa05,ZBT-WA05)
-
-ifeq ($(SUBTARGET),mt7620n)
-define Image/Build/Profile/Default
        $(call Image/Build/Profile/MLW221,$(1))
+       $(call Image/Build/Profile/MLWG2,$(1))
        $(call Image/Build/Profile/WMR300,$(1))
        $(call Image/Build/Profile/RT-N14U,$(1))
        $(call Image/Build/Profile/WR8305RT,$(1))
        $(call Image/Build/Profile/WRTNODE,$(1))
        $(call Image/Build/Profile/WT3020,$(1))
+       $(call Image/Build/Profile/XIAOMI-MIWIFI-MINI,$(1))
+       $(call Image/Build/Profile/ZTE-Q7,$(1))
        $(call Image/Build/Profile/ZBT-WA05,$(1))
+       $(call Image/Build/Profile/ArcherC20i,$(1))
+       $(call Image/Build/Profile/MicroWRT,$(1))
 endef
 endif
 
-
 #
 # MT7621 Profiles
 #
 
-Image/Build/Profile/MT7621=$(call BuildFirmware/Default4M/$(1),$(1),mt7621,MT7621)
-
 ifeq ($(SUBTARGET),mt7621)
-define Image/Build/Profile/Default
-       $(call Image/Build/Profile/MT7621,$(1))
-endef
+  TARGET_DEVICES += mt7621 wsr-600 wsr-1166 dir-860l-b1 firewrt pbr-m1 re6500 sap-g3200u3
 endif
 
+define Device/mt7621
+  DTS := MT7621
+  IMAGE_SIZE := $(ralink_default_fw_size_4M)
+endef
+
+define Device/wsr-600
+  DTS := WSR-600
+endef
+
+define Device/re6500
+  DTS := RE6500
+endef
+
+define Device/wsr-1166
+  DTS := WSR-1166
+  IMAGE/sysupgrade.bin := trx | pad-rootfs
+endef
+
+define Device/dir-860l-b1
+  DTS := DIR-860L-B1
+  IMAGES += factory.bin
+  KERNEL := kernel-bin | patch-dtb | relocate-kernel | lzma | uImage lzma
+  IMAGE/sysupgrade.bin := \
+       append-kernel | pad-offset 65536 64 | append-rootfs | \
+       seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+       pad-rootfs | check-size $$$$(IMAGE_SIZE)
+  IMAGE/factory.bin := \
+       append-kernel | pad-offset 65536 64 | append-rootfs | pad-rootfs -x 64 | \
+       seama -m "dev=/dev/mtdblock/2" -m "type=firmware" | \
+       check-size $$$$(IMAGE_SIZE) | \
+       seama-seal -m "signature=wrgac13_dlink.2013gui_dir860lb"
+endef
+
+define Device/firewrt
+  DTS := FIREWRT
+  IMAGE_SIZE := $(ralink_default_fw_size_16M)
+endef
+
+define Device/pbr-m1
+  DTS := PBR-M1
+  IMAGE_SIZE := $(ralink_default_fw_size_16M)
+endef
+
+define Device/sap-g3200u3
+  DTS := SAP-G3200U3
+endef
+
 #
 # MT7628 Profiles
 #
@@ -860,7 +990,21 @@ endif
 
 
 #
-# Generic Targets
+# MT7688 Profiles
+#
+
+Image/Build/Profile/mt7688=$(call BuildFirmware/Default16M/$(1),$(1),mt7688,MT7688)
+
+ifeq ($(SUBTARGET),mt7688)
+define Image/Build/Profile/Default
+       $(call Image/Build/Profile/mt7688,$(1))
+endef
+endif
+
+
+ifndef TARGET_DEVICES
+#
+# Generic Targets - only needed for legacy image building code
 #
 define Image/BuildKernel
        cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(VMLINUX).elf
@@ -884,5 +1028,16 @@ define Image/Build
        dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
        $(call Image/Build/Profile/$(PROFILE),$(1))
 endef
+endif
+
+ifeq ($(SUBTARGET),mt7621)
+define Image/Prepare
+#define Build/Compile
+       rm -rf $(KDIR)/relocate
+       $(CP) ../../generic/image/relocate $(KDIR)
+       $(MAKE) -C $(KDIR)/relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
+       $(CP) $(KDIR)/relocate/loader.bin $(KDIR)/loader.bin
+endef
+endif
 
 $(eval $(call BuildImage))