ar71xx: ubnt-m-xw: Fix factory image flashing using TFTP recovery
[openwrt/staging/dedeckeh.git] / target / linux / ar71xx / image / generic-ubnt.mk
1 DEVICE_VARS += UBNT_BOARD UBNT_CHIP UBNT_TYPE UBNT_VERSION UBNT_REVISION
2
3 # On M (XW) devices the U-Boot as of version 1.1.4-s1039 doesn't like
4 # VERSION_DIST being on the place of major(?) version number, so we need to
5 # use some number.
6 UBNT_REVISION := $(VERSION_DIST)-$(REVISION)
7
8 # mkubntimage is using the kernel image direct
9 # routerboard creates partitions out of the ubnt header
10 define Build/mkubntimage
11 -$(STAGING_DIR_HOST)/bin/mkfwimage \
12 -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
13 -k $(IMAGE_KERNEL) \
14 -r $@ \
15 -o $@
16 endef
17
18 # all UBNT XM device expect the kernel image to have 1024k while flash, when
19 # booting the image, the size doesn't matter.
20 define Build/mkubntimage-split
21 -[ -f $@ ] && ( \
22 dd if=$@ of=$@.old1 bs=1024k count=1; \
23 dd if=$@ of=$@.old2 bs=1024k skip=1; \
24 $(STAGING_DIR_HOST)/bin/mkfwimage \
25 -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v$(UBNT_VERSION)-$(UBNT_REVISION) \
26 -k $@.old1 \
27 -r $@.old2 \
28 -o $@; \
29 rm $@.old1 $@.old2 )
30 endef
31
32 define Build/mkubntimage2
33 -$(STAGING_DIR_HOST)/bin/mkfwimage2 -f 0x9f000000 \
34 -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-$(VERSION_DIST)-$(REVISION) \
35 -p jffs2:0x50000:0xf60000:0:0:$@ \
36 -o $@.new
37 @mv $@.new $@
38 endef
39
40
41 # UBNT_BOARD e.g. one of (XS2, XS5, RS, XM)
42 # UBNT_TYPE e.g. one of (BZ, XM, XW)
43 # UBNT_CHIP e.g. one of (ar7240, ar933x, ar934x)
44 # UBNT_VERSION e.g. one of (6.0.0, 8.5.0)
45 define Device/ubnt
46 DEVICE_PACKAGES := kmod-usb-core kmod-usb2
47 DEVICE_PROFILE := UBNT
48 IMAGE_SIZE := 7552k
49 MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
50 UBNT_BOARD := XM
51 UBNT_VERSION := 6.0.0
52 IMAGES := sysupgrade.bin factory.bin
53 IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
54 IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage-split
55 endef
56
57 define Device/ubnt-xm
58 $(Device/ubnt)
59 DEVICE_PACKAGES += kmod-usb-ohci rssileds
60 UBNT_TYPE := XM
61 UBNT_CHIP := ar7240
62 KERNEL := kernel-bin | patch-cmdline | relocate-kernel | lzma | uImage lzma
63 endef
64
65 define Device/ubnt-xw
66 $(Device/ubnt)
67 DEVICE_PACKAGES += rssileds
68 UBNT_TYPE := XW
69 UBNT_CHIP := ar934x
70 UBNT_VERSION := 6.0.4
71 UBNT_REVISION := 42.$(UBNT_REVISION)
72 endef
73
74 define Device/ubnt-bz
75 $(Device/ubnt)
76 UBNT_TYPE := BZ
77 UBNT_CHIP := ar7240
78 endef
79
80 define Device/rw2458n
81 $(Device/ubnt-xm)
82 DEVICE_TITLE := Ubiquiti RW2458N
83 BOARDNAME := RW2458N
84 endef
85 TARGET_DEVICES += rw2458n
86
87 define Device/ubnt-airrouter
88 $(Device/ubnt-xm)
89 DEVICE_TITLE := Ubiquiti AirRouter
90 BOARDNAME := UBNT-AR
91 endef
92 TARGET_DEVICES += ubnt-airrouter
93
94 define Device/ubnt-bullet-m
95 $(Device/ubnt-xm)
96 DEVICE_TITLE := Ubiquiti Bullet-M
97 BOARDNAME := UBNT-BM
98 endef
99 TARGET_DEVICES += ubnt-bullet-m
100
101 define Device/ubnt-rocket-m
102 $(Device/ubnt-xm)
103 DEVICE_TITLE := Ubiquiti Rocket-M
104 BOARDNAME := UBNT-RM
105 endef
106 TARGET_DEVICES += ubnt-rocket-m
107
108 define Device/ubnt-nano-m
109 $(Device/ubnt-xm)
110 DEVICE_TITLE := Ubiquiti Nano-M
111 BOARDNAME := UBNT-NM
112 endef
113 TARGET_DEVICES += ubnt-nano-m
114
115 define Device/ubnt-unifi
116 $(Device/ubnt-bz)
117 DEVICE_TITLE := Ubiquiti UniFi
118 BOARDNAME := UBNT-UF
119 DEVICE_PROFILE += UBNTUNIFI
120 endef
121 TARGET_DEVICES += ubnt-unifi
122
123 define Device/ubnt-unifiac
124 DEVICE_PACKAGES := kmod-usb-core kmod-usb2
125 DEVICE_PROFILE := UBNT
126 IMAGE_SIZE := 7744k
127 MTDPARTS := spi0.0:384k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),7744k(ubnt-airos)ro,128k(bs),256k(cfg)ro,64k(EEPROM)ro
128 IMAGES := sysupgrade.bin
129 IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
130 endef
131
132 define Device/ubnt-unifiac-lite
133 $(Device/ubnt-unifiac)
134 DEVICE_TITLE := Ubiquiti UniFi AC-Lite
135 DEVICE_PACKAGES := kmod-ath10k-ct ath10k-firmware-qca988x-ct
136 DEVICE_PROFILE += UBNTUNIFIACLITE
137 BOARDNAME := UBNT-UF-AC-LITE
138 endef
139 TARGET_DEVICES += ubnt-unifiac-lite
140
141 define Device/ubnt-unifiac-mesh
142 $(Device/ubnt-unifiac-lite)
143 DEVICE_TITLE := Ubiquiti UniFi AC-Mesh
144 endef
145 TARGET_DEVICES += ubnt-unifiac-mesh
146
147 define Device/ubnt-unifiac-pro
148 $(Device/ubnt-unifiac)
149 DEVICE_TITLE := Ubiquiti UniFi AC-Pro
150 DEVICE_PACKAGES += kmod-ath10k-ct ath10k-firmware-qca988x-ct
151 DEVICE_PROFILE += UBNTUNIFIACPRO
152 BOARDNAME := UBNT-UF-AC-PRO
153 endef
154 TARGET_DEVICES += ubnt-unifiac-pro
155
156 define Device/ubnt-unifiac-mesh-pro
157 $(Device/ubnt-unifiac-pro)
158 DEVICE_TITLE := Ubiquiti UniFi AC-Mesh-Pro
159 endef
160 TARGET_DEVICES += ubnt-unifiac-mesh-pro
161
162 define Device/ubnt-unifi-outdoor
163 $(Device/ubnt-bz)
164 DEVICE_TITLE := Ubiquiti UniFi Outdoor
165 BOARDNAME := UBNT-U20
166 DEVICE_PROFILE += UBNTUNIFIOUTDOOR
167 endef
168 TARGET_DEVICES += ubnt-unifi-outdoor
169
170 define Device/ubnt-nano-m-xw
171 $(Device/ubnt-xw)
172 DEVICE_TITLE := Ubiquiti Nano M XW
173 BOARDNAME := UBNT-NM-XW
174 endef
175 TARGET_DEVICES += ubnt-nano-m-xw
176
177 define Device/ubnt-lbe-m5
178 $(Device/ubnt-xw)
179 DEVICE_TITLE := Ubiquiti Litebeam M5
180 BOARDNAME := UBNT-LBE-M5
181 endef
182 TARGET_DEVICES += ubnt-lbe-m5
183
184 define Device/ubnt-loco-m-xw
185 $(Device/ubnt-xw)
186 DEVICE_TITLE := Ubiquiti Loco XW
187 BOARDNAME := UBNT-LOCO-XW
188 endef
189 TARGET_DEVICES += ubnt-loco-m-xw
190
191 define Device/ubnt-rocket-m-xw
192 $(Device/ubnt-xw)
193 DEVICE_TITLE := Ubiquiti Rocket M XW
194 BOARDNAME := UBNT-RM-XW
195 endef
196 TARGET_DEVICES += ubnt-rocket-m-xw
197
198 define Device/ubnt-rocket-m-ti
199 $(Device/ubnt-xw)
200 DEVICE_TITLE := Ubiquiti Rocket M TI
201 BOARDNAME := UBNT-RM-TI
202 UBNT_TYPE := TI
203 endef
204 TARGET_DEVICES += ubnt-rocket-m-ti
205
206 define Device/ubnt-air-gateway
207 $(Device/ubnt-xm)
208 DEVICE_TITLE := Ubiquiti Air Gateway
209 BOARDNAME := UBNT-AGW
210 UBNT_TYPE := AirGW
211 UBNT_CHIP := ar933x
212 CONSOLE := ttyATH0,115200
213 endef
214 TARGET_DEVICES += ubnt-air-gateway
215
216 define Device/ubnt-air-gateway-pro
217 $(Device/ubnt-xm)
218 DEVICE_TITLE := Ubiquiti Air Gateway Pro
219 BOARDNAME := UBNT-AGWP
220 UBNT_TYPE := AirGWP
221 UBNT_CHIP := ar934x
222 endef
223 TARGET_DEVICES += ubnt-air-gateway-pro
224
225 define Device/ubdev01
226 $(Device/ubnt-xm)
227 DEVICE_TITLE := Ubiquiti ubDEV01
228 MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
229 BOARDNAME := UBNT-UF
230 UBNT_BOARD := UBDEV01
231 endef
232 TARGET_DEVICES += ubdev01
233
234 define Device/ubnt-routerstation
235 DEVICE_PACKAGES := kmod-usb-core kmod-usb-ohci kmod-usb2
236 DEVICE_PROFILE := UBNT
237 IMAGE_SIZE := 16128k
238 IMAGES := sysupgrade.bin factory.bin
239 IMAGE/factory.bin := append-rootfs | pad-rootfs | mkubntimage
240 IMAGE/sysupgrade.bin := append-rootfs | pad-rootfs | combined-image | check-size $$$$(IMAGE_SIZE)
241 KERNEL := kernel-bin | patch-cmdline | lzma | pad-to $$(BLOCKSIZE)
242 endef
243
244 define Device/ubnt-rs
245 $(Device/ubnt-routerstation)
246 DEVICE_TITLE := Ubiquiti RouterStation
247 BOARDNAME := UBNT-RS
248 DEVICE_PROFILE += UBNTRS
249 UBNT_BOARD := RS
250 UBNT_TYPE := RSx
251 UBNT_CHIP := ar7100
252 endef
253 TARGET_DEVICES += ubnt-rs
254
255 define Device/ubnt-rspro
256 $(Device/ubnt-routerstation)
257 DEVICE_TITLE := Ubiquiti RouterStation Pro
258 BOARDNAME := UBNT-RSPRO
259 DEVICE_PROFILE += UBNTRSPRO
260 UBNT_BOARD := RSPRO
261 UBNT_TYPE := RSPRO
262 UBNT_CHIP := ar7100pro
263 endef
264 TARGET_DEVICES += ubnt-rspro
265
266 define Device/ubnt-ls-sr71
267 $(Device/ubnt-routerstation)
268 DEVICE_TITLE := Ubiquiti LS-SR71
269 BOARDNAME := UBNT-LS-SR71
270 UBNT_BOARD := LS-SR71
271 UBNT_TYPE := LS-SR71
272 UBNT_CHIP := ar7100
273 endef
274 TARGET_DEVICES += ubnt-ls-sr71
275
276 define Device/ubnt-uap-pro
277 DEVICE_TITLE := Ubiquiti UAP Pro
278 KERNEL_SIZE := 2048k
279 IMAGE_SIZE := 15744k
280 MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2048k(kernel),13696k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
281 UBNT_TYPE := BZ
282 UBNT_CHIP := ar934x
283 BOARDNAME := UAP-PRO
284 DEVICE_PROFILE := UBNT UAPPRO
285 KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | jffs2 kernel0
286 IMAGES := sysupgrade.bin factory.bin
287 IMAGE/sysupgrade.bin := append-kernel | pad-to $$$$(KERNEL_SIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
288 IMAGE/factory.bin := $$(IMAGE/sysupgrade.bin) | mkubntimage2
289 endef
290 TARGET_DEVICES += ubnt-uap-pro
291
292 define Device/ubnt-unifi-outdoor-plus
293 $(Device/ubnt-uap-pro)
294 DEVICE_TITLE := Ubiquiti UniFi Outdoor Plus
295 UBNT_CHIP := ar7240
296 BOARDNAME := UBNT-UOP
297 DEVICE_PROFILE := UBNT
298 endef
299 TARGET_DEVICES += ubnt-unifi-outdoor-plus