+ $(call MkImageLzma,$(2),$(3))
+ $(call Sysupgrade/KRuImage,$(1),$(2),$(4),$(5))
+endef
+
+define BuildFirmware/Generic/initramfs
+ $(call MkImageLzma,$(2),$(3))
+ $(CP) $(KDIR)/vmlinux-$(2).uImage $(call imgname,$(1),$(2))-uImage.bin
+endef
+
+mtdlayout_4M=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
+define BuildFirmware/GENERIC_4M
+ $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_4M)),917504,2949120)
+endef
+
+define BuildFirmware/GENERIC_4M/initramfs
+ $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_4M)))
+endef
+
+mtdlayout_8M=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),6976k(rootfs),7872k@0x50000(firmware)
+kernel_size_8M=917504
+rootfs_size_8M=7143424
+define BuildFirmware/GENERIC_8M
+ $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)),$(kernel_size_8M),$(rootfs_size_8M))
+endef
+
+define BuildFirmware/GENERIC_8M/initramfs
+ $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)))
+endef
+
+mtdlayout_argus_atp52b=192k(bootloader)ro,64k(config),64k(factory),1152k(kernel),6656k(rootfs),7808k@0x50000(firmware)
+mtd_argus_atp52b_kernel_part_size=1179648
+mtd_argus_atp52b_rootfs_part_size=6815744
+define BuildFirmware/ARGUS_ATP52B
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_argus_atp52b)),$(mtd_argus_atp52b_kernel_part_size),$(mtd_argus_atp52b_rootfs_part_size))
+endef
+
+define BuildFirmware/Buffalo
+ $(call MkImageLzma,$(2),$(3))
+ $(call Sysupgrade/KRuImage,$(1),$(2),$(4),$(5))
+ if [ -e "$(call sysupname,$(1),$(2))" ]; then \
+ buffalo-enc -p $(3) -v 1.76 \
+ -i $(KDIR)/vmlinux-$(2).uImage \
+ -o $(KDIR)/vmlinux-$(2).uImage.enc; \
+ buffalo-enc -p $(3) -v 1.76 \
+ -i $(KDIR)/root.$(1) \
+ -o $(KDIR)/root.$(2).enc; \
+ buffalo-tag -b $(3) -p $(3) -a ram -v 1.76 -m 1.01 \
+ -l mlang8 -f 1 -r EU \
+ -i $(KDIR)/vmlinux-$(2).uImage.enc \
+ -i $(KDIR)/root.$(2).enc \
+ -o $(call imgname,$(1),$(2))-factory-EU.bin; \
+ fi
+endef
+
+
+define BuildFirmware/Buffalo2
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(4),$(5),$(6))
+endef
+
+mtdlayout_dir300b1=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
+mtd_dir300b1_kernel_part_size=917504
+mtd_dir300b1_rootfs_part_size=2949120
+define BuildFirmware/DIR300B1
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_dir300b1)),$(mtd_dir300b1_kernel_part_size),$(mtd_dir300b1_rootfs_part_size))
+ mkwrgimg -s $(4) -d /dev/mtdblock/2 \
+ -i $(call sysupname,$(1),$(2)) \
+ -o $(call imgname,$(1),$(2))-factory.bin
+endef
+
+define BuildFirmware/Edimax
+ if [ -e "$(call sysupname,$(1),$(2))" ]; then \
+ mkedimaximg -i $(call sysupname,$(1),$(2)) \
+ -o $(call imgname,$(1),$(2))-factory.bin \
+ -s $(3) -m $(4) -f $(5) -S $(6); \
+ fi
+endef
+
+mtdlayout_f5d8235=320k(u-boot)ro,1536k(kernel),6208k(rootfs),64k(nvram),64k(factory),7744k@0x50000(firmware)
+mtd_f5d8235_kernel_part_size=1572864
+mtd_f5d8235_rootfs_part_size=6356992
+define BuildFirmware/F5D8235
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_f5d8235)),$(mtd_f5d8235_kernel_part_size),$(mtd_f5d8235_rootfs_part_size))
+endef
+
+define BuildFirmware/FONERA20N
+ $(call BuildFirmware/GENERIC_8M,$(1),fonera20n,FONERA20N,ttyS1,57600,phys)
+ $(call BuildFirmware/Edimax,$(1),fonera20n,RSDK,NL1T,0x50000,0xc0000)
+endef
+
+mtdlayout_nw718=192k(u-boot)ro,128k(config)ro,64k(factory)ro,896k(kernel),2816k(rootfs),3712k@0x60000(firmware)
+kernel_size_nw718=917504
+rootfs_size_nw718=2883584
+cmdline_nw718=$(call mkcmdline,NW718,ttyS1,57600) $(call mkmtd/spi,$(mtdlayout_nw718))
+define BuildFirmware/NW718
+ $(call BuildFirmware/Generic,$(1),$(2),$(cmdline_nw718),$(kernel_size_nw718),$(rootfs_size_nw718))
+ $(call PatchKernelLzma,$(2),$(cmdline_nw718))
+ mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry) \
+ -n "ARA1B4NCRNW718;1" \
+ -d "$(KDIR)/vmlinux-$(2).bin.lzma" \
+ "$(KDIR)/vmlinux-$(2).uImage"
+ $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,$(kernel_size_nw718),$(KDIR)/root.$(1),$(rootfs_size_nw718),$(call imgname,$(1),$(2))-factory.bin)
+endef
+
+mtdlayout_rtg32b1=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
+mtd_rtg32b1_kernel_part_size=917504
+mtd_rtg32b1_rootfs_part_size=2949120
+define BuildFirmware/RTG32B1
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/spi,$(mtdlayout_rtg32b1)),$(mtd_rtg32b1_kernel_part_size),$(mtd_rtg32b1_rootfs_part_size))
+endef
+
+mtdlayout_rtn10plus=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
+mtd_rtn10plus_kernel_part_size=917504
+mtd_rtn10plus_rootfs_part_size=2949120
+define BuildFirmware/RTN10PLUS
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_rtn10plus)),$(mtd_rtn10plus_kernel_part_size),$(mtd_rtn10plus_rootfs_part_size))
+endef
+
+mtdlayout_whrg300n=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,960k(kernel),2752k(rootfs),64k(user)ro,3712k@0x50000(firmware)
+define BuildFirmware/WHRG300N
+ $(call Image/Build/Template/GENERIC_4M,$(1),whr-g300n,WHR-G300N,ttyS1,57600,phys)
+ $(call BuildFirmware/Buffalo,$(1),whr-g300n,$(call mkcmdline,WHR-G300N,ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_whrg300n)),983040,3801088)
+ ( \
+ echo -n -e "# Airstation FirmWare\nrun u_fw\nreset\n\n" | \
+ dd bs=512 count=1 conv=sync; \
+ dd if=$(call sysupname,$(1),whr-g300n); \
+ ) > $(KDIR)/whr-g300n-tftp.tmp
+ buffalo-tftp -i $(KDIR)/whr-g300n-tftp.tmp \
+ -o $(call imgname,$(1),whr-g300n)-tftp.bin
+endef
+
+mtdlayout_wl341v3=128k(u-boot)ro,64k(board-nvram)ro,64k(u-boot-env)ro,896k(kernel),2880k(rootfs),64k(signature-eRcOmM),3776k@0x40000(firmware),4096k@0x0(fullflash)
+kernel_size_wl341v3=917504
+rootfs_size_wl341v3=2949120
+define BuildFirmware/WL341V3
+ $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_wl341v3)),$(kernel_size_wl341v3),$(rootfs_size_wl341v3))
+ if [ -e "$(call sysupname,$(1),$(2))" ]; then \