ath79: ubnt-xm: support ath9k firmware loading
[oweals/openwrt.git] / target / linux / ath79 / image / common-tp-link.mk
1 DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION TPLINK_BOARD_NAME TPLINK_BOARD_ID
2
3 define rootfs_align
4 $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
5 endef
6
7 # combine kernel and rootfs into one image
8 # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
9 # <type> is "sysupgrade" or "factory"
10 #
11 # -a align the rootfs start on an <align> bytes boundary
12 # -j add jffs2 end-of-filesystem markers
13 # -s strip padding from end of the image
14 # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
15 define Build/mktplinkfw
16         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
17                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) \
18                 -m $(TPLINK_HEADER_VERSION) \
19                 -k $(IMAGE_KERNEL) \
20                 -r $@ \
21                 -o $@.new \
22                 -j -X 0x40000 \
23                 -a $(call rootfs_align,$(FILESYSTEM)) \
24                 $(wordlist 2,$(words $(1)),$(1)) \
25                 $(if $(findstring sysupgrade,$(word 1,$(1))),-s) && mv $@.new $@ || rm -f $@
26 endef
27
28 # mktplinkfw-combined
29 #
30 # -c combined image
31 define Build/mktplinkfw-combined
32         $(STAGING_DIR_HOST)/bin/mktplinkfw \
33                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) $(1) \
34                 -m $(TPLINK_HEADER_VERSION) \
35                 -k $@ \
36                 -o $@.new \
37                 -s -S \
38                 -c
39         @mv $@.new $@
40 endef
41
42 define Device/tplink
43   TPLINK_HWREV := 0x1
44   TPLINK_HEADER_VERSION := 1
45   LOADER_TYPE := gz
46   KERNEL := kernel-bin | append-dtb | lzma
47   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | tplink-v1-header
48   IMAGES := sysupgrade.bin factory.bin
49   IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade | append-metadata
50   IMAGE/factory.bin := append-rootfs | mktplinkfw factory
51 endef
52
53 define Device/tplink-nolzma
54   $(Device/tplink)
55   LOADER_FLASH_OFFS := 0x22000
56   COMPILE := loader-$(1).gz
57   COMPILE/loader-$(1).gz := loader-okli-compile
58   KERNEL := kernel-bin | append-dtb | lzma | uImage lzma -M 0x4f4b4c49 | loader-okli $(1) 7680
59   KERNEL_INITRAMFS := kernel-bin | append-dtb | gzip | tplink-v1-header
60 endef
61
62 define Device/tplink-4m
63   $(Device/tplink-nolzma)
64   TPLINK_FLASHLAYOUT := 4M
65   IMAGE_SIZE := 3904k
66 endef
67
68 define Device/tplink-4mlzma
69   $(Device/tplink)
70   TPLINK_FLASHLAYOUT := 4Mlzma
71   IMAGE_SIZE := 3904k
72 endef
73
74 define Device/tplink-8m
75   $(Device/tplink-nolzma)
76   TPLINK_FLASHLAYOUT := 8M
77   IMAGE_SIZE := 7936k
78 endef
79
80 define Device/tplink-8mlzma
81 $(Device/tplink)
82   TPLINK_FLASHLAYOUT := 8Mlzma
83   IMAGE_SIZE := 7936k
84 endef
85
86 define Device/tplink-16mlzma
87   $(Device/tplink)
88   TPLINK_FLASHLAYOUT := 16Mlzma
89   IMAGE_SIZE := 15872k
90 endef