ar71xx: get rid of copy-file
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / image / common-tp-link.mk
1 DEVICE_VARS += LOADER_FLASH_OFFS TPLINK_BOARD_ID TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION TPLINK_HWID TPLINK_HWREV
2
3 # Arguments: <output name> <kernel offset>
4 define Build/loader-okli
5 dd if=$(KDIR)/loader-$(word 1,$(1)).$(LOADER_TYPE) bs=$(word 2,$(1)) conv=sync of="$@.new"
6 cat "$@" >> "$@.new"
7 mv "$@.new" "$@"
8 endef
9
10 define Build/loader-okli-compile
11 $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
12 endef
13
14 # combine kernel and rootfs into one image
15 # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
16 # <type> is "sysupgrade" or "factory"
17 #
18 # -a align the rootfs start on an <align> bytes boundary
19 # -j add jffs2 end-of-filesystem markers
20 # -s strip padding from end of the image
21 # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
22 define Build/mktplinkfw
23 -$(STAGING_DIR_HOST)/bin/mktplinkfw \
24 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \
25 -m $(TPLINK_HEADER_VERSION) \
26 -k $(IMAGE_KERNEL) \
27 -r $@ \
28 -o $@.new \
29 -j -X 0x40000 \
30 -a $(call rootfs_align,$(FILESYSTEM)) \
31 $(wordlist 2,$(words $(1)),$(1)) \
32 $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
33 endef
34
35 define Build/uImageArcher
36 mkimage -A $(LINUX_KARCH) \
37 -O linux -T kernel \
38 -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
39 -n '$(call toupper,$(LINUX_KARCH)) OpenWrt Linux-$(LINUX_VERSION)' -d $@ $@.new
40 @mv $@.new $@
41 endef
42
43
44 define Device/tplink
45 TPLINK_HWREV := 0x1
46 TPLINK_HEADER_VERSION := 1
47 LOADER_TYPE := gz
48 KERNEL := kernel-bin | patch-cmdline | lzma
49 KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | tplink-v1-header
50 IMAGES := sysupgrade.bin factory.bin
51 IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
52 IMAGE/factory.bin := append-rootfs | mktplinkfw factory
53 endef
54
55 define Device/tplink-nolzma
56 $(Device/tplink)
57 LOADER_FLASH_OFFS := 0x22000
58 COMPILE := loader-$(1).gz
59 COMPILE/loader-$(1).gz := loader-okli-compile
60 KERNEL_NAME := vmlinux.bin.lzma
61 KERNEL := kernel-bin | uImage lzma -M 0x4f4b4c49 | loader-okli $(1) 7680
62 KERNEL_INITRAMFS_NAME := vmlinux-initramfs.bin.lzma
63 KERNEL_INITRAMFS := kernel-bin | loader-kernel-cmdline | tplink-v1-header
64 endef
65
66 define Device/tplink-4m
67 $(Device/tplink-nolzma)
68 TPLINK_FLASHLAYOUT := 4M
69 IMAGE_SIZE := 3904k
70 endef
71
72 define Device/tplink-8m
73 $(Device/tplink-nolzma)
74 TPLINK_FLASHLAYOUT := 8M
75 IMAGE_SIZE := 7936k
76 endef
77
78 define Device/tplink-4mlzma
79 $(Device/tplink)
80 TPLINK_FLASHLAYOUT := 4Mlzma
81 IMAGE_SIZE := 3904k
82 endef
83
84 define Device/tplink-8mlzma
85 $(Device/tplink)
86 TPLINK_FLASHLAYOUT := 8Mlzma
87 IMAGE_SIZE := 7936k
88 endef
89
90 define Device/tplink-16mlzma
91 $(Device/tplink)
92 TPLINK_FLASHLAYOUT := 16Mlzma
93 IMAGE_SIZE := 15872k
94 endef