oxnas: drop target
[openwrt/openwrt.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 IMAGES := sysupgrade.bin factory.bin
48 endef
49
50 define Device/tplink-lzma
51 $(Device/tplink)
52 KERNEL := kernel-bin | patch-cmdline | lzma
53 KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | tplink-v1-header
54 IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
55 IMAGE/factory.bin := append-rootfs | mktplinkfw factory
56 endef
57
58 define Device/tplink-nolzma
59 $(Device/tplink)
60 LOADER_TYPE := gz
61 LOADER_FLASH_OFFS := 0x22000
62 COMPILE := loader-$(1).gz
63 COMPILE/loader-$(1).gz := loader-okli-compile
64 KERNEL_NAME := vmlinux.bin.lzma
65 KERNEL := kernel-bin | uImage lzma -M 0x4f4b4c49 | loader-okli $(1) 7680
66 KERNEL_INITRAMFS_NAME := vmlinux-initramfs.bin.lzma
67 KERNEL_INITRAMFS := kernel-bin | loader-kernel-cmdline | tplink-v1-header
68 IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
69 IMAGE/factory.bin := append-rootfs | mktplinkfw factory
70 endef
71
72 define Device/tplink-safeloader
73 $(Device/tplink)
74 KERNEL := kernel-bin | patch-cmdline | lzma | tplink-v1-header
75 IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
76 append-metadata | check-size $$$$(IMAGE_SIZE)
77 IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
78 endef
79
80 define Device/tplink-4m
81 $(Device/tplink-nolzma)
82 TPLINK_FLASHLAYOUT := 4M
83 IMAGE_SIZE := 3904k
84 endef
85
86 define Device/tplink-8m
87 $(Device/tplink-nolzma)
88 TPLINK_FLASHLAYOUT := 8M
89 IMAGE_SIZE := 7936k
90 endef
91
92 define Device/tplink-4mlzma
93 $(Device/tplink-lzma)
94 TPLINK_FLASHLAYOUT := 4Mlzma
95 IMAGE_SIZE := 3904k
96 endef
97
98 define Device/tplink-8mlzma
99 $(Device/tplink-lzma)
100 TPLINK_FLASHLAYOUT := 8Mlzma
101 IMAGE_SIZE := 7936k
102 endef
103
104 define Device/tplink-16mlzma
105 $(Device/tplink-lzma)
106 TPLINK_FLASHLAYOUT := 16Mlzma
107 IMAGE_SIZE := 15872k
108 endef