KERNEL_LOADADDR = 0x80060000
-DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD NETGEAR_ID CMDLINE CONSOLE IMAGE_SIZE
+DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD NETGEAR_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS
define Build/netgear-squashfs
rm -rf $@.fs $@.squashfs
@mv $@.new $@
endef
+define Build/loader-common
+ rm -rf $@.src
+ $(MAKE) -C lzma-loader \
+ PKG_BUILD_DIR="$@.src" \
+ TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
+ KERNEL_CMDLINE="$(CMDLINE)" BOARD="$(BOARDNAME)" \
+ LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
+ $(1) compile loader.gz
+ mv "$@.gz" "$@"
+ rm -rf $@.src
+endef
+
+define Build/loader-okli-compile
+ $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0)
+endef
+
+define Build/loader-kernel
+ $(call Build/loader-common,LOADER_DATA="$@")
+endef
+
+define Build/loader-okli
+ dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
+ cat "$@" >> "$@.new"
+ mv "$@.new" "$@"
+endef
+
+define Build/copy-file
+ cat "$(1)" > "$@"
+endef
+
DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT
define Device/Default
CONSOLE = ttyS0,115200
CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
+ COMPILE :=
IMAGES := sysupgrade.bin
IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
endef
IMAGE/factory.bin := append-rootfs | mktplinkfw factory
endef
+define Device/tplink-nolzma
+$(Device/tplink)
+ LOADER_FLASH_OFFS := 0x22000
+ COMPILE := loader-$(1).gz
+ COMPILE/loader-$(1).gz := loader-okli-compile
+ KERNEL := copy-file $(KDIR)/vmlinux.bin.lzma | uImage lzma -M 0x4f4b4c49 | loader-okli $(1)
+ KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux-initramfs.bin.lzma | loader-kernel | mktplinkfw-initramfs
+endef
+
+define Device/tplink-4m
+$(Device/tplink-nolzma)
+ TPLINK_FLASHLAYOUT := 4M
+ IMAGE_SIZE := 3904k
+endef
+
+define Device/tplink-8m
+$(Device/tplink-nolzma)
+ TPLINK_FLASHLAYOUT := 8M
+ IMAGE_SIZE := 7936k
+endef
+
define Device/tplink-4mlzma
$(Device/tplink)
TPLINK_FLASHLAYOUT := 4Mlzma
CONSOLE := ttyATH0,115200
endef
+define Device/tl-wr741nd-v1
+ $(Device/tplink-4m)
+ BOARDNAME := TL-WR741ND
+ DEVICE_PROFILE := TLWR741
+ TPLINK_HWID := 0x07410001
+endef
+
+define Device/tl-wr741nd-v2
+ $(Device/tplink-4m)
+ BOARDNAME := TL-WR741ND
+ DEVICE_PROFILE := TLWR741
+ TPLINK_HWID := 0x07410001
+endef
+
define Device/tl-wr741nd-v4
$(Device/tplink-4mlzma)
BOARDNAME := TL-WR741ND-v4
TPLINK_HWID := 0x07430002
CONSOLE := ttyATH0,115200
endef
-TARGET_DEVICES += tl-wr740n-v4 tl-wr741nd-v4 tl-wr743nd-v2
+TARGET_DEVICES += tl-wr740n-v4 tl-wr741nd-v1 tl-wr741nd-v2 tl-wr741nd-v4 tl-wr743nd-v2
define Device/tl-wr841n-v8
$(Device/tplink-4mlzma)
$(eval $(call SingleProfile,TPLINK,64kraw,TLWA901NV2,tl-wa901nd-v2,TL-WA901ND-v2,ttyS0,115200,0x09010002,1,4M))
$(eval $(call SingleProfile,TPLINK,64kraw,TLWR740NV1,tl-wr740n-v1,TL-WR741ND,ttyS0,115200,0x07400001,1,4M))
$(eval $(call SingleProfile,TPLINK,64kraw,TLWR740NV3,tl-wr740n-v3,TL-WR741ND,ttyS0,115200,0x07400003,1,4M))
-$(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV1,tl-wr741nd-v1,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
-$(eval $(call SingleProfile,TPLINK,64kraw,TLWR741NV2,tl-wr741nd-v2,TL-WR741ND,ttyS0,115200,0x07410001,1,4M))
$(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND,ttyS0,115200,0x07430001,1,4M))
$(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV3,tl-wr841nd-v3,TL-WR941ND,ttyS0,115200,0x08410003,3,4M))
$(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV5,tl-wr841nd-v5,TL-WR741ND,ttyS0,115200,0x08410005,1,4M))