ar71xx/image: add options argument to mktplinkfw step
[openwrt.git] / target / linux / ar71xx / image / Makefile
1 #
2 # Copyright (C) 2008-2011 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 JFFS2_BLOCKSIZE = 64k 128k 256k
9
10 include $(TOPDIR)/rules.mk
11 include $(INCLUDE_DIR)/image.mk
12
13 IMAGE_PROFILE:=$(if $(PROFILE),$(PROFILE),Default)
14
15 KERNEL_LOADADDR = 0x80060000
16
17 DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD_ID NETGEAR_HW_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS
18
19 define Build/netgear-squashfs
20         rm -rf $@.fs $@.squashfs
21         mkdir -p $@.fs/image
22         cp $@ $@.fs/image/uImage
23         $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
24                 $@.fs $@.squashfs \
25                 -noappend -root-owned -be -b 65536
26         dd if=/dev/zero bs=1k count=1 >> $@.squashfs
27         mkimage \
28                 -A mips -O linux -T filesystem -C none \
29                 -M $(NETGEAR_KERNEL_MAGIC) \
30                 -a 0xbf070000 -e 0xbf070000 \
31                 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
32                 -d $@.squashfs $@
33         rm -rf $@.squashfs $@.fs
34 endef
35
36 define Build/netgear-uImage
37         $(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC))
38 endef
39
40 # combine kernel and rootfs into one image
41 # mktplinkfw <type> <optional extra arguments to mktplinkfw binary>
42 # <type> is "sysupgrade" or "factory"
43 #
44 # -a align the rootfs start on an <align> bytes boundary
45 # -j add jffs2 end-of-filesystem markers
46 # -s strip padding from end of the image
47 # -X reserve <size> bytes in the firmware image (hexval prefixed with 0x)
48 define Build/mktplinkfw
49         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
50                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) $2 \
51                 -k $(word 1,$^) \
52                 -r $@ \
53                 -o $@.new \
54                 -j -X 0x40000 \
55                 -a $(call rootfs_align,$(FILESYSTEM)) \
56                 $(if $(findstring sysupgrade,$1),-s) && mv $@.new $@ || rm -f $@
57 endef
58
59 define Build/mktplinkfw-chn-v2
60         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
61                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) -m 2 \
62                 -k $(word 1,$^) \
63                 -r $@ \
64                 -o $@.new \
65                 -j -X 0x40000 \
66                 -a $(call rootfs_align,$(FILESYSTEM)) \
67                 $(if $(findstring sysupgrade,$1),-s) && mv $@.new $@ || rm -f $@
68 endef
69
70 # mktplinkfw-initramfs <optional extra arguments to mktplinkfw binary>
71 #
72 # -c combined image
73 define Build/mktplinkfw-initramfs
74         $(STAGING_DIR_HOST)/bin/mktplinkfw \
75                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) $2 \
76                 -k $@ \
77                 -o $@.new \
78                 -s -S \
79                 -c
80         @mv $@.new $@
81 endef
82
83 define Build/mktplinkfw-initramfs-chn-v2
84         $(STAGING_DIR_HOST)/bin/mktplinkfw \
85                 -H $(TPLINK_HWID) -W $(TPLINK_HWREV) -F $(TPLINK_FLASHLAYOUT) -N OpenWrt -V $(REVISION) -m 2 \
86                 -k $@ \
87                 -o $@.new \
88                 -s -S \
89                 -c
90         @mv $@.new $@
91 endef
92
93 define Build/loader-common
94         rm -rf $@.src
95         $(MAKE) -C lzma-loader \
96                 PKG_BUILD_DIR="$@.src" \
97                 TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
98                 KERNEL_CMDLINE="$(CMDLINE)" BOARD="$(BOARDNAME)" \
99                 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
100                 $(1) compile loader.gz
101         mv "$@.gz" "$@"
102         rm -rf $@.src
103 endef
104
105 define Build/loader-okli-compile
106         $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0)
107 endef
108
109 define Build/loader-kernel
110         $(call Build/loader-common,LOADER_DATA="$@")
111 endef
112
113 define Build/loader-okli
114         dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
115         cat "$@" >> "$@.new"
116         mv "$@.new" "$@"
117 endef
118
119 define Build/copy-file
120         cat "$(1)" > "$@"
121 endef
122
123 DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT
124
125 # UBNT_BOARD e.g. one of (XS2, XS5, RS, XM)
126 # UBNT_TYPE e.g. one of (BZ, XM, XW)
127 # UBNT_CHIP e.g. one of (ar7240, ar933x, ar934x)
128
129 # mkubntimage is using the kernel image direct
130 # routerboard creates partitions out of the ubnt header
131 define Build/mkubntimage
132         $(STAGING_DIR_HOST)/bin/mkfwimage \
133                 -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
134                 -k $(word 1,$^) \
135                 -r $@ \
136                 -o $@
137 endef
138
139 # all UBNT XM device expect the kernel image to have 1024k while flash, when
140 # booting the image, the size doesn't matter.
141 define Build/mkubntimage-split
142         dd if=$@ of=$@.old1 bs=1024k count=1
143         dd if=$@ of=$@.old2 bs=1024k skip=1
144         $(STAGING_DIR_HOST)/bin/mkfwimage \
145                 -B $(UBNT_BOARD) -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
146                 -k $@.old1 \
147                 -r $@.old2 \
148                 -o $@
149         rm $@.old1 $@.old2
150 endef
151
152 define Build/mkubntimage2
153         $(STAGING_DIR_HOST)/bin/mkfwimage2 -f 0x9f000000 \
154                 -v $(UBNT_TYPE).$(UBNT_CHIP).v6.0.0-OpenWrt-$(REVISION) \
155                 -p jffs2:0x50000:0xf60000:0:0:$@ \
156                 -o $@.new
157         @mv $@.new $@
158 endef
159
160 DEVICE_VARS += UBNT_BOARD UBNT_CHIP UBNT_TYPE
161
162 define Build/mkubntkernelimage
163         rm -rf $(KDIR_TMP)/ubnt-$(KERNEL_IMAGE)/image && \
164                 mkdir -p $(KDIR_TMP)/ubnt-$(KERNEL_IMAGE)/image && \
165                 cp $@ $(KDIR_TMP)/ubnt-$(KERNEL_IMAGE)/image/kernel0 && \
166                 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
167                         --pad --big-endian --squash-uids -v -e 64KiB \
168                         -o $@.new \
169                         -d $(KDIR_TMP)/ubnt-$(KERNEL_IMAGE)/image \
170                         2>&1 && \
171                 $(STAGING_DIR_HOST)/bin/padjffs2 $@.new -J 64
172         -rm -rf $(KDIR_TMP)/ubnt-$(KERNEL_IMAGE)/image
173         @mv $@.new $@
174 endef
175
176 define Device/Default
177   BOARDNAME :=
178   DEVICE_PROFILE = $$(BOARDNAME)
179   PROFILES = Default Minimal $$(DEVICE_PROFILE)
180   MTDPARTS :=
181   IMAGES := sysupgrade.bin
182   BLOCKSIZE := 64k
183   FILESYSTEMS = $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-$$(BLOCKSIZE)
184   CONSOLE = ttyS0,115200
185   CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
186   KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
187   COMPILE :=
188   IMAGES := sysupgrade.bin
189   IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
190 endef
191
192 define Device/bsb
193   BOARDNAME = BSB
194   IMAGE_SIZE = 16000k
195   CONSOLE = ttyATH0,115200
196   MTDPARTS = spi0.0:128k(u-boot)ro,64k(u-boot-env)ro,16128k(firmware),64k(art)ro
197 endef
198 TARGET_DEVICES += bsb
199
200 define Device/carambola2
201   BOARDNAME = CARAMBOLA2
202   IMAGE_SIZE = 16000k
203   CONSOLE = ttyATH0,115200
204   MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro
205 endef
206 TARGET_DEVICES += carambola2
207
208 define Device/cf-e316n-v2
209   BOARDNAME = CF-E316N-V2
210   IMAGE_SIZE = 16192k
211   CONSOLE = ttyS0,115200
212   MTDPARTS = spi0.0:64k(u-boot)ro,64k(art)ro,16192k(firmware),64k(nvram)ro
213 endef
214 TARGET_DEVICES += cf-e316n-v2
215
216 define Device/weio
217   BOARDNAME = WEIO
218   IMAGE_SIZE = 16000k
219   CONSOLE = ttyATH0,115200
220   MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,16000k(firmware),64k(art)ro
221 endef
222 TARGET_DEVICES += weio
223
224 define Device/wndr3700
225   BOARDNAME = WNDR3700
226   NETGEAR_KERNEL_MAGIC = 0x33373030
227   NETGEAR_BOARD_ID = WNDR3700
228   IMAGE_SIZE = 7680k
229   MTDPARTS = spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,7680k(firmware),64k(art)ro
230   IMAGES := sysupgrade.bin factory.img factory-NA.img
231   KERNEL := kernel-bin | patch-cmdline | lzma -d20 | netgear-uImage lzma
232   IMAGE/default = append-kernel $$$$(BLOCKSIZE) | netgear-squashfs | append-rootfs | pad-rootfs
233   IMAGE/sysupgrade.bin = $$(IMAGE/default) | check-size $$$$(IMAGE_SIZE)
234   IMAGE/factory.img = $$(IMAGE/default) | netgear-dni | check-size $$$$(IMAGE_SIZE)
235   IMAGE/factory-NA.img = $$(IMAGE/default) | netgear-dni NA | check-size $$$$(IMAGE_SIZE)
236 endef
237
238 define Device/wndr3700v2
239 $(Device/wndr3700)
240   NETGEAR_BOARD_ID = WNDR3700v2
241   NETGEAR_KERNEL_MAGIC = 0x33373031
242   NETGEAR_HW_ID = 29763654+16+64
243   IMAGE_SIZE = 15872k
244   MTDPARTS = spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,15872k(firmware),64k(art)ro
245   IMAGES := sysupgrade.bin factory.img
246 endef
247
248 define Device/wndr3800
249 $(Device/wndr3700v2)
250   NETGEAR_BOARD_ID = WNDR3800
251   NETGEAR_HW_ID = 29763654+16+128
252 endef
253
254 define Device/wndr3800ch
255 $(Device/wndr3800)
256   NETGEAR_BOARD_ID = WNDR3800CH
257 endef
258
259 define Device/wndrmac
260 $(Device/wndr3700v2)
261   NETGEAR_BOARD_ID = WNDRMAC
262 endef
263
264 define Device/wndrmacv2
265 $(Device/wndr3800)
266   NETGEAR_BOARD_ID = WNDRMACv2
267 endef
268
269 TARGET_DEVICES += wndr3700 wndr3700v2 wndr3800 wndr3800ch wndrmac wndrmacv2
270
271 define Device/tplink
272   TPLINK_HWREV := 0x1
273   KERNEL := kernel-bin | patch-cmdline | lzma
274   KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | mktplinkfw-initramfs
275   IMAGES := sysupgrade.bin factory.bin
276   IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw sysupgrade
277   IMAGE/factory.bin := append-rootfs | mktplinkfw factory
278 endef
279
280 define Device/tplink-chn-v2
281   TPLINK_HWREV := 0x1
282   KERNEL := kernel-bin | patch-cmdline | lzma
283   KERNEL_INITRAMFS := kernel-bin | patch-cmdline | lzma | mktplinkfw-initramfs-chn-v2
284   IMAGES := sysupgrade.bin factory.bin
285   IMAGE/sysupgrade.bin := append-rootfs | mktplinkfw-chn-v2 sysupgrade
286   IMAGE/factory.bin := append-rootfs | mktplinkfw-chn-v2 factory
287 endef
288
289 define Device/tplink-nolzma
290 $(Device/tplink)
291   LOADER_FLASH_OFFS := 0x22000
292   COMPILE := loader-$(1).gz
293   COMPILE/loader-$(1).gz := loader-okli-compile
294   KERNEL := copy-file $(KDIR)/vmlinux.bin.lzma | uImage lzma -M 0x4f4b4c49 | loader-okli $(1)
295   KERNEL_INITRAMFS := copy-file $(KDIR)/vmlinux-initramfs.bin.lzma | loader-kernel | mktplinkfw-initramfs
296 endef
297
298 define Device/tplink-4m
299 $(Device/tplink-nolzma)
300   TPLINK_FLASHLAYOUT := 4M
301   IMAGE_SIZE := 3904k
302 endef
303
304 define Device/tplink-8m
305 $(Device/tplink-nolzma)
306   TPLINK_FLASHLAYOUT := 8M
307   IMAGE_SIZE := 7936k
308 endef
309
310 define Device/tplink-4mlzma
311 $(Device/tplink)
312   TPLINK_FLASHLAYOUT := 4Mlzma
313   IMAGE_SIZE := 3904k
314 endef
315
316 define Device/tplink-8mlzma
317 $(Device/tplink)
318   TPLINK_FLASHLAYOUT := 8Mlzma
319   IMAGE_SIZE := 7936k
320 endef
321
322 define Device/tplink-16mlzma
323 $(Device/tplink)
324   TPLINK_FLASHLAYOUT := 16Mlzma
325   IMAGE_SIZE := 15872k
326 endef
327
328 define Device/tplink-chn-v2-4mlzma
329 $(Device/tplink-chn-v2)
330   TPLINK_FLASHLAYOUT := 4Mlzma
331   IMAGE_SIZE := 3904k
332 endef
333
334 define Device/tl-wdr4300-v1
335 $(Device/tplink-8mlzma)
336   BOARDNAME = TL-WDR4300
337   DEVICE_PROFILE = TLWDR4300
338   TPLINK_HWID := 0x43000001
339 endef
340
341 define Device/tl-wdr3500-v1
342 $(Device/tl-wdr4300-v1)
343   BOARDNAME = TL-WDR3500
344   TPLINK_HWID := 0x35000001
345 endef
346
347 define Device/tl-wdr3600-v1
348 $(Device/tl-wdr4300-v1)
349   TPLINK_HWID := 0x36000001
350 endef
351
352 define Device/tl-wdr4300-v1-il
353 $(Device/tl-wdr4300-v1)
354   TPLINK_HWID := 0x43008001
355 endef
356
357 define Device/tl-wdr4310-v1
358 $(Device/tl-wdr4300-v1)
359   TPLINK_HWID := 0x43100001
360 endef
361
362 define Device/mw4530r-v1
363 $(Device/tl-wdr4300-v1)
364   TPLINK_HWID := 0x45300001
365 endef
366
367 define Device/tl-wdr3320-v2
368 $(Device/tplink-chn-v2-4mlzma)
369   BOARDNAME = TL-WDR3320-v2
370   DEVICE_PROFILE = TLWDR3320V2
371   TPLINK_HWID := 0x33200002
372 endef
373
374 TARGET_DEVICES += tl-wdr3500-v1 tl-wdr3600-v1 tl-wdr4300-v1 tl-wdr4300-v1-il tl-wdr4310-v1 mw4530r-v1 tl-wdr3320-v2
375
376 define Device/archer-c5
377     $(Device/tplink-16mlzma)
378     BOARDNAME := ARCHER-C5
379     DEVICE_PROFILE := ARCHERC7
380     TPLINK_HWID := 0xc5000001
381 endef
382
383 define Device/archer-c7-v1
384     $(Device/tplink-8mlzma)
385     BOARDNAME := ARCHER-C7
386     DEVICE_PROFILE := ARCHERC7
387     TPLINK_HWID := 0x75000001
388 endef
389
390 define Device/archer-c7-v2
391     $(Device/tplink-16mlzma)
392     BOARDNAME := ARCHER-C7
393     DEVICE_PROFILE := ARCHERC7
394     TPLINK_HWID := 0xc7000002
395 endef
396 TARGET_DEVICES += archer-c5 archer-c7-v1 archer-c7-v2
397
398 define Device/antminer-s1
399         $(Device/tplink-8mlzma)
400         BOARDNAME := ANTMINER-S1
401         DEVICE_PROFILE := ANTMINER_S1
402         TPLINK_HWID := 0x04440001
403         CONSOLE := ttyATH0,115200
404 endef
405
406 define Device/antminer-s3
407         $(Device/tplink-8mlzma)
408         BOARDNAME := ANTMINER-S3
409         DEVICE_PROFILE := ANTMINER_S3
410         TPLINK_HWID := 0x04440003
411         CONSOLE := ttyATH0,115200
412 endef
413
414 define Device/el-m150
415     $(Device/tplink-8mlzma)
416     BOARDNAME := EL-M150
417     DEVICE_PROFILE := ELM150
418     TPLINK_HWID := 0x01500101
419     CONSOLE := ttyATH0,115200
420 endef
421
422 define Device/el-mini
423     $(Device/tplink-8mlzma)
424     BOARDNAME := EL-MINI
425     DEVICE_PROFILE := ELMINI
426     TPLINK_HWID := 0x01530001
427     CONSOLE := ttyATH0,115200
428 endef
429 TARGET_DEVICES += antminer-s1 antminer-s3 el-m150 el-mini
430
431 define Device/gl-inet-6408A-v1
432     $(Device/tplink-8mlzma)
433     BOARDNAME := GL-INET
434     DEVICE_PROFILE := GLINET
435     TPLINK_HWID := 0x08000001
436     CONSOLE := ttyATH0,115200
437 endef
438
439 define Device/gl-inet-6416A-v1
440     $(Device/tplink-16mlzma)
441     BOARDNAME := GL-INET
442     DEVICE_PROFILE := GLINET
443     TPLINK_HWID := 0x08000001
444     CONSOLE := ttyATH0,115200
445 endef
446 TARGET_DEVICES += gl-inet-6408A-v1 gl-inet-6416A-v1
447
448 define Device/mc-mac1200r
449     $(Device/tplink-8mlzma)
450     BOARDNAME := MC-MAC1200R
451     DEVICE_PROFILE := MAC1200R
452     TPLINK_HWID := 0x12000001
453 endef
454 TARGET_DEVICES += mc-mac1200r
455
456 define Device/onion-omega
457     $(Device/tplink-16mlzma)
458     BOARDNAME := ONION-OMEGA
459     DEVICE_PROFILE := OMEGA
460     TPLINK_HWID := 0x04700001
461     CONSOLE := ttyATH0,115200
462 endef
463 TARGET_DEVICES += onion-omega
464
465 define Device/tl-mr10u-v1
466     $(Device/tplink-4mlzma)
467     BOARDNAME := TL-MR10U
468     DEVICE_PROFILE := TLMR10U
469     TPLINK_HWID := 0x00100101
470     CONSOLE := ttyATH0,115200
471 endef
472
473 define Device/tl-mr11u-v1
474     $(Device/tplink-4mlzma)
475     BOARDNAME := TL-MR11U
476     DEVICE_PROFILE := TLMR11U
477     TPLINK_HWID := 0x00110101
478     CONSOLE := ttyATH0,115200
479 endef
480
481 define Device/tl-mr11u-v2
482     $(Device/tplink-4mlzma)
483     BOARDNAME := TL-MR11U
484     DEVICE_PROFILE := TLMR11U
485     TPLINK_HWID := 0x00110102
486     CONSOLE := ttyATH0,115200
487 endef
488
489 define Device/tl-mr12u-v1
490     $(Device/tplink-4mlzma)
491     BOARDNAME := TL-MR13U
492     DEVICE_PROFILE := TLMR12U
493     TPLINK_HWID := 0x00120101
494     CONSOLE := ttyATH0,115200
495 endef
496
497 define Device/tl-mr13u-v1
498     $(Device/tplink-4mlzma)
499     BOARDNAME := TL-MR13U
500     DEVICE_PROFILE := TLMR13U
501     TPLINK_HWID := 0x00130101
502     CONSOLE := ttyATH0,115200
503 endef
504 TARGET_DEVICES += tl-mr10u-v1 tl-mr11u-v1 tl-mr11u-v2 tl-mr12u-v1 tl-mr13u-v1
505
506 define Device/tl-mr3020-v1
507     $(Device/tplink-4mlzma)
508     BOARDNAME := TL-MR3020
509     DEVICE_PROFILE := TLMR3020
510     TPLINK_HWID := 0x30200001
511     CONSOLE := ttyATH0,115200
512 endef
513
514 define Device/tl-mr3040-v1
515     $(Device/tplink-4mlzma)
516     BOARDNAME := TL-MR3040
517     DEVICE_PROFILE := TLMR3040
518     TPLINK_HWID := 0x30400001
519     CONSOLE := ttyATH0,115200
520 endef
521
522 define Device/tl-mr3040-v2
523     $(Device/tplink-4mlzma)
524     BOARDNAME := TL-MR3040-v2
525     DEVICE_PROFILE := TLMR3040
526     TPLINK_HWID := 0x30400002
527     CONSOLE := ttyATH0,115200
528 endef
529
530 define Device/tl-mr3220-v2
531     $(Device/tplink-4mlzma)
532     BOARDNAME := TL-MR3220-v2
533     DEVICE_PROFILE := TLMR3220
534     TPLINK_HWID := 0x32200002
535     CONSOLE := ttyATH0,115200
536 endef
537
538 define Device/tl-mr3420-v2
539     $(Device/tplink-4mlzma)
540     BOARDNAME := TL-MR3420-v2
541     DEVICE_PROFILE := TLMR3420
542     TPLINK_HWID := 0x34200002
543 endef
544 TARGET_DEVICES += tl-mr3020-v1 tl-mr3040-v1 tl-mr3040-v2 tl-mr3220-v2 tl-mr3420-v2
545
546 define Device/tl-wr703n-v1
547     $(Device/tplink-4mlzma)
548     BOARDNAME := TL-WR703N
549     DEVICE_PROFILE := TLWR703
550     TPLINK_HWID := 0x07030101
551     CONSOLE := ttyATH0,115200
552 endef
553
554 define Device/tl-wr710n-v1
555     $(Device/tplink-8mlzma)
556     BOARDNAME := TL-WR710N
557     DEVICE_PROFILE := TLWR710
558     TPLINK_HWID := 0x07100001
559     CONSOLE := ttyATH0,115200
560 endef
561
562 define Device/tl-wr710n-v2
563     $(Device/tplink-4mlzma)
564     BOARDNAME := TL-WR710N
565     DEVICE_PROFILE := TLWR710
566     TPLINK_HWID := 0x07100002
567     CONSOLE := ttyATH0,115200
568 endef
569
570 define Device/tl-wr720n-v3
571     $(Device/tplink-4mlzma)
572     BOARDNAME := TL-WR720N-v3
573     DEVICE_PROFILE := TLWR720
574     TPLINK_HWID := 0x07200103
575     CONSOLE := ttyATH0,115200
576 endef
577
578 define Device/tl-wr720n-v4
579     $(Device/tplink-4mlzma)
580     BOARDNAME := TL-WR720N-v3
581     DEVICE_PROFILE := TLWR720
582     TPLINK_HWID := 0x07200104
583     CONSOLE := ttyATH0,115200
584 endef
585 TARGET_DEVICES += tl-wr703n-v1 tl-wr710n-v1 tl-wr710n-v2 tl-wr720n-v3 tl-wr720n-v4
586
587 define Device/tl-wr740n-v4
588     $(Device/tplink-4mlzma)
589     BOARDNAME := TL-WR741ND-v4
590     DEVICE_PROFILE := TLWR740
591     TPLINK_HWID := 0x07400004
592     CONSOLE := ttyATH0,115200
593 endef
594
595 define Device/tl-wr740n-v5
596     $(Device/tplink-4mlzma)
597     BOARDNAME := TL-WR741ND-v4
598     DEVICE_PROFILE := TLWR740
599     TPLINK_HWID := 0x07400005
600     CONSOLE := ttyATH0,115200
601 endef
602
603 define Device/tl-wr741nd-v1
604     $(Device/tplink-4m)
605     BOARDNAME := TL-WR741ND
606     DEVICE_PROFILE := TLWR741
607     TPLINK_HWID := 0x07410001
608 endef
609
610 define Device/tl-wr741nd-v2
611     $(Device/tplink-4m)
612     BOARDNAME := TL-WR741ND
613     DEVICE_PROFILE := TLWR741
614     TPLINK_HWID := 0x07410001
615 endef
616
617 define Device/tl-wr741nd-v4
618     $(Device/tplink-4mlzma)
619     BOARDNAME := TL-WR741ND-v4
620     DEVICE_PROFILE := TLWR741
621     TPLINK_HWID := 0x07410004
622     CONSOLE := ttyATH0,115200
623 endef
624
625 define Device/tl-wr741nd-v5
626     $(Device/tplink-4mlzma)
627     BOARDNAME := TL-WR741ND-v4
628     DEVICE_PROFILE := TLWR741
629     TPLINK_HWID := 0x07400005
630     CONSOLE := ttyATH0,115200
631 endef
632
633 define Device/tl-wr743nd-v2
634     $(Device/tplink-4mlzma)
635     BOARDNAME := TL-WR741ND-v4
636     DEVICE_PROFILE := TLWR743
637     TPLINK_HWID := 0x07430002
638     CONSOLE := ttyATH0,115200
639 endef
640 TARGET_DEVICES += tl-wr740n-v4 tl-wr740n-v5 tl-wr741nd-v1 tl-wr741nd-v2 tl-wr741nd-v4 tl-wr741nd-v5 tl-wr743nd-v2
641
642 define Device/tl-wr841n-v8
643     $(Device/tplink-4mlzma)
644     BOARDNAME := TL-WR841N-v8
645     DEVICE_PROFILE := TLWR841
646     TPLINK_HWID := 0x08410008
647 endef
648
649 define Device/tl-wr841n-v9
650     $(Device/tplink-4mlzma)
651     BOARDNAME := TL-WR841N-v9
652     DEVICE_PROFILE := TLWR841
653     TPLINK_HWID := 0x08410009
654 endef
655
656 define Device/tl-wr842n-v2
657     $(Device/tplink-8mlzma)
658     BOARDNAME := TL-WR842N-v2
659     DEVICE_PROFILE := TLWR842
660     TPLINK_HWID := 0x8420002
661 endef
662
663 define Device/tl-wr843nd-v1
664     $(Device/tplink-4mlzma)
665     BOARDNAME := TL-WR841N-v8
666     DEVICE_PROFILE := TLWR843
667     TPLINK_HWID := 0x08430001
668 endef
669
670 define Device/tl-wr847n-v8
671     $(Device/tplink-4mlzma)
672     BOARDNAME := TL-WR841N-v8
673     DEVICE_PROFILE := TLWR841
674     TPLINK_HWID := 0x08470008
675 endef
676 TARGET_DEVICES += tl-wr841n-v8 tl-wr841n-v9 tl-wr842n-v2 tl-wr843nd-v1 tl-wr847n-v8
677
678 define Device/tl-wr941nd-v5
679     $(Device/tplink-4mlzma)
680     BOARDNAME := TL-WR941ND-v5
681     DEVICE_PROFILE := TLWR941
682     TPLINK_HWID := 0x09410005
683 endef
684
685 # Chinese version (unlike European) is similar to the TL-WDR3500
686 define Device/tl-wr941nd-v6-cn
687     $(Device/tplink-4mlzma)
688     BOARDNAME := TL-WDR3500
689     DEVICE_PROFILE := TLWR941
690     TPLINK_HWID := 0x09410006
691 endef
692 TARGET_DEVICES += tl-wr941nd-v5 tl-wr941nd-v6-cn
693
694 define Device/tl-wr1041n-v2
695     $(Device/tplink-4mlzma)
696     BOARDNAME := TL-WR1041N-v2
697     DEVICE_PROFILE := TLWR1041
698     TPLINK_HWID := 0x10410002
699 endef
700 TARGET_DEVICES += tl-wr1041n-v2
701
702 define Device/tl-wdr4900-v2
703     $(Device/tplink-8mlzma)
704     BOARDNAME := TL-WDR4900-v2
705     DEVICE_PROFILE := TLWDR4900V2
706     TPLINK_HWID := 0x49000002
707 endef
708 TARGET_DEVICES += tl-wdr4900-v2
709
710 define Device/tl-wa701nd-v2
711     $(Device/tplink-4mlzma)
712     BOARDNAME := TL-WA701ND-v2
713     DEVICE_PROFILE := TLWA701
714     TPLINK_HWID := 0x07010002
715     CONSOLE := ttyATH0,115200
716 endef
717
718 define Device/tl-wa750re-v1
719     $(Device/tplink-4mlzma)
720     BOARDNAME := TL-WA750RE
721     DEVICE_PROFILE := TLWA750
722     TPLINK_HWID := 0x07500001
723 endef
724 TARGET_DEVICES += tl-wa701nd-v2 tl-wa750re-v1
725
726 define Device/tl-wa801nd-v2
727     $(Device/tplink-4mlzma)
728     BOARDNAME := TL-WA801ND-v2
729     DEVICE_PROFILE := TLWA801
730     TPLINK_HWID := 0x08010002
731 endef
732
733 define Device/tl-wa830re-v2
734     $(Device/tplink-4mlzma)
735     BOARDNAME := TL-WA830RE-v2
736     DEVICE_PROFILE := TLWA830
737     TPLINK_HWID := 0x08300002
738 endef
739
740 define Device/tl-wa850re-v1
741     $(Device/tplink-4mlzma)
742     BOARDNAME := TL-WA850RE
743     DEVICE_PROFILE := TLWA850
744     TPLINK_HWID := 0x08500001
745 endef
746
747 define Device/tl-wa860re-v1
748     $(Device/tplink-4mlzma)
749     BOARDNAME := TL-WA860RE
750     DEVICE_PROFILE := TLWA860
751     TPLINK_HWID := 0x08600001
752 endef
753 TARGET_DEVICES += tl-wa801nd-v2 tl-wa830re-v2 tl-wa850re-v1 tl-wa860re-v1
754
755 define Device/tl-wa901nd-v3
756     $(Device/tplink-4mlzma)
757     BOARDNAME := TL-WA901ND-v3
758     DEVICE_PROFILE := TLWA901
759     TPLINK_HWID := 0x09010003
760 endef
761 TARGET_DEVICES += tl-wa901nd-v3
762
763 define Device/tl-wa7210n-v2
764     $(Device/tplink-4mlzma)
765     BOARDNAME := TL-WA7210N-v2
766     DEVICE_PROFILE := TLWA7210
767     TPLINK_HWID := 0x72100002
768     CONSOLE := ttyATH0,115200
769 endef
770 TARGET_DEVICES += tl-wa7210n-v2
771
772 define Device/smart-300
773     $(Device/tplink-8mlzma)
774     BOARDNAME := SMART-300
775     DEVICE_PROFILE := SMART-300
776     TPLINK_HWID := 0x93410001
777 endef
778 TARGET_DEVICES += smart-300
779
780 define Device/oolite
781     $(Device/tplink-16mlzma)
782     BOARDNAME := GS-OOLITE
783     DEVICE_PROFILE := OOLITE
784     TPLINK_HWID := 0x3C000101
785     CONSOLE := ttyATH0,115200
786 endef
787 TARGET_DEVICES += oolite
788
789 # UBNT_BOARD e.g. one of (XS2, XS5, RS, XM)
790 # UBNT_TYPE e.g. one of (BZ, XM, XW)
791 # UBNT_CHIP e.g. one of (ar7240, ar933x, ar934x)
792 define Device/ubnt-xm
793   DEVICE_PROFILE := UBNT
794   IMAGE_SIZE := 7552k
795   MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
796   UBNT_TYPE := XM
797   UBNT_BOARD := XM
798   UBNT_CHIP := ar7240
799   IMAGES := sysupgrade.bin factory.bin
800   IMAGE/factory.bin = $$(IMAGE/sysupgrade.bin) | mkubntimage-split
801   IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
802 endef
803
804 define Device/ubnt-xw
805   DEVICE_PROFILE := UBNT
806   IMAGE_SIZE := 7552k
807   MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
808   UBNT_TYPE := XW
809   UBNT_BOARD := XM
810   UBNT_CHIP := ar934x
811   IMAGES := sysupgrade.bin factory.bin
812   IMAGE/factory.bin = $$(IMAGE/sysupgrade.bin) | mkubntimage-split
813   IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
814 endef
815
816 define Device/ubnt-bz
817   DEVICE_PROFILE := UBNT
818   IMAGE_SIZE := 7552k
819   MTDPARTS = spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
820   UBNT_TYPE := BZ
821   UBNT_BOARD := XM
822   UBNT_CHIP := ar934x
823   IMAGES := sysupgrade.bin factory.bin
824   IMAGE/factory.bin = $$(IMAGE/sysupgrade.bin) | mkubntimage-split
825   IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
826 endef
827
828 define Device/rw2458n
829   $(Device/ubnt-xm)
830   BOARDNAME := RW2458N
831 endef
832
833 define Device/ubnt-airrouter
834   $(Device/ubnt-xm)
835   BOARDNAME := UBNT-AR
836 endef
837
838 define Device/ubnt-bullet-m
839   $(Device/ubnt-xm)
840   BOARDNAME := UBNT-BM
841 endef
842
843 define Device/ubnt-rocket-m
844   $(Device/ubnt-xm)
845   BOARDNAME := UBNT-RM
846 endef
847
848 define Device/ubnt-nano-m
849   $(Device/ubnt-xm)
850   BOARDNAME := UBNT-NM
851 endef
852 TARGET_DEVICES += rw2458n ubnt-airrouter ubnt-bullet-m ubnt-rocket-m ubnt-nano-m
853
854 define Device/ubnt-unifi
855   $(Device/ubnt-bz)
856   BOARDNAME := UBNT-UF
857   DEVICE_PROFILE := UBNT UBNTUNIFI
858 endef
859
860 define Device/ubnt-unifi-outdoor
861   $(Device/ubnt-bz)
862   BOARDNAME := UBNT-U20
863   DEVICE_PROFILE := UBNT UBNTUNIFIOUTDOOR
864 endef
865 TARGET_DEVICES += ubnt-unifi ubnt-unifi-outdoor
866
867 define Device/ubnt-nano-m-xw
868   $(Device/ubnt-xw)
869   BOARDNAME := UBNT-NM-XW
870 endef
871
872 define Device/ubnt-loco-m-xw
873   $(Device/ubnt-xw)
874   BOARDNAME := UBNT-LOCO-XW
875 endef
876
877 define Device/ubnt-rocket-m-xw
878   $(Device/ubnt-xw)
879   BOARDNAME := UBNT-RM-XW
880 endef
881
882 define Device/ubnt-rocket-m-ti
883   $(Device/ubnt-xw)
884   BOARDNAME := UBNT-RM-TI
885   UBNT_TYPE := TI
886   UBNT_BOARD := XM
887 endef
888 TARGET_DEVICES += ubnt-nano-m-xw ubnt-loco-m-xw ubnt-rocket-m-xw ubnt-rocket-m-ti
889
890 define Device/ubnt-air-gateway
891   $(Device/ubnt-xm)
892   BOARDNAME := UBNT-AGW
893   UBNT_BOARD := XM
894   UBNT_TYPE := AirGW
895   UBNT_CHIP := ar933x
896   CONSOLE = ttyATH0,115200
897 endef
898 TARGET_DEVICES += ubnt-air-gateway
899
900 define Device/ubnt-air-gateway-pro
901   $(Device/ubnt-xm)
902   BOARDNAME := UBNT-AGWP
903   UBNT_TYPE := AirGWP
904   UBNT_CHIP := ar934x
905   CONSOLE = ttyS0,115200
906 endef
907 TARGET_DEVICES += ubnt-air-gateway-pro
908
909 define Device/ubdev01
910   $(Device/ubnt-xm)
911   MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
912   BOARDNAME := UBNT-UF
913   UBNT_BOARD := XM
914   UBNT_TYPE := XM
915   UBNT_CHIP := ar7240
916 endef
917
918 TARGET_DEVICES += ubdev01
919
920 define Device/ubnt-routerstation
921   IMAGE_SIZE := 16128k
922   IMAGES := sysupgrade.bin factory.bin
923   IMAGE/factory.bin = append-rootfs | pad-rootfs | mkubntimage
924   IMAGE/sysupgrade.bin = append-rootfs | pad-rootfs | combined-image | check-size $$$$(IMAGE_SIZE)
925   KERNEL := kernel-bin | patch-cmdline | lzma | pad-to $$(BLOCKSIZE)
926 endef
927
928 define Device/ubnt-rs
929 $(Device/ubnt-routerstation)
930   BOARDNAME := UBNT-RS
931   DEVICE_PROFILE := Madwifi UBNT UBNTRS
932   UBNT_BOARD := RS
933   UBNT_TYPE := RSx
934   UBNT_CHIP := ar7100
935 endef
936
937 define Device/ubnt-rspro
938 $(Device/ubnt-routerstation)
939   BOARDNAME := UBNT-RSPRO
940   DEVICE_PROFILE := Madwifi UBNT UBNTRSPRO
941   UBNT_BOARD := RSPRO
942   UBNT_TYPE := RSPRO
943   UBNT_CHIP := ar7100pro
944 endef
945
946 define Device/ubnt-ls-sr71
947 $(Device/ubnt-routerstation)
948   BOARDNAME := UBNT-LS-SR71
949   DEVICE_PROFILE := Madwifi UBNT
950   UBNT_BOARD := LS-SR71
951   UBNT_TYPE := LS-SR71
952   UBNT_CHIP := ar7100
953 endef
954
955 TARGET_DEVICES += ubnt-rs ubnt-rspro ubnt-ls-sr71
956
957 define Device/ubnt-uap-pro
958   IMAGE_SIZE := 15744k
959   MTDPARTS := spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1536k(kernel),14208k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
960   UBNT_TYPE := BZ
961   UBNT_CHIP := ar934x
962   BOARDNAME := UAP-PRO
963   DEVICE_PROFILE := UBNT UAPPRO
964   KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma | mkubntkernelimage
965   IMAGES := sysupgrade.bin factory.bin
966   IMAGE/sysupgrade.bin = append-kernel 1536k | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
967   IMAGE/factory.bin = $$(IMAGE/sysupgrade.bin) | mkubntimage2
968 endef
969
970 define Device/ubnt-unifi-outdoor-plus
971 $(Device/ubnt-uap-pro)
972   UBNT_CHIP := ar7240
973   BOARDNAME := UBNT-UOP
974   DEVICE_PROFILE := UBNT
975 endef
976
977 TARGET_DEVICES += ubnt-uap-pro ubnt-unifi-outdoor-plus
978
979 rootfs_type=$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
980
981 # $(1): rootfs type.
982 # $(2): board name.
983 define imgname
984 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(call rootfs_type,$(1))
985 endef
986
987 define rootfs_align
988 $(patsubst %-256k,0x40000,$(patsubst %-128k,0x20000,$(patsubst %-64k,0x10000,$(patsubst squashfs%,0x4,$(patsubst root.%,%,$(1))))))
989 endef
990
991 define sysupname
992 $(call imgname,$(1),$(2))-sysupgrade.bin
993 endef
994
995 define factoryname
996 $(call imgname,$(1),$(2))-factory.bin
997 endef
998
999 COMMA:=,
1000
1001 define mkcmdline
1002 $(if $(1),board=$(1) )$(if $(2),console=$(2)$(COMMA)$(3))
1003 endef
1004
1005 define mtdpartsize
1006 $(shell sz=`echo '$(2)' | sed -ne 's/.*[:$(COMMA)]\([0-9]*\)k[@]*[0-9a-zx]*($(1)).*/\1/p'`; [ -n "$$sz" ] && echo $$(($$sz * 1024)))
1007 endef
1008
1009 SINGLE_PROFILES:=
1010
1011 # $(1)      : name of image build method to be used, e.g., TPLINK-LZMA, AthLzma.
1012 # $(2)      : name of the build template to be used, e.g. 64k, 64kraw, 128k, etc.
1013 # $(3)      : name of the profile to be defined.
1014 # $(4)      : board name.
1015 # $(5)~$(7) : arguments for $(mkcmdline)
1016 #               board=$(1) console=$(2),$(3)
1017 # $(8)~$(14): extra arguments.
1018 define SingleProfile
1019   # $(1): action name, e.g. loader, buildkernel, squashfs, etc.
1020   define Image/Build/Profile/$(3)
1021         $$(call Image/Build/Template/$(2)/$$(1),$(1),$(4),$$(call mkcmdline,$(5),$(6),$(7)),$(8),$(9),$(10),$(11),$(12),$(13),$(14))
1022   endef
1023   SINGLE_PROFILES += $(3)
1024 endef
1025
1026 # $(1), name of the MultiProfile to be added.
1027 # $(2), name of Profiles to be included in the MultiProfile.
1028 define MultiProfile
1029   define Image/Build/Profile/$(1)
1030         $(foreach p,$(2),
1031                 $$(call Image/Build/Profile/$p,$$(1))
1032         )
1033   endef
1034 endef
1035
1036 LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR)
1037
1038 VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
1039 UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
1040
1041 # $(1): input file.
1042 # $(2): output file.
1043 # $(3): extra arguments for lzma.
1044 define CompressLzma
1045   $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(3) $(2)
1046 endef
1047
1048 define PatchKernel
1049         cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1)
1050         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))"
1051 endef
1052
1053 define PatchKernel/initramfs
1054         $(call PatchKernel,$(1),$(2),-initramfs)
1055         cp $(KDIR_TMP)/vmlinux-initramfs-$(1) $(call imgname,initramfs,$(1)).bin
1056 endef
1057
1058 # $(1): board name.
1059 # $(2): kernel command line.
1060 # $(3): extra argumetns for lzma.
1061 # $(4): name suffix, e.g. "-initramfs".
1062 define PatchKernelLzma
1063         cp $(KDIR)/vmlinux$(4) $(KDIR_TMP)/vmlinux$(4)-$(1)
1064         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(4)-$(1) "$(strip $(2))"
1065         $(call CompressLzma,$(KDIR_TMP)/vmlinux$(4)-$(1),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(3))
1066 endef
1067
1068 define PatchKernelGzip
1069         cp $(KDIR)/vmlinux$(3) $(KDIR_TMP)/vmlinux$(3)-$(1)
1070         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR_TMP)/vmlinux$(3)-$(1) "$(strip $(2))"
1071         gzip -9n -c $(KDIR_TMP)/vmlinux$(3)-$(1) > $(KDIR_TMP)/vmlinux$(3)-$(1).bin.gz
1072 endef
1073
1074 ifneq ($(SUBTARGET),mikrotik)
1075 # $(1): compression method of the data.
1076 # $(2): extra arguments.
1077 # $(3): input data file.
1078 # $(4): output file.
1079 define MkuImage
1080         mkimage -A mips -O linux -T kernel -a 0x80060000 -C $(1) $(2) \
1081                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
1082                 -d $(3) $(4)
1083 endef
1084
1085 # $(1): board name.
1086 # $(2): kernel command line.
1087 # $(3): extra arguments for lzma.
1088 # $(4): name suffix, e.g. "-initramfs".
1089 # $(5): extra arguments for mkimage.
1090 define MkuImageLzma
1091         $(call PatchKernelLzma,$(1),$(2),$(3),$(4))
1092         $(call MkuImage,lzma,$(5),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(KDIR_TMP)/vmlinux$(4)-$(1).uImage)
1093 endef
1094
1095 define MkuImageLzma/initramfs
1096         $(call PatchKernelLzma,$(1),$(2),$(3),-initramfs)
1097         $(call MkuImage,lzma,$(4),$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.lzma,$(call imgname,initramfs,$(1))-uImage.bin)
1098 endef
1099
1100 define MkuImageGzip
1101         $(call PatchKernelGzip,$(1),$(2))
1102         $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-$(1).bin.gz,$(KDIR_TMP)/vmlinux-$(1).uImage)
1103 endef
1104
1105 define MkuImageGzip/initramfs
1106         $(call PatchKernelGzip,$(1),$(2),-initramfs)
1107         $(call MkuImage,gzip,,$(KDIR_TMP)/vmlinux-initramfs-$(1).bin.gz,$(call imgname,initramfs,$(1))-uImage.bin)
1108 endef
1109
1110 define MkuImageOKLI
1111         $(call MkuImage,lzma,-M 0x4f4b4c49,$(KDIR)/vmlinux.bin.lzma,$(KDIR_TMP)/vmlinux-$(1).okli)
1112 endef
1113 endif
1114
1115 # $(1): name of the 1st file.
1116 # $(2): size limit of the 1st file if it is greater than 262144, or
1117 #       the erase size of the flash if it is greater than zero and less
1118 #       than 262144
1119 # $(3): name of the 2nd file.
1120 # $(4): size limit of the 2nd file if $(2) is greater than 262144, otherwise
1121 #       it is the size limit of the output file
1122 # $(5): name of the output file.
1123 # $(6): padding size.
1124 define CatFiles
1125         if [ $(2) -eq 0 ]; then \
1126                 filename="$(3)"; fstype=$$$${filename##*\.}; \
1127                 case "$$$${fstype}" in \
1128                 "jffs2-64k") bs=65536;; \
1129                 "jffs2-128k") bs=131072;; \
1130                 "jffs2-256k") bs=262144;; \
1131                 *) bs=`stat -c%s $(1)`;; \
1132                 esac; \
1133                 ( dd if=$(1) bs=$$$${bs} conv=sync;  cat $(3) ) > $(5); \
1134                 if [ -n "$(6)" ]; then \
1135                         case "$$$${fstype}" in \
1136                         squashfs*) \
1137                                 padjffs2 $(5) $(6); \
1138                                 ;; \
1139                         esac; \
1140                 fi; \
1141                 if [ `stat -c%s $(5)` -gt $(4) ]; then \
1142                         echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
1143                         rm -f $(5); \
1144                 fi; \
1145         else if [ $(2) -gt 262144 ]; then \
1146                 if [ `stat -c%s "$(1)"` -gt $(2) ]; then \
1147                         echo "Warning: $(1) is too big (> $(2) bytes)" >&2; \
1148                 else if [ `stat -c%s $(3)` -gt $(4) ]; then \
1149                         echo "Warning: $(3) is too big (> $(4) bytes)" >&2; \
1150                 else \
1151                         ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
1152                 fi; fi; \
1153         else \
1154                 ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
1155                 if [ `stat -c%s $(5)` -gt $(4) ]; then \
1156                         echo "Warning: $(5) is too big (> $(4) bytes)" >&2; \
1157                         rm -f $(5); \
1158                 fi; \
1159         fi; fi
1160 endef
1161
1162 # $(1): rootfs type.
1163 # $(2): board name.
1164 # $(3): kernel image size limit.
1165 # $(4): rootfs image size limit.
1166 # $(5): padding argument for padjffs2.
1167 Sysupgrade/KR=$(call CatFiles,$(2),$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(5)))
1168 Sysupgrade/KRuImage=$(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(2)),$(5))
1169 Sysupgrade/RKuImage=$(call CatFiles,$(KDIR)/root.$(1),$(4),$(KDIR_TMP)/vmlinux-$(2).uImage,$(3),$(call sysupname,$(1),$(2)))
1170
1171 # $(1): ubinize ini file
1172 # $(2): working directory
1173 # $(3): output file
1174 # $(4): physical erase block size
1175 # $(5): minimum I/O unit size
1176 # $(6): custom options
1177 define ubinize
1178         $(CP) $(1) $(2)
1179         ( cd $(2); $(STAGING_DIR_HOST)/bin/ubinize -o $(3) -p $(4) -m $(5) $(6) $(1))
1180 endef
1181
1182 #
1183 # Embed lzma-compressed kernel inside lzma-loader.
1184 #
1185 # $(1), suffix of output filename, e.g. generic, lowercase board name, etc.
1186 # $(2), suffix of target file to build, e.g. bin, gz, elf
1187 # $(3), kernel command line to pass from lzma-loader to kernel
1188 # $(4), unused here
1189 # $(5), suffix of kernel filename, e.g. -initramfs, or empty
1190 define Image/BuildLoader
1191         -rm -rf $(KDIR)/lzma-loader
1192         $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)"\
1193                 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
1194                 LOADER_DATA="$(KDIR)/vmlinux$(5).bin.lzma" BOARD="$(1)" \
1195                 compile loader.$(2)
1196         -$(CP) $(KDIR)/loader-$(1).$(2) $(KDIR)/loader-$(1)$(5).$(2)
1197 endef
1198
1199 #
1200 # Embed patched lzma-compressed kernel inside lzma-loader.
1201 #
1202 # Specifying the command line via the lzma-loader doesn't work with some
1203 # models (like the TP-LINK CPE series), so this version first patches the
1204 # command line in the image and then builds the loader around it.
1205 #
1206 # $(1), suffix of output filename, e.g. generic, lowercase board name, etc.
1207 # $(2), suffix of target file to build, e.g. bin, gz, elf
1208 # $(3), kernel command line to pass from lzma-loader to kernel
1209 # $(4), unused here
1210 # $(5), suffix of kernel filename, e.g. -initramfs, or empty
1211 define Image/BuildLoaderPatched
1212         $(call PatchKernelLzma,$(1),$(3))
1213         -rm -rf $(KDIR)/lzma-loader
1214         $(LOADER_MAKE) LOADER=loader-$(1).$(2) \
1215                 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
1216                 LOADER_DATA="$(KDIR_TMP)/vmlinux-$(1)$(5).bin.lzma" BOARD="$(1)" \
1217                 compile loader.$(2)
1218         -$(CP) $(KDIR)/loader-$(1).$(2) $(KDIR)/loader-$(1)$(5).$(2)
1219 endef
1220
1221 #
1222 # Build lzma-loader alone which will search for lzma-compressed kernel identified by
1223 # uImage header with magic "OKLI" at boot time.
1224 #
1225 # $(4), offset into the flash space to start searching uImage magic "OKLI".
1226 # $(5), size of search range starting at $(4).  With 0 as the value, uImage
1227 #       header is expected to be at precisely $(4)
1228 define Image/BuildLoaderAlone
1229         -rm -rf $(KDIR)/lzma-loader
1230         $(LOADER_MAKE) LOADER=loader-$(1).$(2) KERNEL_CMDLINE="$(3)" \
1231                 LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
1232                 BOARD="$(1)" FLASH_OFFS=$(4) FLASH_MAX=$(5) \
1233                 compile loader.$(2)
1234 endef
1235
1236 define Build/Clean
1237         $(LOADER_MAKE) clean
1238 endef
1239
1240
1241 alfa_ap96_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13312k(rootfs),2048k(kernel),512k(caldata)ro,15360k@0x80000(firmware)
1242 alfa_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
1243 alfa_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,15936k(firmware),64k(nvram),64k(art)ro
1244 all0258n_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),6272k(firmware),1536k(failsafe),64k(art)
1245 all0315n_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env),13568k(firmware),2048k(failsafe),256k(art)ro
1246 ap81_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,5120k(rootfs),2688k(kernel),64k(art)ro,7808k@0x50000(firmware)
1247 ap83_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,128k(u-boot-env)ro,4096k(rootfs),3648k(kernel),64k(art)ro,7744k@0x60000(firmware)
1248 ap96_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1728k(kernel),64k(art)ro,7872k@0x40000(firmware)
1249 ap113_mtd_layout=mtdparts=spi0.0:64k(u-boot),3008k(rootfs),896k(uImage),64k(NVRAM),64k(ART),3904k@0x10000(firmware)
1250 ap121_mtdlayout_2M=mtdparts=spi0.0:64k(u-boot)ro,1216k(rootfs),704k(kernel),64k(art)ro,1920k@0x10000(firmware)
1251 ap121_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2448k(rootfs),1200k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
1252 ap121_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6144k(rootfs),1600k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
1253 ap132_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),6400k(rootfs),64k(art),7808k@0x50000(firmware)
1254 ap135_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware)
1255 ap136_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(mib0),64k(art)ro,7744k@0x50000(firmware)
1256 ap143_mtdlayout_8M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1472k(kernel),64k(art)ro,7744k@0x50000(firmware)
1257 ap143_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware)
1258 ap147_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art),16000k@0x50000(firmware)
1259 ap152_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,14528k(rootfs),1472k(kernel),64k(art)ro,16000k@0x50000(firmware)
1260 bxu2000n2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),8448k(rootfs),6016k(user),64k(cfg),64k(oem),64k(art)ro
1261 cameo_ap81_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,3840k(firmware),64k(art)ro
1262 cameo_ap91_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3712k(firmware),64k(mac)ro,64k(art)ro
1263 cameo_ap99_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,3520k(firmware),64k(mac)ro,192k(lp)ro,64k(art)ro
1264 cameo_ap121_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,192k(language)ro,3648k(firmware)
1265 cameo_ap121_mtdlayout_8M=mtdparts=spi0.0:64k(u-boot)ro,64k(art)ro,64k(mac)ro,64k(nvram)ro,256k(language)ro,7680k@0x80000(firmware)
1266 cameo_ap123_mtdlayout_4M=mtdparts=spi0.0:64k(u-boot)ro,64k(nvram)ro,3712k(firmware),192k(lang)ro,64k(art)ro
1267 cameo_db120_mtdlayout=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,15936k(firmware),192k(lang)ro,64k(mac)ro,64k(art)ro
1268 cameo_db120_mtdlayout_8M=mtdparts=spi0.0:64k(uboot)ro,64k(nvram)ro,7872k(firmware),128k(lang)ro,64k(art)ro
1269 cap4200ag_mtdlayout=mtdparts=spi0.0:256k(u-boot),64k(u-boot-env),320k(custom)ro,1536k(kernel),12096k(rootfs),2048k(failsafe),64k(art),13632k@0xa0000(firmware)
1270 cpe510_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(pation-table)ro,64k(product-info)ro,1536k(kernel),6144k(rootfs),192k(config)ro,64k(ART)ro,7680k@0x40000(firmware)
1271 eap300v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),320k(custom),13632k(firmware),2048k(failsafe),64k(art)ro
1272 db120_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6336k(rootfs),1408k(kernel),64k(nvram),64k(art)ro,7744k@0x50000(firmware)
1273 dgl_5500_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,15296k(firmware),192k(lang)ro,512k(my-dlink)ro,64k(mac)ro,64k(art)ro
1274 dlan_pro_500_wp_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(Config1)ro,64k(Config2)ro,7680k@0x70000(firmware),64k(art)ro
1275 dlan_pro_1200_ac_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(Config1)ro,64k(Config2)ro,15872k@0x70000(firmware),64k(art)ro
1276 cameo_ap94_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,1600k(unknown)ro,64k@0x7f0000(caldata_copy)
1277 cameo_ap94_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7808k(firmware),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig)
1278 esr900_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware)
1279 esr1750_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware)
1280 epg5000_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),13248k(rootfs),1024k(manufacture)ro,64k(backup)ro,320k(storage)ro,64k(caldata)ro,14656k@0x40000(firmware)
1281 ew-dorin_mtdlayout_4M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),3712k(firmware),64k(art)
1282 ew-dorin_mtdlayout_16M=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),16000k(firmware),64k(art)ro
1283 f9k1115v2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),14464k(rootfs),1408k(kernel),64k(nvram)ro,64k(envram)ro,64k(art)ro,15872k@0x50000(firmware)
1284 dlrtdev_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,6208k(firmware),64k(caldata)ro,640k(certs),960k(unknown)ro,64k@0x7f0000(caldata_copy)
1285 dlrtdev_mtdlayout_fat=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,7168k(firmware),640k(certs),64k(caldata)ro,64k@0x660000(caldata_orig),6208k@0x50000(firmware_orig)
1286 dragino2_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,16000k(firmware),64k(config)ro,64k(art)ro
1287 hiwifi_hc6361_mtdlayout=mtdparts=spi0.0:64k(u-boot)ro,64k(bdinfo)ro,1280k(kernel),14848k(rootfs),64k(backup)ro,64k(art)ro,16128k@0x20000(firmware)
1288 mr12_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),2304k(kernel),128k(art)ro,15744k@0x80000(firmware)
1289 mr16_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,256k(u-boot-env)ro,13440k(rootfs),2304k(kernel),128k(art)ro,15744k@0x80000(firmware)
1290 pb92_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,2752k(rootfs),896k(kernel),64k(nvram),64k(art)ro,3648k@0x50000(firmware)
1291 planex_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7744k(firmware),128k(art)ro
1292 ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7552k(firmware),256k(cfg)ro,64k(EEPROM)ro
1293 uap_pro_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1536k(kernel),14208k(rootfs),256k(cfg)ro,64k(EEPROM)ro,15744k@0x50000(firmware)
1294 ubdev_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7488k(firmware),64k(certs),256k(cfg)ro,64k(EEPROM)ro
1295 whrhpg300n_mtdlayout=mtdparts=spi0.0:248k(u-boot)ro,8k(u-boot-env)ro,3712k(firmware),64k(art)ro
1296 wlr8100_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,1408k(kernel),14080k(rootfs),192k(unknown)ro,64k(art)ro,384k(unknown2)ro,15488k@0x40000(firmware)
1297 wpj344_mtdlayout_16M=mtdparts=spi0.0:192k(u-boot)ro,16128k(firmware),64k(art)ro
1298 wpj531_mtdlayout_16M=mtdparts=spi0.0:192k(u-boot)ro,16128k(firmware),64k(art)ro
1299 wpj558_mtdlayout_16M=mtdparts=spi0.0:192k(u-boot)ro,16128k(firmware),64k(art)ro
1300 wndap360_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1728k(kernel),6016k(rootfs),64k(nvram)ro,64k(art)ro,7744k@0x50000(firmware)
1301 wnr2200_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,7808k(firmware),64k(art)ro
1302 wnr2000v3_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,3712k(firmware),64k(art)ro
1303 wnr2000v4_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(u-boot-env)ro,3776k(firmware),64k(art)ro
1304 r6100_mtdlayout=mtdparts=ar934x-nfc:128k(u-boot)ro,256k(caldata),256k(caldata-backup),512k(config),512k(pot),2048k(kernel),122240k(ubi),25600k@0x1a0000(firmware),2048k(language),3072k(traffic_meter)
1305 wndr4300_mtdlayout=mtdparts=ar934x-nfc:256k(u-boot)ro,256k(u-boot-env)ro,256k(caldata),512k(pot),2048k(language),512k(config),3072k(traffic_meter),2048k(kernel),23552k(ubi),25600k@0x6c0000(firmware),256k(caldata_backup),-(reserved)
1306 zcn1523h_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,6208k(rootfs),1472k(kernel),64k(configure)ro,64k(mfg)ro,64k(art)ro,7680k@0x50000(firmware)
1307 mynet_n600_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,64k(devdata)ro,64k(devconf)ro,15872k(firmware),64k(radiocfg)ro
1308 mynet_rext_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,7808k(firmware),64k(nvram)ro,64k(ART)ro
1309 zyx_nbg6716_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(env)ro,64k(RFdata)ro,-(nbu);ar934x-nfc:2048k(zyxel_rfsd),2048k(romd),1024k(header),2048k(kernel),-(ubi)
1310 qihoo_c301_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env),64k(devdata),64k(devconf),15744k(firmware),64k(warm_start),64k(action_image_config),64k(radiocfg)ro;spi0.1:15360k(upgrade2),1024k(privatedata)
1311
1312
1313 define Image/BuildKernel
1314         cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
1315         cp $(KDIR)/vmlinux $(VMLINUX).bin
1316         dd if=$(KDIR)/vmlinux.bin.lzma of=$(VMLINUX).lzma bs=65536 conv=sync
1317         dd if=$(KDIR)/vmlinux.bin.gz of=$(VMLINUX).gz bs=65536 conv=sync
1318         $(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
1319         $(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
1320         cp $(KDIR)/loader-generic.elf $(VMLINUX)-lzma.elf
1321         -mkdir -p $(KDIR_TMP)
1322         $(call Image/Build/Profile/$(IMAGE_PROFILE),buildkernel)
1323 endef
1324
1325 define Image/BuildKernel/Initramfs
1326         cp $(KDIR)/vmlinux-initramfs.elf $(VMLINUX)-initramfs.elf
1327         cp $(KDIR)/vmlinux-initramfs $(VMLINUX)-initramfs.bin
1328         dd if=$(KDIR)/vmlinux-initramfs.bin.lzma of=$(VMLINUX)-initramfs.lzma bs=65536 conv=sync
1329         dd if=$(KDIR)/vmlinux-initramfs.bin.gz of=$(VMLINUX)-initramfs.gz bs=65536 conv=sync
1330         $(call MkuImage,gzip,,$(KDIR)/vmlinux-initramfs.bin.gz,$(UIMAGE)-initramfs-gzip.bin)
1331         $(call MkuImage,lzma,,$(KDIR)/vmlinux-initramfs.bin.lzma,$(UIMAGE)-initramfs-lzma.bin)
1332         cp $(KDIR)/loader-generic-initramfs.elf $(VMLINUX)-initramfs-lzma.elf
1333         $(call Image/Build/Initramfs)
1334 endef
1335
1336 Image/Build/WRT400N/buildkernel=$(call MkuImageLzma,$(2),$(3))
1337
1338 define Image/Build/WRT400N
1339         $(call Sysupgrade/KRuImage,$(1),$(2),1310720,6488064)
1340         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1341                 wrt400n $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR)/root.$(1) $(call factoryname,$(1),$(2)); \
1342         fi
1343 endef
1344
1345
1346 define Image/Build/CameoAP94/buildkernel
1347         $(call MkuImageLzma,$(2),$(3) $(4))
1348         $(call MkuImageLzma,$(2)-fat,$(3) $(5))
1349 endef
1350
1351 define Image/Build/CameoAP94
1352         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1353         $(eval fwsize_fat=$(call mtdpartsize,firmware,$(5)))
1354         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
1355         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1356                 ( \
1357                         dd if=$(call sysupname,$(1),$(2)); \
1358                         echo -n "$(6)"; \
1359                 ) > $(call imgname,$(1),$(2))-backup-loader.bin; \
1360                 if [ `stat -c%s $(call sysupname,$(1),$(2))` -gt 4194304 ]; then \
1361                         echo "Warning: $(call sysupname,$(1),$(2)) is too big" >&2; \
1362                 else \
1363                         ( \
1364                                 dd if=$(call sysupname,$(1),$(2)) bs=4096k conv=sync; \
1365                                 echo -n "$(7)"; \
1366                         ) > $(call factoryname,$(1),$(2)); \
1367                 fi; \
1368         fi
1369         $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2)-fat.uImage,0,$(KDIR)/root.$(1),$$$$(($(fwsize_fat)-4*64*1024)),$(KDIR_TMP)/$(2)-fat.bin,64)
1370         if [ -e "$(KDIR_TMP)/$(2)-fat.bin" ]; then \
1371                 echo -n "" > $(KDIR_TMP)/$(2)-fat.dummy; \
1372                 sh $(TOPDIR)/scripts/combined-image.sh \
1373                         "$(KDIR_TMP)/$(2)-fat.bin" \
1374                         "$(KDIR_TMP)/$(2)-fat.dummy" \
1375                         $(call sysupname,$(1),$(2)-fat); \
1376         fi
1377 endef
1378
1379 define Image/Build/WZRHP
1380         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(3)-4*$(4)*1024)),$(4))
1381         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1382                 ( \
1383                         echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
1384                         dd if=$(call sysupname,$(1),$(2)); \
1385                 ) > $(call imgname,$(1),$(2))-tftp.bin; \
1386                 buffalo-enc -p $(5) -v 1.99 \
1387                         -i $(call sysupname,$(1),$(2)) \
1388                         -o $(KDIR_TMP)/$(2).enc; \
1389                 buffalo-tag -b $(5) -p $(5) -a ath -v 1.99 -m 1.01 -l mlang8 \
1390                         -w 3 -c 0x80041000 -d 0x801e8000 -f 1 -r M_ \
1391                         -i $(KDIR_TMP)/$(2).enc \
1392                         -o $(call factoryname,$(1),$(2)); \
1393         fi
1394 endef
1395
1396 Image/Build/WZRHP64K/buildkernel=$(call MkuImageLzma,$(2),$(3))
1397 Image/Build/WZRHP64K/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1398 Image/Build/WZRHP64K=$(call Image/Build/WZRHP,$(1),$(2),33095680,64,$(4))
1399
1400 Image/Build/WZRHP128K/buildkernel=$(call MkuImageLzma,$(2),$(3))
1401 Image/Build/WZRHP128K/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1402 Image/Build/WZRHP128K=$(call Image/Build/WZRHP,$(1),$(2),33030144,128,$(4))
1403
1404
1405 Image/Build/WHRHPG300N/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1406 Image/Build/WHRHPG300N/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1407
1408 define Image/Build/WHRHPG300N
1409         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1410         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
1411         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1412                 ( \
1413                         echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
1414                         dd if=$(call sysupname,$(1),$(2)); \
1415                 ) > $(call imgname,$(1),$(2))-tftp.bin; \
1416                 buffalo-enc -p $(5) -v 1.99 \
1417                         -i $(call sysupname,$(1),$(2)) \
1418                         -o $(KDIR_TMP)/$(2).enc; \
1419                 buffalo-tag -b $(5) -p $(5) -a ath -v 1.99 -m 1.01 -l mlang8 \
1420                         -w 3 -c 0x80041000 -d 0x801e8000 -f 1 -r M_ \
1421                         -i $(KDIR_TMP)/$(2).enc \
1422                         -o $(call factoryname,$(1),$(2)); \
1423         fi
1424 endef
1425
1426
1427 define Image/Build/Cameo
1428         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1429         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
1430         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1431                 factory_size=$$$$(($(fwsize) - $(6))); \
1432                 ( \
1433                         dd if=$(call sysupname,$(1),$(2)) bs=$$$${factory_size} conv=sync; \
1434                         echo -n $(5); \
1435                 ) > $(call factoryname,$(1),$(2)); \
1436         fi
1437 endef
1438
1439 Image/Build/CameoAP81/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap81_mtdlayout))
1440 Image/Build/CameoAP81=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap81_mtdlayout),$(4),65536)
1441 Image/Build/CameoAP81/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap81_mtdlayout))
1442
1443 Image/Build/CameoAP91/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap91_mtdlayout))
1444 Image/Build/CameoAP91=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap91_mtdlayout),$(4),65536)
1445 Image/Build/CameoAP91/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap91_mtdlayout))
1446
1447 Image/Build/CameoAP99/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap99_mtdlayout))
1448 Image/Build/CameoAP99=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap99_mtdlayout),$(4),65536)
1449 Image/Build/CameoAP99/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap99_mtdlayout))
1450
1451 Image/Build/CameoAP123_4M/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap123_mtdlayout_4M))
1452 Image/Build/CameoAP123_4M=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_ap123_mtdlayout_4M),$(4),26)
1453 Image/Build/CameoAP123_4M/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap123_mtdlayout_4M))
1454
1455 Image/Build/CameoAP135/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1456 Image/Build/CameoAP135=$(call Image/Build/Cameo,$(1),$(2),$(3),$(4),$(5),26)
1457 Image/Build/CameoAP135/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1458
1459 Image/Build/CameoDB120/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_db120_mtdlayout))
1460 Image/Build/CameoDB120=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_db120_mtdlayout),$(4),26)
1461 Image/Build/CameoDB120/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_db120_mtdlayout))
1462
1463 Image/Build/CameoDB120_8M/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_db120_mtdlayout_8M))
1464 Image/Build/CameoDB120_8M=$(call Image/Build/Cameo,$(1),$(2),$(3),$(cameo_db120_mtdlayout_8M),$(4),26)
1465 Image/Build/CameoDB120_8M/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_db120_mtdlayout_8M))
1466
1467 define Image/Build/CameoHornet
1468         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1469         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
1470         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1471                 for r in $(7); do \
1472                         [ -n "$$$$r" ] && dashr="-$$$$r" || dashr=; \
1473                         [ -z "$$$$r" ] && r="DEF"; \
1474                         mkcameofw -M HORNET -R "$$$$r" -S $(5) -V $(6) -c \
1475                                 -K $(8) -I $(fwsize) \
1476                                 -k "$(call sysupname,$(1),$(2))" \
1477                                 -o $(call imgname,$(1),$(2))-factory$$$$dashr.bin; \
1478                         true; \
1479                 done; \
1480         fi
1481 endef
1482
1483 Image/Build/CameoAP121/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap121_mtdlayout))
1484 Image/Build/CameoAP121=$(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo_ap121_mtdlayout),$(4),$(5),$(6),0xe0000)
1485 Image/Build/CameoAP121/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap121_mtdlayout))
1486
1487 Image/Build/CameoAP121_8M/buildkernel=$(call MkuImageLzma,$(2),$(3) $(cameo_ap121_mtdlayout_8M))
1488 Image/Build/CameoAP121_8M=$(call Image/Build/CameoHornet,$(1),$(2),$(3),$(cameo_ap121_mtdlayout_8M),$(4),$(5),$(6),0x100000)
1489 Image/Build/CameoAP121_8M/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(cameo_ap121_mtdlayout_8M))
1490
1491 define Image/Build/dLAN
1492         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1493         $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
1494         $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
1495         $(call Sysupgrade/$(5),$(1),$(2),$(if $(6),$(6),$(kernsize)),$(if $(rootsize),$(rootsize),$(fwsize)))
1496         if [ -e "$(call factoryname,$(1),$(2))" ]; then \
1497                 dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
1498                         of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
1499                 dd if=$(KDIR)/root.$(1) \
1500                         of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
1501         fi
1502 endef
1503
1504 Image/Build/dLANLzma/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1505 Image/Build/dLANLzma=$(call Image/Build/dLAN,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
1506 Image/Build/dLANLzma/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1507
1508 define Image/Build/Ath
1509         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1510         $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
1511         $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
1512         $(call Sysupgrade/$(5),$(1),$(2),$(if $(6),$(6),$(kernsize)),$(if $(rootsize),$(rootsize),$(fwsize)))
1513         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1514                 dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
1515                         of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
1516                 dd if=$(KDIR)/root.$(1) \
1517                         of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
1518         fi
1519 endef
1520
1521 Image/Build/AthGzip/buildkernel=$(call MkuImageGzip,$(2),$(3) $(4))
1522 Image/Build/AthGzip=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
1523 Image/Build/AthGzip/initramfs=$(call MkuImageGzip/initramfs,$(2),$(3) $(4))
1524
1525 Image/Build/AthLzma/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1526 Image/Build/AthLzma=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
1527 Image/Build/AthLzma/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1528
1529
1530 Image/Build/Belkin/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1531 Image/Build/Belkin/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1532
1533 define Image/Build/Belkin
1534         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1535         $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
1536         $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
1537         $(call Sysupgrade/RKuImage,$(1),$(2),$(kernsize),$(rootsize))
1538         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1539                 edimax_fw_header -m $(5) -v "OpenWrt$(REVISION)" \
1540                         -n "uImage" \
1541                         -i $(KDIR_TMP)/vmlinux-$(2).uImage \
1542                         -o $(KDIR_TMP)/$(2)-uImage; \
1543                 edimax_fw_header -m $(5) -v "OpenWrt$(REVISION)" \
1544                         -n "rootfs" \
1545                         -i $(KDIR)/root.$(1) \
1546                         -o $(KDIR_TMP)/$(2)-rootfs; \
1547                 ( \
1548                         dd if=$(KDIR_TMP)/$(2)-rootfs; \
1549                         dd if=$(KDIR_TMP)/$(2)-uImage; \
1550                 ) > "$(call factoryname,$(1),$(2))"; \
1551         fi
1552 endef
1553
1554 define Image/Build/EnGenius
1555         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1556         $(eval rootsize=$(call mtdpartsize,rootfs,$(4)))
1557         $(eval kernsize=$(call mtdpartsize,kernel,$(4)))
1558         $(call Sysupgrade/$(5),$(1),$(2),$(if $(6),$(6),$(kernsize)),$(if $(rootsize),$(rootsize),$(fwsize)))
1559         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1560                 dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
1561                         of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
1562                 dd if=$(KDIR)/root.$(1) \
1563                         of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
1564                 mksenaofw -e $(call sysupname,$(1),$(2)) \
1565                         -o $(call imgname,$(1),$(2))-factory.dlf \
1566                         -r 0x101 -p $(7) -t 2; \
1567         fi
1568 endef
1569
1570 Image/Build/EnGenius/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1571 Image/Build/EnGenius/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1572
1573
1574 define MkuImageHiWiFi
1575         # Field ih_name needs to start with "tw150v1"
1576         mkimage -A mips -O linux -T kernel -a 0x80060000 -C $(1) $(2) \
1577                 -e 0x80060000 -n 'tw150v1 MIPS OpenWrt Linux-$(LINUX_VERSION)' \
1578                 -d $(3) $(4)
1579 endef
1580
1581 define MkuImageLzmaHiWiFi
1582         $(call PatchKernelLzma,$(1),$(2),$(3),$(4))
1583         $(call MkuImageHiWiFi,lzma,$(5),$(KDIR_TMP)/vmlinux$(4)-$(1).bin.lzma,$(KDIR_TMP)/vmlinux$(4)-$(1).uImage)
1584 endef
1585
1586 Image/Build/HiWiFi/buildkernel=$(call MkuImageLzmaHiWiFi,$(2),$(3) $(4))
1587 Image/Build/HiWiFi=$(call Image/Build/Ath,$(1),$(2),$(3),$(4),$(5),$(6),$(7))
1588 Image/Build/HiWiFi/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1589
1590 Image/Build/PB4X/buildkernel=$(call PatchKernelLzma,$(2),$(3))
1591
1592 define Image/Build/PB4X
1593         dd if=$(KDIR_TMP)/vmlinux-$(2).bin.lzma \
1594            of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync
1595         dd if=$(KDIR)/root.$(1) \
1596            of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync
1597         -sh $(TOPDIR)/scripts/combined-image.sh \
1598                 "$(call imgname,kernel,$(2)).bin" \
1599                 "$(call imgname,$(1),$(2)-rootfs).bin" \
1600                 $(call sysupname,$(1),$(2))
1601 endef
1602
1603
1604 Image/Build/MyLoader/buildkernel=$(call PatchKernelLzma,$(2),$(3))
1605 Image/Build/MyLoader/initramfs=$(call PatchKernel/initramfs,$(2),$(3))
1606
1607 define Image/Build/MyLoader
1608         $(eval fwsize=$(shell echo $$(($(4)-0x30000-4*64*1024))))
1609         $(eval fwimage=$(KDIR_TMP)/$(2)-$(5)-firmware.bin)
1610         $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).bin.lzma,65536,$(KDIR)/root.$(1),$(fwsize),$(fwimage))
1611         if [ -e "$(fwimage)" ]; then \
1612                 $(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) -s $(4) -v \
1613                         -p0x00030000:0:al:0x80060000:firmware:$(fwimage) \
1614                         $(call imgname,$(1),$(2))-$(5)-factory.img; \
1615                 echo -n "" > $(KDIR_TMP)/empty.bin; \
1616                 sh $(TOPDIR)/scripts/combined-image.sh \
1617                         $(fwimage) $(KDIR_TMP)/empty.bin \
1618                         $(call imgname,$(1),$(2))-$(5)-sysupgrade.bin; \
1619         fi
1620 endef
1621
1622 Image/Build/Planex/initramfs=$(call MkuImageGzip/initramfs,$(2),$(3) $(planex_mtdlayout))
1623 Image/Build/Planex/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2) $(planex_mtdlayout),0x52000,0)
1624
1625 define Image/Build/Planex/buildkernel
1626         [ -e "$(KDIR)/loader-$(2).gz" ]
1627         $(call MkuImageOKLI,$(2))
1628         ( \
1629                 dd if=$(KDIR)/loader-$(2).gz bs=8128 count=1 conv=sync; \
1630                 dd if=$(KDIR_TMP)/vmlinux-$(2).okli; \
1631         ) > $(KDIR_TMP)/kernel-$(2).bin
1632         $(call MkuImage,gzip,,$(KDIR_TMP)/kernel-$(2).bin,$(KDIR_TMP)/vmlinux-$(2).uImage)
1633 endef
1634
1635 define Image/Build/Planex
1636         $(eval fwsize=$(call mtdpartsize,firmware,$(planex_mtdlayout)))
1637         $(call Sysupgrade/KRuImage,$(1),$(2),0,$$$$(($(fwsize)-4*64*1024)),64)
1638         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1639                 $(STAGING_DIR_HOST)/bin/mkplanexfw \
1640                         -B $(2) \
1641                         -v 2.00.00 \
1642                         -i $(call sysupname,$(1),$(2)) \
1643                         -o $(call factoryname,$(1),$(2)); \
1644         fi
1645 endef
1646
1647
1648 Image/Build/ALFA/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1649 Image/Build/ALFA/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1650
1651 define Image/Build/ALFA
1652         $(call Sysupgrade/RKuImage,$(1),$(2),$(5),$(6))
1653         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
1654                 rm -rf $(KDIR)/$(1); \
1655                 mkdir -p $(KDIR)/$(1); \
1656                 cd $(KDIR)/$(1); \
1657                 cp $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR)/$(1)/$(7); \
1658                 cp $(KDIR)/root.$(1) $(KDIR)/$(1)/$(8); \
1659                 $(TAR) zcf $(call factoryname,$(1),$(2)) -C $(KDIR)/$(1) $(7) $(8); \
1660                 ( \
1661                         echo WRM7222C | dd bs=32 count=1 conv=sync; \
1662                         echo -ne '\xfe'; \
1663                 ) >> $(call factoryname,$(1),$(2)); \
1664         fi
1665 endef
1666
1667
1668 Image/Build/Seama/loader=$(call Image/BuildLoader,$(1),bin,$(2) $(3),0x80060000)
1669
1670 define Image/Build/Seama
1671         [ -e "$(KDIR)/loader-$(2).bin" ]
1672         $(call CompressLzma,$(KDIR)/loader-$(2).bin,$(KDIR_TMP)/loader-$(2).bin.lzma)
1673         -rm -f $(KDIR_TMP)/image-$(2).tmp
1674         $(call CatFiles,$(KDIR_TMP)/loader-$(2).bin.lzma,$$$$(($(6) - 64)),$(KDIR)/root.$(1),$(7),$(KDIR_TMP)/image-$(2).tmp)
1675         [ -e "$(KDIR_TMP)/image-$(2).tmp" ] && { \
1676                 head -c -4 "$(KDIR_TMP)/image-$(2).tmp" > "$(KDIR_TMP)/image-$(2).no-jffs2mark.tmp"; \
1677                 $(STAGING_DIR_HOST)/bin/seama \
1678                 -i $(KDIR_TMP)/image-$(2).no-jffs2mark.tmp \
1679                 -m "dev=/dev/mtdblock/1" -m "type=firmware"; \
1680                 $(STAGING_DIR_HOST)/bin/seama \
1681                         -s $(call imgname,$(1),$(2))-factory.bin \
1682                         -m "signature=$(5)" \
1683                         -i $(KDIR_TMP)/image-$(2).no-jffs2mark.tmp.seama; \
1684                 tail -c 4 "$(KDIR_TMP)/image-$(2).tmp" >> $(call imgname,$(1),$(2))-factory.bin; \
1685         }
1686         cat $(KDIR_TMP)/loader-$(2).bin.lzma > $(KDIR_TMP)/image-$(2)-sysupgrade.tmp
1687         $(STAGING_DIR_HOST)/bin/seama \
1688                 -i $(KDIR_TMP)/image-$(2)-sysupgrade.tmp \
1689                 -m "dev=/dev/mtdblock/1" -m "type=firmware"
1690         $(call CatFiles,$(KDIR_TMP)/image-$(2)-sysupgrade.tmp.seama,$(6),$(KDIR)/root.$(1),$(7),$(call sysupname,$(1),$(2)))
1691 endef
1692
1693 define Image/Build/Seama/initramfs
1694         $(call PatchKernelLzma,$(2),$(3) $(4),,-initramfs)
1695         $(STAGING_DIR_HOST)/bin/seama \
1696                 -i $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma \
1697                 -m "dev=/dev/mtdblock/1" -m "type=firmware"
1698         cat $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma.seama > $(call imgname,initramfs,$(2))-seama.bin
1699 endef
1700
1701 Image/Build/Senao/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1702 Image/Build/Senao/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
1703
1704 define Image/Build/Senao
1705         mkdir -p $(KDIR_TMP)/$(2)/
1706         touch $(KDIR_TMP)/$(2)/FWINFO-OpenWrt-$(REVISION)-$(2)
1707         -$(CP) ./$(2)/* $(KDIR_TMP)/$(2)/
1708         dd if=$(KDIR_TMP)/vmlinux-$(2).uImage \
1709                 of=$(KDIR_TMP)/$(2)/openwrt-senao-$(2)-uImage-lzma.bin bs=64k conv=sync
1710         dd if=$(KDIR)/root.$(1) \
1711                 of=$(KDIR_TMP)/$(2)/openwrt-senao-$(2)-root.$(1) bs=64k conv=sync
1712         ( \
1713                 cd $(KDIR_TMP)/$(2)/;  \
1714                 $(TAR) -cz -f $(call factoryname,$(1),$(2)) * \
1715         )
1716         -rm -rf $(KDIR_TMP)/$(2)/
1717         -sh $(TOPDIR)/scripts/combined-image.sh \
1718                 $(KDIR_TMP)/vmlinux-$(2).uImage \
1719                 $(KDIR)/root.$(1) \
1720                 $(call sysupname,$(1),$(2))
1721 endef
1722
1723 Image/Build/TPLINKOLD/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2),0x22000,0)
1724
1725 define Image/Build/TPLINKOLD
1726         [ -e "$(KDIR)/loader-$(2).gz" ]
1727         $(call MkuImageOKLI,$(2))
1728         ( \
1729                 dd if=$(KDIR)/loader-$(2).gz bs=7680 count=1 conv=sync; \
1730                 dd if=$(KDIR_TMP)/vmlinux-$(2).okli conv=sync; \
1731         ) > $(KDIR_TMP)/kernel-$(2).bin
1732         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1733                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION)\
1734                 -X 0x40000 \
1735                 -k $(KDIR_TMP)/kernel-$(2).bin \
1736                 -r $(KDIR)/root.$(1) \
1737                 -o $(call factoryname,$(1),$(2))
1738         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1739                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) -s\
1740                 -X 0x40000 \
1741                 -k $(KDIR_TMP)/kernel-$(2).bin \
1742                 -r $(KDIR)/root.$(1) \
1743                 -o $(call sysupname,$(1),$(2))
1744 endef
1745
1746 define Image/Build/TPLINKOLD/initramfs
1747         $(call Image/BuildLoader,$(2),gz,$(3),0x80060000,-initramfs)
1748         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
1749                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) -s\
1750                 -k $(KDIR)/loader-$(2)-initramfs.gz \
1751                 -o $(call imgname,$(1),$(2))-initramfs-uImage.bin
1752 endef
1753
1754
1755 Image/Build/TPLINK/loader=$(call Image/BuildLoaderAlone,$(1),gz,$(2),0x22000,0)
1756
1757 define Image/Build/TPLINK
1758         [ -e "$(KDIR)/loader-$(2).gz" ]
1759         $(call MkuImageOKLI,$(2))
1760         ( \
1761                 dd if=$(KDIR)/loader-$(2).gz bs=7680 count=1 conv=sync; \
1762                 dd if=$(KDIR_TMP)/vmlinux-$(2).okli conv=sync; \
1763         ) > $(KDIR_TMP)/kernel-$(2).bin
1764         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1765                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION)\
1766                 -X 0x40000 \
1767                 -k $(KDIR_TMP)/kernel-$(2).bin \
1768                 -r $(KDIR)/root.$(1) \
1769                 -a $(call rootfs_align,$(1)) -j \
1770                 -o $(call factoryname,$(1),$(2))
1771         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1772                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) -s\
1773                 -X 0x40000 \
1774                 -k $(KDIR_TMP)/kernel-$(2).bin \
1775                 -r $(KDIR)/root.$(1) \
1776                 -a $(call rootfs_align,$(1)) -j \
1777                 -o $(call sysupname,$(1),$(2))
1778 endef
1779
1780 define Image/Build/TPLINK/initramfs
1781         $(call Image/BuildLoader,$(2),gz,$(3),0x80060000,-initramfs)
1782         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
1783                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) -s\
1784                 -k $(KDIR)/loader-$(2)-initramfs.gz \
1785                 -o $(call imgname,$(1),$(2))-uImage.bin
1786 endef
1787
1788
1789 Image/Build/TPLINK-LZMA/buildkernel=$(call PatchKernelLzma,$(2),$(3))
1790
1791 define Image/Build/TPLINK-LZMA
1792         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1793                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) \
1794                 -X 0x40000 \
1795                 -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma \
1796                 -r $(KDIR)/root.$(1) \
1797                 -a $(call rootfs_align,$(1)) -j \
1798                 -o $(call factoryname,$(1),$(2))
1799         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1800                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) -s \
1801                 -X 0x40000 \
1802                 -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma \
1803                 -r $(KDIR)/root.$(1) \
1804                 -a $(call rootfs_align,$(1)) -j \
1805                 -o $(call sysupname,$(1),$(2))
1806 endef
1807
1808 define Image/Build/TPLINK-LZMA/initramfs
1809         $(call PatchKernelLzma,$(2),$(3),,-initramfs)
1810         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
1811                 -H $(4) -W $(5) -F $(6) -N OpenWrt -V $(REVISION) $(7) -s \
1812                 -k $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma \
1813                 -o $(call imgname,$(1),$(2))-uImage.bin
1814 endef
1815
1816 Image/Build/TPLINK-64K/buildkernel=$(call PatchKernelLzma,$(2),$(3))
1817
1818 define Image/Build/TPLINK-64K
1819         -$(STAGING_DIR_HOST)/bin/mkimage \
1820                 -A mips -O linux -T kernel -a 0x80060000 -C lzma \
1821                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
1822                 -d $$(KDIR_TMP)/vmlinux-$(2).bin.lzma $(KDIR_TMP)/vmlinux-$(2).bin.lzma.img
1823         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1824                 -H $(4) -W $(5) -F $(6) -N OpenWrt -m 2 -V $(REVISION) $(7) \
1825                 -X 0x20000 \
1826                 -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma.img \
1827                 -r $(KDIR)/root.$(1) \
1828                 -a $(call rootfs_align,$(1)) -j \
1829                 -o $(call factoryname,$(1),$(2))
1830         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
1831                 -H $(4) -W $(5) -F $(6) -N OpenWrt -m 2 -V $(REVISION) $(7) -s \
1832                 -X 0x20000 \
1833                 -k $(KDIR_TMP)/vmlinux-$(2).bin.lzma.img \
1834                 -r $(KDIR)/root.$(1) \
1835                 -a $(call rootfs_align,$(1)) -j \
1836                 -o $(call sysupname,$(1),$(2))
1837 endef
1838
1839 define Image/Build/TPLINK-64K/initramfs
1840         $(call PatchKernelLzma,$(2),$(3),,-initramfs)
1841         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
1842                 -H $(4) -W $(5) -F $(6) -N OpenWrt -m 2 -V $(REVISION) $(7) -s \
1843                 -k $(KDIR_TMP)/vmlinux-initramfs-$(2).bin.lzma.img \
1844                 -o $(call imgname,$(1),$(2))-uImage.bin
1845 endef
1846
1847
1848 Image/Build/TPLINK-SAFELOADER/loader = $(call Image/BuildLoaderPatched,$(1),elf,$(2) $(3))
1849
1850 define Image/Build/TPLINK-SAFELOADER
1851         [ -e "$(KDIR)/loader-$(2).elf" ]
1852
1853         -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
1854                 -B $(5) \
1855                 -k $(KDIR)/loader-$(2).elf \
1856                 -r $(KDIR)/root.$(1) \
1857                 -V $(REVISION) \
1858                 -j \
1859                 -o $(call factoryname,$(1),$(2))
1860         -$(STAGING_DIR_HOST)/bin/tplink-safeloader \
1861                 -B $(5) \
1862                 -k $(KDIR)/loader-$(2).elf \
1863                 -r $(KDIR)/root.$(1) \
1864                 -V $(REVISION) \
1865                 -j -S \
1866                 -o $(call sysupname,$(1),$(2))
1867 endef
1868
1869
1870 define Image/Build/CyberTAN
1871         echo -n '' > $(KDIR_TMP)/empty.bin
1872         $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp \
1873                 -f $(KDIR_TMP)/vmlinux-$(2).uImage -F $(KDIR_TMP)/empty.bin \
1874                 -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1)
1875         -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) \
1876                 -i $(KDIR)/image.tmp \
1877                 -o $(call sysupname,$(1),$(2))
1878         $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp -f $(KDIR_TMP)/vmlinux-$(2).uImage \
1879                 -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1)
1880         -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) -g \
1881                 -i $(KDIR)/image.tmp \
1882                 -o $(call factoryname,$(1),$(2))
1883         rm $(KDIR)/image.tmp
1884 endef
1885
1886 Image/Build/CyberTANGZIP/loader=$(call Image/BuildLoader,$(1),gz,$(2),0x80060000)
1887 Image/Build/CyberTANGZIP/buildkernel=$(call MkuImage,gzip,,$(KDIR)/loader-$(2).gz,$(KDIR_TMP)/vmlinux-$(2).uImage)
1888 Image/Build/CyberTANGZIP=$(call Image/Build/CyberTAN,$(1),$(2),$(3),$(4),$(5))
1889
1890 Image/Build/CyberTANLZMA/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
1891 Image/Build/CyberTANLZMA=$(call Image/Build/CyberTAN,$(1),$(2),$(3),$(4),$(5))
1892
1893
1894 Image/Build/Netgear/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
1895
1896 define Image/Build/Netgear/buildkernel
1897         $(call MkuImageLzma,$(2),$(3) $(4),-d20,,-M $(5))
1898         -rm -rf $(KDIR_TMP)/$(2)
1899         mkdir -p $(KDIR_TMP)/$(2)/image
1900         cat $(KDIR_TMP)/vmlinux-$(2).uImage > $(KDIR_TMP)/$(2)/image/uImage
1901         $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
1902                 $(KDIR_TMP)/$(2) $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp1 \
1903                 -noappend -root-owned -be -b 65536
1904         ( \
1905                 cat $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp1; \
1906                 dd if=/dev/zero bs=1k count=1 \
1907         ) > $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp2
1908         mkimage -A mips -O linux -T filesystem -C none -M $(5) \
1909                 -a 0xbf070000 -e 0xbf070000 \
1910                 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
1911                 -d $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs.tmp2 \
1912                 $(KDIR_TMP)/vmlinux-$(2).uImage.squashfs
1913 endef
1914
1915 define Image/Build/Netgear
1916         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1917         $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage.squashfs,0,$(KDIR)/root.$(1),$(fwsize),$(call sysupname,$(1),$(2)),64)
1918         if [ -e $(call sysupname,$(1),$(2)) ]; then \
1919                 for r in $(7) ; do \
1920                         [ -n "$$$$r" ] && dashr="-$$$$r" || dashr= ; \
1921                         $(STAGING_DIR_HOST)/bin/mkdniimg \
1922                                 -B $(6) -v OpenWrt.$(REVISION) -r "$$$$r" $(8) \
1923                                 -i $(call sysupname,$(1),$(2)) \
1924                                 -o $(call imgname,$(1),$(2))-factory$$$$dashr.img; \
1925                 done; \
1926         fi
1927 endef
1928
1929
1930 Image/Build/NetgearLzma/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
1931 Image/Build/NetgearLzma/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4),-d20,,-M $(5))
1932
1933 define Image/Build/NetgearLzma
1934         $(eval fwsize=$(call mtdpartsize,firmware,$(4)))
1935         $(call CatFiles,$(KDIR_TMP)/vmlinux-$(2).uImage,0,$(KDIR)/root.$(1),$(fwsize),$(call sysupname,$(1),$(2)),64)
1936 endef
1937
1938
1939 Image/Build/NetgearNAND/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4),,-M $(5))
1940
1941 # $(1): (empty)
1942 # $(2): Board name (small caps)
1943 # $(3): Kernel board specific cmdline
1944 # $(4): Kernel mtdparts definition
1945 # $(5): U-Boot magic
1946 define Image/Build/NetgearNAND/buildkernel
1947         $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
1948         $(call PatchKernelLzma,$(2),$(3) $(4),-d20)
1949         dd if=$(KDIR_TMP)/vmlinux-$(2).bin.lzma \
1950                 of=$(KDIR_TMP)/vmlinux-$(2).bin.tmp \
1951                 bs=$$$$(($(kernelsize)-131072-2*64-1)) \
1952                 count=1 conv=sync
1953         $(call MkuImage,lzma,-M $(5),$(KDIR_TMP)/vmlinux-$(2).bin.tmp,$(KDIR_TMP)/vmlinux-$(2).uImage)
1954         echo -ne '\xff' >> $(KDIR_TMP)/vmlinux-$(2).uImage
1955         # create a fake rootfs image
1956         dd if=/dev/zero of=$(KDIR_TMP)/fakeroot-$(2) bs=131072 count=1
1957         mkimage -A mips -O linux -T filesystem -C none \
1958                 -a 0xbf070000 -e 0xbf070000 \
1959                 -n 'MIPS OpenWrt fakeroot' \
1960                 -d $(KDIR_TMP)/fakeroot-$(2) \
1961                 -M $(5) \
1962                 $(KDIR_TMP)/fakeroot-$(2).uImage
1963         # append the fake rootfs image to the kernel, it will reside in the last
1964         # erase block of the kernel partition
1965         cat $(KDIR_TMP)/fakeroot-$(2).uImage >> $(KDIR_TMP)/vmlinux-$(2).uImage
1966 endef
1967
1968
1969 # $(1): rootfs image suffix
1970 # $(2): Board name (small caps)
1971 # $(3): Kernel board specific cmdline
1972 # $(4): Kernel mtdparts definition
1973 # $(5): U-Boot magic
1974 # $(6): Board name (upper caps)
1975 # $(7): firmware region code (not used yet)
1976 # $(8): DNI Hardware version
1977 # $(9): suffix of the configuration file for ubinize
1978 define Image/Build/NetgearNAND
1979         $(eval firmwaresize=$(call mtdpartsize,firmware,$(4)))
1980         $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
1981         $(eval imageraw=$(KDIR_TMP)/$(2)-raw.img)
1982         $(CP) $(KDIR)/root.squashfs-raw $(KDIR_TMP)/root.squashfs
1983         echo -ne '\xde\xad\xc0\xde' > $(KDIR_TMP)/jffs2.eof
1984         $(call ubinize,ubinize-$(9).ini,$(KDIR_TMP),$(KDIR_TMP)/$(2)-root.ubi,128KiB,2048,-E 5)
1985         ( \
1986                 dd if=$(KDIR_TMP)/vmlinux-$(2).uImage; \
1987                 dd if=$(KDIR_TMP)/$(2)-root.ubi \
1988         ) > $(imageraw)
1989         $(STAGING_DIR_HOST)/bin/mkdniimg \
1990                 -B $(6) -v OpenWrt.$(REVISION) -r "$$$$r" $(8) \
1991                 -i $(imageraw) \
1992                 -o $(call imgname,ubi,$(2))-factory.img
1993
1994         $(call Image/Build/SysupgradeNAND,$(2),squashfs,$(KDIR_TMP)/vmlinux-$(2).uImage)
1995 endef
1996
1997
1998 ifdef CONFIG_PACKAGE_uboot-ar71xx-nbg460n_550n_550nh
1999   Image/Build/ZyXEL/buildkernel=$(call MkuImageLzma,$(2),$(3))
2000
2001   define Image/Build/ZyXEL
2002         $(call Sysupgrade/KRuImage,$(1),$(2),917504,2752512)
2003         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
2004                 if [ ! -f $(BIN_DIR)/$(IMG_PREFIX)-$(2)-u-boot.bin ]; then \
2005                         echo "Warning: $(IMG_PREFIX)-$(2)-u-boot.bin not found" >&2; \
2006                 else \
2007                         $(STAGING_DIR_HOST)/bin/mkzynfw \
2008                                 -B $(4) \
2009                                 -b $(BIN_DIR)/$(IMG_PREFIX)-$(2)-u-boot.bin \
2010                                 -r $(call sysupname,$(1),$(2)):0x10000 \
2011                                 -o $(call factoryname,$(1),$(2)); \
2012         fi; fi
2013   endef
2014 endif
2015
2016
2017 define  Image/Build/ZyXELNAND/buildkernel
2018         $(eval kernelsize=$(call mtdpartsize,kernel,$(5)))
2019         $(call MkuImageLzma,$(2),$(3) $(5) $(6))
2020         mkdir -p $(KDIR_TMP)/$(2)/image/boot
2021         cp $(KDIR_TMP)/vmlinux-$(2).uImage $(KDIR_TMP)/$(2)/image/boot/vmlinux.lzma.uImage
2022         $(STAGING_DIR_HOST)/bin/mkfs.jffs2 \
2023                 --pad=$(kernelsize) --big-endian --squash-uids -v -e 128KiB \
2024                 -o $(KDIR_TMP)/$(2)-kernel.jffs2 \
2025                 -d $(KDIR_TMP)/$(2)/image \
2026                 2>&1 1>/dev/null | awk '/^.+$$$$/'
2027         -rm -rf $(KDIR_TMP)/$(2)
2028 endef
2029
2030 define Image/Build/ZyXELNAND
2031         if [ "$(1)" != "squashfs" ]; then \
2032                 echo Only squashfs is supported; \
2033                 return 0; \
2034         fi
2035         $(eval firmwaresize=$(call mtdpartsize,firmware,$(4)))
2036         $(eval kernelsize=$(call mtdpartsize,kernel,$(4)))
2037         $(eval imageraw=$(KDIR_TMP)/$(2)-raw.img)
2038         $(CP) $(KDIR)/root.$(1) $(KDIR_TMP)/ubi_root.img
2039         $(call ubinize,ubinize-$(2).ini,$(KDIR_TMP),$(KDIR_TMP)/$(2)-root.ubi,128KiB,2048,-E 5)
2040         ( \
2041                 dd if=$(KDIR_TMP)/$(2)-kernel.jffs2; \
2042                 dd if=$(KDIR_TMP)/$(2)-root.ubi \
2043         ) > $(imageraw)
2044         dd if=$(imageraw) of=$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1)-factory.bin \
2045                 bs=128k conv=sync
2046         $(call Image/Build/SysupgradeNAND,$(2),squashfs,$(KDIR_TMP)/$(2)-kernel.jffs2)
2047 endef
2048
2049
2050 Image/Build/OpenMesh/buildkernel=$(call MkuImageLzma,$(2))
2051
2052 define Image/Build/OpenMesh
2053         -sh $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \
2054                 "$(4)" \
2055                 "$(BUILD_DIR)/fwupgrade.cfg-$(4)" \
2056                 "$(KDIR_TMP)/vmlinux-$(2).uImage" \
2057                 "$(KDIR)/root.$(1)"
2058         -sh $(TOPDIR)/scripts/combined-ext-image.sh \
2059                 "$(4)" "$(call factoryname,$(1),$(2))" \
2060                 "$(BUILD_DIR)/fwupgrade.cfg-$(4)" "fwupgrade.cfg" \
2061                 "$(KDIR_TMP)/vmlinux-$(2).uImage" "kernel" \
2062                 "$(KDIR)/root.$(1)" "rootfs"
2063 endef
2064
2065
2066 Image/Build/Zcomax/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4))
2067 Image/Build/Zcomax/initramfs=$(call MkuImageLzma/initramfs,$(2),$(3) $(4))
2068
2069 define Image/Build/Zcomax
2070         $(call Sysupgrade/RKuImage,$(1),$(2),1507328,6356992)
2071         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
2072                 $(STAGING_DIR_HOST)/bin/mkzcfw \
2073                         -B $(2) \
2074                         -k $(KDIR_TMP)/vmlinux-$(2).uImage \
2075                         -r $(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
2076                         -o $(call imgname,$(1),$(2))-factory.img; \
2077         fi
2078 endef
2079
2080
2081 # $(1): template name to be defined, etc. squashfs-only, 64k, 64kraw, etc.
2082 # $(2): jffs2 blocksize.
2083 define Jffs2Template
2084   define Image/Build/Template/$(1)/jffs2-$(2)
2085     $$(call Image/Build/$$(1),jffs2-$(2),$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
2086   endef
2087 endef
2088
2089 # $(1): template name to be defined.
2090 # $(2): squashfs suffix to be used.
2091 # $(3): jffs2 suffix to be used.
2092 define BuildTemplate
2093   # $(1)     : name of build method.
2094   # $(2)     : board name.
2095   # $(3)     : kernel command line.
2096   # $(4)~$(8): extra arguments.
2097   define Image/Build/Template/$(1)/initramfs
2098     $$(call Image/Build/$$(1)/initramfs,initramfs,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
2099   endef
2100   define Image/Build/Template/$(1)/loader
2101     $$(call Image/Build/$$(1)/loader,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
2102   endef
2103   define Image/Build/Template/$(1)/buildkernel
2104     $$(call Image/Build/$$(1)/buildkernel,,$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
2105   endef
2106   define Image/Build/Template/$(1)/squashfs
2107     $$(call Image/Build/$$(1),squashfs$(2),$$(2),$$(3),$$(4),$$(5),$$(6),$$(7),$$(8),$$(9),$$(10))
2108   endef
2109   $(if $(3),$(foreach bs,$(3),$(eval $(call Jffs2Template,$(1),$(bs)))))
2110 endef
2111
2112 $(eval $(call BuildTemplate,squashfs-only))
2113 $(eval $(call BuildTemplate,64k,-64k,64k))
2114 $(eval $(call BuildTemplate,64kraw,-raw,64k))
2115 $(eval $(call BuildTemplate,64kraw-nojffs,-raw))
2116 $(eval $(call BuildTemplate,128k,,128k))
2117 $(eval $(call BuildTemplate,128kraw,-raw,128k))
2118 $(eval $(call BuildTemplate,256k,,256k))
2119 $(eval $(call BuildTemplate,all,,64k 128k 256k))
2120
2121 ifeq ($(SUBTARGET),generic)
2122 $(eval $(call SingleProfile,ALFA,64k,ALFANX,alfa-nx,ALFA-NX,ttyS0,115200,$$(alfa_mtdlayout_8M),1638400,6291456,vmlinux.gz.uImage,pb9x-2.6.31-jffs2))
2123 $(eval $(call SingleProfile,ALFA,64k,HORNETUB,hornet-ub,HORNET-UB,ttyATH0,115200,$$(alfa_mtdlayout_8M),1638400,6291456,kernel_image,rootfs_image))
2124 $(eval $(call SingleProfile,ALFA,64k,TUBE2H8M,tube2h-8M,TUBE2H,ttyATH0,115200,$$(alfa_mtdlayout_8M),1638400,6291456,kernel.image,rootfs.image))
2125
2126 $(eval $(call SingleProfile,AthGzip,64k,AP81,ap81,AP81,ttyS0,115200,$$(ap81_mtdlayout),RKuImage))
2127 $(eval $(call SingleProfile,AthGzip,64k,AP83,ap83,AP83,ttyS0,115200,$$(ap83_mtdlayout),RKuImage))
2128 $(eval $(call SingleProfile,AthGzip,64k,AP96,ap96,AP96,ttyS0,115200,$$(ap96_mtdlayout),RKuImage))
2129 $(eval $(call SingleProfile,AthGzip,64k,WNDAP360,wndap360,WNDAP360,ttyS0,9600,$$(wndap360_mtdlayout),KRuImage))
2130
2131 $(eval $(call SingleProfile,AthLzma,64k,ALFAAP96,alfa-ap96,ALFA-AP96,ttyS0,115200,$$(alfa_ap96_mtdlayout),RKuImage))
2132 $(eval $(call SingleProfile,AthLzma,64k,ALL0258N,all0258n,ALL0258N,ttyS0,115200,$$(all0258n_mtdlayout),KRuImage,65536))
2133 $(eval $(call SingleProfile,AthLzma,256k,ALL0315N,all0315n,ALL0315N,ttyS0,115200,$$(all0315n_mtdlayout),KRuImage,262144))
2134 $(eval $(call SingleProfile,AthLzma,64k,AP113,ap113,AP113,ttyS0,115200,$$(ap113_mtd_layout),RK))
2135 $(eval $(call SingleProfile,AthLzma,64k,AP121_2M,ap121-2M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_2M),RKuImage))
2136 $(eval $(call SingleProfile,AthLzma,64k,AP121_4M,ap121-4M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_4M),RKuImage))
2137 $(eval $(call SingleProfile,AthLzma,64k,AP121_8M,ap121-8M,AP121,ttyATH0,115200,$$(ap121_mtdlayout_8M),RKuImage))
2138 $(eval $(call SingleProfile,AthLzma,64k,AP121MINI,ap121-mini,AP121-MINI,ttyATH0,115200,$$(ap121_mtdlayout_4M),RKuImage))
2139 $(eval $(call SingleProfile,AthLzma,64k,AP132,ap132,AP132,ttyS0,115200,$$(ap132_mtdlayout),KRuImage))
2140 $(eval $(call SingleProfile,AthLzma,64k,AP135,ap135-020,AP135-020,ttyS0,115200,$$(ap135_mtdlayout),RKuImage))
2141 $(eval $(call SingleProfile,AthLzma,64k,AP136_010,ap136-010,AP136-010,ttyS0,115200,$$(ap136_mtdlayout),RKuImage))
2142 $(eval $(call SingleProfile,AthLzma,64k,AP136_020,ap136-020,AP136-020,ttyS0,115200,$$(ap136_mtdlayout),RKuImage))
2143 $(eval $(call SingleProfile,AthLzma,64k,AP143_8M,ap143-8M,AP143,ttyS0,115200,$$(ap143_mtdlayout_8M),RKuImage))
2144 $(eval $(call SingleProfile,AthLzma,64k,AP143_16M,ap143-16M,AP143,ttyS0,115200,$$(ap143_mtdlayout_16M),RKuImage))
2145 $(eval $(call SingleProfile,AthLzma,64k,AP147_010,ap147-010,AP147-010,ttyS0,115200,$$(ap147_mtdlayout),RKuImage))
2146 $(eval $(call SingleProfile,AthLzma,64k,AP152_16M,ap152-16M,AP152,ttyS0,115200,$$(ap152_mtdlayout_16M),RKuImage))
2147 $(eval $(call SingleProfile,AthLzma,64k,BXU2000N2,bxu2000n-2-a1,BXU2000n-2-A1,ttyS0,115200,$$(bxu2000n2_mtdlayout),RKuImage))
2148 $(eval $(call SingleProfile,AthLzma,64k,CAP4200AG,cap4200ag,CAP4200AG,ttyS0,115200,$$(cap4200ag_mtdlayout),KRuImage))
2149 $(eval $(call SingleProfile,AthLzma,64k,DB120,db120,DB120,ttyS0,115200,$$(db120_mtdlayout),RKuImage))
2150 $(eval $(call SingleProfile,AthLzma,64k,DRAGINO2,dragino2,DRAGINO2,ttyATH0,115200,$$(dragino2_mtdlayout),KRuImage,65536))
2151 $(eval $(call SingleProfile,AthLzma,64k,EWDORINAP,ew-dorin,EW-DORIN,ttyATH0,115200,$$(ew-dorin_mtdlayout_4M),KRuImage,65536))
2152 $(eval $(call SingleProfile,AthLzma,64k,EWDORINRT,ew-dorin-router,EW-DORIN-ROUTER,ttyATH0,115200,$$(ew-dorin_mtdlayout_4M),KRuImage,65536))
2153 $(eval $(call SingleProfile,AthLzma,64k,EWDORIN16M,ew-dorin-16M,EW-DORIN,ttyATH0,115200,$$(ew-dorin_mtdlayout_16M),KRuImage,65536))
2154 $(eval $(call SingleProfile,AthLzma,64k,HORNETUBx2,hornet-ub-x2,HORNET-UB,ttyATH0,115200,$$(alfa_mtdlayout_16M),KRuImage,65536))
2155 $(eval $(call SingleProfile,AthLzma,64k,MR12,mr12,MR12,ttyS0,115200,$$(mr12_mtdlayout),RKuImage))
2156 $(eval $(call SingleProfile,AthLzma,64k,MR16,mr16,MR16,ttyS0,115200,$$(mr16_mtdlayout),RKuImage))
2157 $(eval $(call SingleProfile,AthLzma,64k,PB92,pb92,PB92,ttyS0,115200,$$(pb92_mtdlayout),KRuImage))
2158 $(eval $(call SingleProfile,AthLzma,64k,TUBE2H16M,tube2h-16M,TUBE2H,ttyATH0,115200,$$(alfa_mtdlayout_16M),KRuImage,65536))
2159 $(eval $(call SingleProfile,AthLzma,64k,WLR8100,wlr8100,WLR8100,ttyS0,115200,$$(wlr8100_mtdlayout),KRuImage))
2160 $(eval $(call SingleProfile,AthLzma,64k,WPJ344_16M,wpj344-16M,WPJ344,ttyS0,115200,$$(wpj344_mtdlayout_16M),KRuImage,65536))
2161 $(eval $(call SingleProfile,AthLzma,64k,WPJ531_16M,wpj531-16M,WPJ531,ttyS0,115200,$$(wpj531_mtdlayout_16M),KRuImage,65536))
2162 $(eval $(call SingleProfile,AthLzma,64k,WPJ558_16M,wpj558-16M,WPJ558,ttyS0,115200,$$(wpj558_mtdlayout_16M),KRuImage,65536))
2163
2164 $(eval $(call SingleProfile,Belkin,64k,F9K1115V2,f9k1115v2,F9K1115V2,ttyS0,115200,$$(f9k1115v2_mtdlayout),BR-6679BAC))
2165
2166 $(eval $(call SingleProfile,CameoAP91,64kraw,DIR600A1,dir-600-a1,DIR-600-A1,ttyS0,115200,"AP91-AR7240-RT-090223-00"))
2167 $(eval $(call SingleProfile,CameoAP91,64kraw,DIR601A1,dir-601-a1,DIR-600-A1,ttyS0,115200,"AP91-AR7240-RT-090223-02"))
2168 $(eval $(call SingleProfile,CameoAP91,64kraw,FR54RTR,fr-54rtr,DIR-600-A1,ttyS0,115200,"AP91-AR7240-RT-090223-01"))
2169
2170 $(eval $(call SingleProfile,CameoAP99,64kraw,DIR615E1,dir-615-e1,DIR-615-E1,ttyS0,115200,"AP93-AR7240-RT-081028-00"))
2171 $(eval $(call SingleProfile,CameoAP99,64kraw,DIR615E4,dir-615-e4,DIR-615-E4,ttyS0,115200,"AP99-AR7240-RT-091105-05"))
2172
2173 $(eval $(call SingleProfile,CameoAP123_4M,64kraw,DIR615I1,dir-615-i1,DIR-615-I1,ttyS0,115200,"00DB120AR9341-RT-1012I1-00"))
2174 $(eval $(call SingleProfile,CameoAP123_4M,64kraw,DIR615I3,dir-615-i3,DIR-615-I1,ttyS0,115200,"00DB120AR9341-RT-101214-00"))
2175
2176 $(eval $(call SingleProfile,CameoAP81,64kraw-nojffs,A02RBW300N,a02-rb-w300n,TEW-632BRP,ttyS0,115200,"AP81-AR9130-RT-070614-03"))
2177 $(eval $(call SingleProfile,CameoAP81,64kraw-nojffs,DIR615C1,dir-615-c1,DIR-615-C1,ttyS0,115200,"AP81-AR9130-RT-070614-02"))
2178 $(eval $(call SingleProfile,CameoAP81,64kraw-nojffs,TEW632BRP,tew-632brp,TEW-632BRP,ttyS0,115200,"AP81-AR9130-RT-070614-00"))
2179 $(eval $(call SingleProfile,CameoAP81,64kraw-nojffs,TEW652BRP_FW,tew-652brp,TEW-632BRP,ttyS0,115200,"AP81-AR9130-RT-080609-05"))
2180 $(eval $(call SingleProfile,CameoAP81,64kraw-nojffs,TEW652BRP_RECOVERY,tew-652brp-recovery,TEW-632BRP,ttyS0,115200,"AP81-AR9130-RT-070614-02"))
2181
2182 $(eval $(call SingleProfile,CameoAP121,64kraw-nojffs,TEW712BR,tew-712br,TEW-712BR,ttyATH0,115200,"HORNET-RT-TEW712BR-3",1.99,""))
2183 $(eval $(call SingleProfile,CameoAP121,64kraw-nojffs,DIR601B1,dir-601-b1,TEW-712BR,ttyATH0,115200,"HORNET-RT-DIR601B1-3",2.99.99,"" "NA"))
2184 $(eval $(call SingleProfile,CameoAP121_8M,64kraw-nojffs,DIR505A1,dir-505-a1,DIR-505-A1,ttyATH0,115200,"HORNET-PACKET-DIR505A1-3",1.99.99,""))
2185
2186 $(eval $(call SingleProfile,CameoAP135,64kraw,DGL5500A1,dgl-5500-a1,DGL-5500-A1,ttyS0,115200,$$(dgl_5500_mtdlayout),"00AP135AR9558-RT-130508-00"))
2187
2188 $(eval $(call SingleProfile,CameoDB120,64kraw,DHP1565A1,dhp-1565-a1,DHP-1565-A1,ttyS0,115200,"00DB120AR9344-RT-101214-00"))
2189 $(eval $(call SingleProfile,CameoDB120,64kraw,DIR825C1,dir-825-c1,DIR-825-C1,ttyS0,115200,"00DB120AR9344-RT-101214-00"))
2190 $(eval $(call SingleProfile,CameoDB120,64kraw,DIR835A1,dir-835-a1,DIR-835-A1,ttyS0,115200,"00DB120AR9344-RT-101214-00"))
2191
2192 $(eval $(call SingleProfile,CameoDB120_8M,64kraw,TEW732BR,tew-732br,TEW-732BR,ttyS0,115200,"00DB120AR9341-RT-120906-NA"))
2193
2194 $(eval $(call SingleProfile,CyberTANGZIP,64k,WRT160NL,wrt160nl,WRT160NL,ttyS0,115200,,1.00.01))
2195
2196 $(eval $(call SingleProfile,CyberTANLZMA,64k,MYNETREXT,mynet-rext,MYNET-REXT,ttyS0,115200,$$(mynet_rext_mtdlayout) root=31:2,1.00.01))
2197
2198 $(eval $(call SingleProfile,CameoAP94,64kraw,DIR825B1,dir-825-b1,DIR-825-B1,ttyS0,115200,$$(cameo_ap94_mtdlayout),$$(cameo_ap94_mtdlayout_fat),01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
2199 $(eval $(call SingleProfile,CameoAP94,64kraw,TEW673GRU,tew-673gru,TEW-673GRU,ttyS0,115200,$$(cameo_ap94_mtdlayout),$$(cameo_ap94_mtdlayout_fat),01AP94-AR7161-RT-080619-01,00AP94-AR7161-RT-080619-01))
2200 $(eval $(call SingleProfile,CameoAP94,64kraw,DLRTDEV01,dlrtdev01,DIR-825-B1,ttyS0,115200,$$(dlrtdev_mtdlayout),$$(dlrtdev_mtdlayout_fat),01AP94-AR7161-RT-080619-00,00AP94-AR7161-RT-080619-00))
2201
2202 $(eval $(call SingleProfile,dLANLzma,64k,dLAN_pro_500_wp,dlan-pro-500-wp,dLAN-pro-500-wp,ttyS0,115200,$$(dlan_pro_500_wp_mtdlayout) mem=128M,KRuImage,64k))
2203 $(eval $(call SingleProfile,dLANLzma,64k,dLAN_pro_1200_ac,dlan-pro-1200-ac,dLAN-pro-1200-ac,ttyS0,115200,$$(dlan_pro_1200_ac_mtdlayout) mem=128M,KRuImage,64k))
2204
2205 $(eval $(call SingleProfile,EnGenius,64k,ESR900,esr900,ESR900,ttyS0,115200,$$(esr900_mtdlayout),KRuImage,,0x4e))
2206 $(eval $(call SingleProfile,EnGenius,64k,ESR1750,esr1750,ESR1750,ttyS0,115200,$$(esr1750_mtdlayout),KRuImage,,0x61))
2207 $(eval $(call SingleProfile,EnGenius,64k,EPG5000,epg5000,EPG5000,ttyS0,115200,$$(epg5000_mtdlayout),KRuImage,,0x71))
2208
2209 $(eval $(call SingleProfile,HiWiFi,64k,HIWIFI_HC6361,hiwifi-hc6361,HiWiFi-HC6361,ttyATH0,115200,$$(hiwifi_hc6361_mtdlayout),KRuImage))
2210
2211 $(eval $(call SingleProfile,MyLoader,64k,WP543_2M,wp543,,ttyS0,115200,0x200000,2M))
2212 $(eval $(call SingleProfile,MyLoader,64k,WP543_4M,wp543,,ttyS0,115200,0x400000,4M))
2213 $(eval $(call SingleProfile,MyLoader,64k,WP543_8M,wp543,,ttyS0,115200,0x800000,8M))
2214 $(eval $(call SingleProfile,MyLoader,64k,WP543_16M,wp543,,ttyS0,115200,0x1000000,16M))
2215 $(eval $(call SingleProfile,MyLoader,64k,WPE72_4M,wpe72,,ttyS0,115200,0x400000,4M))
2216 $(eval $(call SingleProfile,MyLoader,64k,WPE72_8M,wpe72,,ttyS0,115200,0x800000,8M))
2217 $(eval $(call SingleProfile,MyLoader,64k,WPE72_16M,wpe72,,ttyS0,115200,0x1000000,16M))
2218
2219 $(eval $(call SingleProfile,Netgear,64kraw,WNR2000V3,wnr2000v3,WNR2000V3,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303033,WNR2000V3,"" NA,-H 29763551+04+32))
2220 $(eval $(call SingleProfile,NetgearLzma,64kraw,WNR2000V4,wnr2000v4,WNR2000V4,ttyS0,115200,$$(wnr2000v4_mtdlayout),0x32303034,WNR2000V4,"" NA,))
2221 $(eval $(call SingleProfile,Netgear,64kraw,WNR2200,wnr2200,WNR2200,ttyS0,115200,$$(wnr2200_mtdlayout),0x32323030,WNR2200,"" NA,))
2222 $(eval $(call SingleProfile,Netgear,64kraw,REALWNR612V2,wnr612v2,WNR612V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303631,WNR612V2,"",))
2223 $(eval $(call SingleProfile,Netgear,64kraw,N150R,n150r,WNR612V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x32303631,N150R,"",))
2224 $(eval $(call SingleProfile,Netgear,64kraw,REALWNR1000V2,wnr1000v2,WNR1000V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x31303031,WNR1000V2,"",))
2225 $(eval $(call SingleProfile,Netgear,64kraw,WNR1000V2_VC,wnr1000v2-vc,WNR1000V2,ttyS0,115200,$$(wnr2000v3_mtdlayout),0x31303030,WNR1000V2-VC,"",))
2226
2227 $(eval $(call SingleProfile,OpenMesh,squashfs-only,OM2P,om2p,,,,OM2P))
2228 $(eval $(call SingleProfile,OpenMesh,squashfs-only,OM5P,om5p,,,,OM5P))
2229 $(eval $(call SingleProfile,OpenMesh,squashfs-only,MR600,mr600,,,,MR600))
2230 $(eval $(call SingleProfile,OpenMesh,squashfs-only,MR900,mr900,,,,MR900))
2231 $(eval $(call SingleProfile,OpenMesh,squashfs-only,MR1750,mr1750,,,,MR1750))
2232
2233 $(eval $(call SingleProfile,PB4X,128k,ALL0305,all0305,ALL0305,ttyS0,115200))
2234 $(eval $(call SingleProfile,PB4X,128k,EAP7660D,eap7660d,EAP7660D,ttyS0,115200))
2235 $(eval $(call SingleProfile,PB4X,64k,JA76PF,ja76pf,JA76PF,ttyS0,115200))
2236 $(eval $(call SingleProfile,PB4X,64k,JA76PF2,ja76pf2,JA76PF2,ttyS0,115200))
2237 $(eval $(call SingleProfile,PB4X,64k,JWAP003,jwap003,JWAP003,ttyS0,115200))
2238 $(eval $(call SingleProfile,PB4X,64k,PB42,pb42,PB42,ttyS0,115200))
2239 $(eval $(call SingleProfile,PB4X,64k,PB44,pb44,PB44,ttyS0,115200))
2240
2241 $(eval $(call SingleProfile,Planex,64kraw,MZKW04NU,mzk-w04nu,MZK-W04NU,ttyS0,115200))
2242 $(eval $(call SingleProfile,Planex,64kraw,MZKW300NH,mzk-w300nh,MZK-W300NH,ttyS0,115200))
2243
2244 $(eval $(call SingleProfile,Seama,64k,MYNETN600,mynet-n600,MYNET-N600,ttyS0,115200,$$(mynet_n600_mtdlayout),wrgnd16_wd_db600,65536,16187392))
2245 $(eval $(call SingleProfile,Seama,64k,MYNETN750,mynet-n750,MYNET-N750,ttyS0,115200,$$(mynet_n600_mtdlayout),wrgnd13_wd_av,65536,16187392))
2246
2247 $(eval $(call SingleProfile,Seama,64k,QIHOO360,qihoo-c301,QIHOO-C301,ttyS0,115200,$$(qihoo_c301_mtdlayout),wrgac26_qihoo360_360rg,65536,16121856))
2248
2249 $(eval $(call SingleProfile,Senao,squashfs-only,EAP300V2,eap300v2,EAP300V2,ttyS0,115200,$$(eap300v2_mtdlayout)))
2250
2251 $(eval $(call SingleProfile,TPLINKOLD,squashfs-only,TLWR841NV15,tl-wr841nd-v1.5,TL-WR841N-v1.5,ttyS0,115200,0x08410002,2,4M))
2252
2253 $(eval $(call SingleProfile,TPLINK,64kraw,RNXN360RT,rnx-n360rt,TL-WR941ND,ttyS0,115200,0x09410002,0x00420001,4M))
2254 $(eval $(call SingleProfile,TPLINK,64kraw,TLMR3220V1,tl-mr3220-v1,TL-MR3220,ttyS0,115200,0x32200001,1,4M))
2255 $(eval $(call SingleProfile,TPLINK,64kraw,TLMR3420V1,tl-mr3420-v1,TL-MR3420,ttyS0,115200,0x34200001,1,4M))
2256 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA701NV1,tl-wa701n-v1,TL-WA901ND,ttyS0,115200,0x07010001,1,4M))
2257 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA730REV1,tl-wa730rev1,TL-WA901ND,ttyS0,115200,0x07300001,1,4M))
2258 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA7510NV1,tl-wa7510n,TL-WA7510N,ttyS0,115200,0x75100001,1,4M))
2259 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA801NV1,tl-wa801nd-v1,TL-WA901ND,ttyS0,115200,0x08010001,1,4M))
2260 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA830RV1,tl-wa830re-v1,TL-WA901ND,ttyS0,115200,0x08300010,1,4M))
2261 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA901NV1,tl-wa901nd-v1,TL-WA901ND,ttyS0,115200,0x09010001,1,4M))
2262 $(eval $(call SingleProfile,TPLINK,64kraw,TLWA901NV2,tl-wa901nd-v2,TL-WA901ND-v2,ttyS0,115200,0x09010002,1,4M))
2263 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR740NV1,tl-wr740n-v1,TL-WR741ND,ttyS0,115200,0x07400001,1,4M))
2264 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR740NV3,tl-wr740n-v3,TL-WR741ND,ttyS0,115200,0x07400003,1,4M))
2265 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR743NV1,tl-wr743nd-v1,TL-WR741ND,ttyS0,115200,0x07430001,1,4M))
2266 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV3,tl-wr841nd-v3,TL-WR941ND,ttyS0,115200,0x08410003,3,4M))
2267 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV5,tl-wr841nd-v5,TL-WR741ND,ttyS0,115200,0x08410005,1,4M))
2268 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR841NV7,tl-wr841nd-v7,TL-WR841N-v7,ttyS0,115200,0x08410007,1,4M))
2269 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR842V1,tl-wr842n-v1,TL-MR3420,ttyS0,115200,0x08420001,1,8M))
2270 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR941NV2,tl-wr941nd-v2,TL-WR941ND,ttyS0,115200,0x09410002,2,4M))
2271 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR941NV3,tl-wr941nd-v3,TL-WR941ND,ttyS0,115200,0x09410002,2,4M))
2272 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR941NV4,tl-wr941nd-v4,TL-WR741ND,ttyS0,115200,0x09410004,1,4M))
2273 $(eval $(call SingleProfile,TPLINK,64kraw,TLWR1043V1,tl-wr1043nd-v1,TL-WR1043ND,ttyS0,115200,0x10430001,1,8M))
2274
2275 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR1043V2,tl-wr1043nd-v2,TL-WR1043ND-v2,ttyS0,115200,0x10430002,1,8M))
2276 $(eval $(call SingleProfile,TPLINK-LZMA,64kraw,TLWR2543,tl-wr2543-v1,TL-WR2543N,ttyS0,115200,0x25430001,1,8Mlzma,-v 3.13.99))
2277
2278 $(eval $(call SingleProfile,TPLINK-64K,64kraw,TLWDR6500V2,tl-wdr6500-v2,TL-WDR6500-v2,ttyS0,115200,0x65000002,1,8Mlzma))
2279
2280 $(eval $(call SingleProfile,TPLINK-SAFELOADER,64kraw,CPE510,cpe210-220-510-520,CPE510,ttyS0,115200,$$(cpe510_mtdlayout),CPE510))
2281
2282 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRG301N,whr-g301n,WHR-G301N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-G301N))
2283 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRHPG300N,whr-hp-g300n,WHR-HP-G300N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-HP-G300N))
2284 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WHRHPGN,whr-hp-gn,WHR-HP-GN,ttyS0,115200,$$(whrhpg300n_mtdlayout),WHR-HP-GN))
2285 $(eval $(call SingleProfile,WHRHPG300N,64kraw,WLAEAG300N,wlae-ag300n,WLAE-AG300N,ttyS0,115200,$$(whrhpg300n_mtdlayout),WLAE-AG300N))
2286
2287 $(eval $(call SingleProfile,WRT400N,64k,WRT400N,wrt400n,WRT400N,ttyS0,115200))
2288
2289 $(eval $(call SingleProfile,WZRHP128K,128kraw,WZRHPG300NH,wzr-hp-g300nh,WZR-HP-G300NH,ttyS0,115200,WZR-HP-G300NH))
2290 $(eval $(call SingleProfile,WZRHP64K,64kraw,WZRHPG300NH2,wzr-hp-g300nh2,WZR-HP-G300NH2,ttyS0,115200,WZR-HP-G300NH2))
2291 $(eval $(call SingleProfile,WZRHP64K,64kraw,WZRHPAG300H,wzr-hp-ag300h,WZR-HP-AG300H,ttyS0,115200,WZR-HP-AG300H))
2292 $(eval $(call SingleProfile,WZRHP64K,64kraw,WZRHPG450H,wzr-hp-g450h,WZR-HP-G450H,ttyS0,115200,WZR-HP-AG450H))
2293 $(eval $(call SingleProfile,WZRHP64K,64kraw,WZR600DHP,wzr-600dhp,WZR-HP-AG300H,ttyS0,115200,WZR-600DHP))
2294 $(eval $(call SingleProfile,WZRHP64K,64kraw,WZR450HP2,wzr-450hp2,WZR-450HP2,ttyS0,115200,WZR-450HP2))
2295
2296 $(eval $(call SingleProfile,Zcomax,64k,ZCN1523H28,zcn-1523h-2-8,ZCN-1523H-2,ttyS0,115200,$$(zcn1523h_mtdlayout)))
2297 $(eval $(call SingleProfile,Zcomax,64k,ZCN1523H516,zcn-1523h-5-16,ZCN-1523H-5,ttyS0,115200,$$(zcn1523h_mtdlayout)))
2298
2299 $(eval $(call SingleProfile,ZyXEL,64k,NBG_460N_550N_550NH,nbg460n_550n_550nh,NBG460N,ttyS0,115200,NBG-460N))
2300
2301 $(eval $(call MultiProfile,AP121,AP121_2M AP121_4M AP121_8M))
2302 $(eval $(call MultiProfile,AP136,AP136_010 AP136_020))
2303 $(eval $(call MultiProfile,AP143,AP143_8M AP143_16M))
2304 $(eval $(call MultiProfile,AP147,AP147_010))
2305 $(eval $(call MultiProfile,AP152,AP152_16M))
2306 $(eval $(call MultiProfile,DIR615IX,DIR615I1 DIR615I3))
2307 $(eval $(call MultiProfile,EWDORIN, EWDORINAP EWDORINRT EWDORIN16M))
2308 $(eval $(call MultiProfile,OPENMESH,OM2P OM5P MR600 MR900 MR1750))
2309 $(eval $(call MultiProfile,TEW652BRP,TEW652BRP_FW TEW652BRP_RECOVERY))
2310 $(eval $(call MultiProfile,TLMR3220,TLMR3220V1))
2311 $(eval $(call MultiProfile,TLMR3420,TLMR3420V1))
2312 $(eval $(call MultiProfile,TLWA701,TLWA701NV1))
2313 $(eval $(call MultiProfile,TLWA730RE,TLWA730REV1))
2314 $(eval $(call MultiProfile,TLWA801,TLWA801NV1))
2315 $(eval $(call MultiProfile,TLWA830,TLWA830RV1))
2316 $(eval $(call MultiProfile,TLWA901,TLWA901NV1 TLWA901NV2))
2317 $(eval $(call MultiProfile,TLWA7510,TLWA7510NV1))
2318 $(eval $(call MultiProfile,TLWR740,TLWR740NV1 TLWR740NV3))
2319 $(eval $(call MultiProfile,TLWR743,TLWR743NV1))
2320 $(eval $(call MultiProfile,TLWR841,TLWR841NV15 TLWR841NV3 TLWR841NV5 TLWR841NV7))
2321 $(eval $(call MultiProfile,TLWR842,TLWR842V1))
2322 $(eval $(call MultiProfile,TLWR941,TLWR941NV2 TLWR941NV3 TLWR941NV4))
2323 $(eval $(call MultiProfile,TLWR1043,TLWR1043V1 TLWR1043V2))
2324 $(eval $(call MultiProfile,TUBE2H,TUBE2H8M TUBE2H16M))
2325 $(eval $(call MultiProfile,WNR612V2,REALWNR612V2 N150R))
2326 $(eval $(call MultiProfile,WNR1000V2,REALWNR1000V2 WNR1000V2_VC))
2327 $(eval $(call MultiProfile,WP543,WP543_2M WP543_4M WP543_8M WP543_16M))
2328 $(eval $(call MultiProfile,WPE72,WPE72_4M WPE72_8M WPE72_16M))
2329 $(eval $(call MultiProfile,WPJ344,WPJ344_16M))
2330 $(eval $(call MultiProfile,WPJ531,WPJ531_16M))
2331 $(eval $(call MultiProfile,WPJ558,WPJ558_16M))
2332
2333 $(eval $(call MultiProfile,Minimal,$(SINGLE_PROFILES)))
2334 $(eval $(call MultiProfile,Madwifi,EAP7660D WP543))
2335 endif # ifeq ($(SUBTARGET),generic)
2336
2337 ifeq ($(SUBTARGET),nand)
2338 $(eval $(call SingleProfile,NetgearNAND,64k,WNDR3700V4,wndr3700v4,WNDR3700_V4,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR3700v4,"",-H 29763948+128+128,wndr4300))
2339 $(eval $(call SingleProfile,NetgearNAND,64k,WNDR4300V1,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3,wndr4300))
2340 $(eval $(call SingleProfile,NetgearNAND,64k,R6100,r6100,R6100,ttyS0,115200,$$(r6100_mtdlayout),0x36303030,R6100,"",-H 29764434+0+128+128+2x2+2x2,wndr4300))
2341
2342 $(eval $(call SingleProfile,ZyXELNAND,128k,NBG6716,nbg6716,NBG6716,ttyS0,115200,NBG6716,$$(zyx_nbg6716_mtdlayout),mem=256M))
2343
2344 $(eval $(call MultiProfile,WNDR4300,WNDR3700V4 WNDR4300V1))
2345 endif # ifeq ($(SUBTARGET),nand)
2346
2347
2348 $(eval $(call MultiProfile,Default,$(SINGLE_PROFILES)))
2349
2350 define Image/Build/squashfs
2351         cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-raw
2352         cp $(KDIR)/root.squashfs $(KDIR)/root.squashfs-64k
2353         $(STAGING_DIR_HOST)/bin/padjffs2 $(KDIR)/root.squashfs-64k 64
2354         cp $(KDIR)/root.squashfs-64k $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-64k
2355         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
2356         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
2357 endef
2358
2359 define Image/Build/jffs2
2360         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
2361 endef
2362
2363 define Image/Build/Initramfs
2364         $(call Image/Build/Profile/$(IMAGE_PROFILE),initramfs)
2365 endef
2366
2367 define Image/Prepare
2368         gzip -9n -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
2369         $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
2370 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
2371         gzip -9n -c $(KDIR)/vmlinux-initramfs > $(KDIR)/vmlinux-initramfs.bin.gz
2372         $(call CompressLzma,$(KDIR)/vmlinux-initramfs,$(KDIR)/vmlinux-initramfs.bin.lzma)
2373         $(call Image/BuildLoader,generic,elf,,,-initramfs)
2374 endif
2375         $(call Image/BuildLoader,generic,elf)
2376         $(call Image/Build/Profile/$(if $(CONFIG_IB),Default,$(IMAGE_PROFILE)),loader)
2377 endef
2378
2379 # $(1): filesystem type.
2380 define Image/Build
2381         $(call Image/Build/$(call rootfs_type,$(1)),$(1))
2382         $(call Image/Build/Profile/$(IMAGE_PROFILE),$(1))
2383 endef
2384
2385 $(eval $(call BuildImage))