ar71xx: simplify WP543 image generation, and fix rootfs offset
[librecmc/librecmc.git] / target / linux / ar71xx / image / Makefile
1 #
2 # Copyright (C) 2008-2009 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 IMGNAME:=$(BIN_DIR)/openwrt-$(BOARD)
11
12 define imgname
13 $(IMGNAME)-$(2)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
14 endef
15
16 VMLINUX:=$(IMGNAME)-vmlinux
17 UIMAGE:=$(IMGNAME)-uImage
18 fs_squash:=squashfs-only
19 fs_all:=all
20 fs_4k:=4k
21 fs_64k:=64k
22 fs_128k:=128k
23 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
24         fs_squash:=initramfs
25         fs_all:=initramfs
26         fs_4k:=initramfs
27         fs_64k:=initramfs
28         fs_128k:=initramfs
29         VMLINUX:=$(IMGNAME)-vmlinux-initramfs
30         UIMAGE:=$(IMGNAME)-uImage-initramfs
31 endif
32
33 define CompressLzma
34   $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
35 endef
36
37 define PatchKernelLzma
38         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
39         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
40         $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).bin.lzma)
41 endef
42
43 define PatchKernelGzip
44         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
45         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
46         gzip -9 -c $(KDIR)/vmlinux-$(1) > $(KDIR)/vmlinux-$(1).bin.gz
47 endef
48
49 define MkImageLzma
50         mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma \
51                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
52                 -d $(1) $(2)
53 endef
54
55 define MkImageGzip
56         mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip \
57                 -e 0x80060000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
58                 -d $(1) $(2)
59 endef
60
61 define Image/BuildKernel
62         cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
63         cp $(KDIR)/vmlinux $(VMLINUX).bin
64         gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
65         $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
66         dd if=$(KDIR)/vmlinux.bin.lzma of=$(VMLINUX).lzma bs=65536 conv=sync
67         dd if=$(KDIR)/vmlinux.bin.gz of=$(VMLINUX).gz bs=65536 conv=sync
68         $(call MkImageGzip,$(KDIR)/vmlinux.bin.gz,$(UIMAGE)-gzip.bin)
69         $(call MkImageLzma,$(KDIR)/vmlinux.bin.lzma,$(UIMAGE)-lzma.bin)
70         $(call Image/Build/Initramfs)
71 endef
72
73 define Image/Build/WRT400N
74         $(call PatchKernelLzma,$(2),$(3))
75         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1310720 ]; then \
76                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
77         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6488064 ]; then \
78                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
79         else \
80                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
81                         0x80060000 \
82                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
83                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
84                 ( \
85                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1280k conv=sync; \
86                         dd if=$(KDIR)/root.$(1) bs=6336k conv=sync; \
87                         echo -n $(4); \
88                 ) > $(call imgname,$(1),$(2)).bin; \
89                 wrt400n $(KDIR)/vmlinux-$(2).uImage $(KDIR)/root.$(1) $(call imgname,$(1),$(2)).webui; \
90         fi; fi
91 endef
92
93 dir600a1_mtdlayout=mtdparts=spi0.0:192k(u-boot)ro,64k(nvram)ro,896k(kernel),2816k(rootfs),64k(mac)ro,64k(art)ro,3712k@0x40000(firmware)
94 define Image/Build/DIR600A1
95         $(call PatchKernelLzma,$(2),$(3) $(dir600a1_mtdlayout))
96         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 917504 ]; then \
97                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
98         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 2818048 ]; then \
99                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
100         else \
101                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
102                         0x80060000 \
103                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
104                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
105                 ( \
106                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
107                         dd if=$(KDIR)/root.$(1) bs=2752k conv=sync; \
108                         echo -n "AP91-AR7240-RT-090223-00"; \
109                 ) > $(call imgname,$(1),$(2))-universal.bin; \
110         fi; fi
111 endef
112
113 dir825b1_mtdlayout=mtdparts=spi0.0:256k(uboot)ro,64k(config)ro,1024k(kernel),5184k(rootfs),64k(caldata)ro,1600k(unknown)ro,6208k@0x50000(firmware)
114 define Image/Build/DIR825B1
115         $(call PatchKernelLzma,$(2),$(3) $(dir825b1_mtdlayout))
116         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(call imgname,$(1),$(2)).bin)
117         if [ `stat -c%s "$(call imgname,$(1),$(2)).bin"` -gt 1048576 ]; then \
118                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
119                 rm -f $(call imgname,$(1),$(2)).bin; \
120         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 5308416 ]; then \
121                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
122                 rm -f $(call imgname,$(1),$(2)).bin; \
123         else \
124                 dd if=$(KDIR)/root.$(1) of=$(call imgname,$(1),$(2)).bin bs=1k seek=1024; \
125                 cp $(call imgname,$(1),$(2)).bin $(call imgname,$(1),$(2))-backup-loader.bin; \
126                 echo -n "01AP94-AR7161-RT-080619-00" >> $(call imgname,$(1),$(2))-backup-loader.bin; \
127         fi; fi
128 endef
129
130 define Image/Build/WZRHPG300NH
131         $(call PatchKernelLzma,$(2),$(3))
132         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1048576 ]; then \
133                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
134         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 31850496 ]; then \
135                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
136         else \
137                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
138                         0x80060000 \
139                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
140                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
141                 ( \
142                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync; \
143                         dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
144                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
145                 ( \
146                         echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \
147                         dd if=$(call imgname,$(1),$(2))-sysupgrade.bin; \
148                 ) > $(call imgname,$(1),$(2))-tftp.bin; \
149         fi; fi
150 endef
151
152 cameo_mtdlayout=mtdparts=spi0.0:128k(u-boot)ro,64k(config)ro,896k(kernel),2880k(rootfs),64k(art)ro,3776k@0x30000(firmware)
153 define Image/Build/Cameo
154         $(call PatchKernelLzma,$(2),$(3) $(cameo_mtdlayout))
155         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 917504 ]; then \
156                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
157         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 2949120 ]; then \
158                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
159         else \
160                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C lzma -e \
161                         0x80060000 \
162                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
163                         -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage; \
164                 ( \
165                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=896k conv=sync; \
166                         dd if=$(KDIR)/root.$(1) bs=2880k conv=sync; \
167                         echo -n $(4); \
168                 ) > $(call imgname,$(1),$(2)).uni; \
169         fi; fi
170 endef
171
172 define Image/Build/AP83
173         $(call PatchKernelGzip,$(2),$(3))
174         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gz"` -gt 1310720 ]; then \
175                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.gz is too big"; \
176         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6619136 ]; then \
177                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
178         else \
179                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
180                         0x80060000 \
181                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
182                         -d $(KDIR)/vmlinux-$(2).bin.gz \
183                         $(KDIR)/vmlinux-$(2).uImage; \
184                 dd if=$(KDIR)/vmlinux-$(2).uImage \
185                         of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync; \
186                 dd if=$(KDIR)/root.$(1) \
187                         of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync; \
188                 ( \
189                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1280k conv=sync; \
190                         dd if=$(KDIR)/root.$(1); \
191                 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
192         fi; fi
193 endef
194
195 define Image/Build/PB4X
196         $(call PatchKernelLzma,$(2),$(3))
197         dd if=$(KDIR)/vmlinux-$(2).bin.lzma \
198            of=$(call imgname,kernel,$(2)).bin bs=64k conv=sync
199         dd if=$(KDIR)/root.$(1) \
200            of=$(call imgname,$(1),$(2)-rootfs).bin bs=128k conv=sync
201         -sh $(TOPDIR)/scripts/combined-image.sh \
202                 "$(call imgname,kernel,$(2)).bin" \
203                 "$(call imgname,$(1),$(2)-rootfs).bin" \
204                 $(call imgname,$(1),$(2))-sysupgrade.bin
205 endef
206
207 define Image/Build/MyLoader
208         -$(STAGING_DIR_HOST)/bin/mkmylofw -B $(2) -s $(3) \
209                 -p0x030000:0xe0000:al:0x80060000:kernel:$(KDIR)/vmlinux.bin.lzma \
210                 -p0x110000:0:::rootfs:$(KDIR)/root.$(1) \
211                 $(call imgname,$(1),$(2))-$(4)-factory.img
212 endef
213
214 ubntxm_mtdlayout=mtdparts=spi0.0:256k(u-boot)ro,64k(u-boot-env)ro,1024k(kernel),6528k(rootfs),256k(cfg)ro,64k(EEPROM)ro,7552k@0x50000(firmware)
215 define Image/Build/UBNTXM
216         $(call PatchKernelLzma,$(2),$(3) $(ubntxm_mtdlayout))
217         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage.bin)
218         dd if=$(KDIR)/vmlinux-$(2).uImage.bin of=$(KDIR)/vmlinux-$(2).uImage bs=1024k conv=sync
219         -$(STAGING_DIR_HOST)/bin/mkfwimage \
220                 -B $(4) -v $(5).$(6).OpenWrt.$(REVISION) \
221                 -k $(KDIR)/vmlinux-$(2).uImage \
222                 -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \
223                 -o $(call imgname,$(1),$(2))-factory.bin
224         ( \
225                 dd if=$(KDIR)/vmlinux-$(2).uImage; \
226                 dd if=$(BIN_DIR)/openwrt-$(BOARD)-root.$(1); \
227         ) > $(call imgname,$(1),$(2))-sysupgrade.bin
228 endef
229
230 define Image/Build/UBNT
231         $(call PatchKernelLzma,$(2),$(3))
232         dd if=$(KDIR)/vmlinux-$(2).bin.lzma of=$(KDIR)/vmlinux-$(2).lzma bs=64k conv=sync
233         -$(STAGING_DIR_HOST)/bin/mkfwimage \
234                 -B $(4) -v $(5).$(6).OpenWrt.$(REVISION) \
235                 -k $(KDIR)/vmlinux-$(2).lzma \
236                 -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \
237                 -o $(call imgname,$(1),$(2))-factory.bin
238         -sh $(TOPDIR)/scripts/combined-image.sh \
239                 "$(KDIR)/vmlinux-$(2).lzma" \
240                 "$(BIN_DIR)/openwrt-$(BOARD)-root.$(1)" \
241                 $(call imgname,$(1),$(2))-sysupgrade.bin
242 endef
243
244 define Image/Build/Planex
245         $(call PatchKernelGzip,$(2),$(3))
246         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.gz"` -gt 1441792 ]; then \
247                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.gz is too big"; \
248         else if [ `stat -c%s $(KDIR)/root.$(1)` -gt 6356992 ]; then \
249                 echo "Warning: $(KDIR)/root.$(1) is too big"; \
250         else \
251                 mkimage -A mips -O linux -T kernel -a 0x80060000 -C gzip -e \
252                         0x80060000 \
253                         -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
254                         -d $(KDIR)/vmlinux-$(2).bin.gz $(KDIR)/vmlinux-$(2).uImage; \
255                 ( \
256                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=1408k conv=sync; \
257                         dd if=$(KDIR)/root.$(1) bs=6208k conv=sync; \
258                 ) > $(call imgname,$(1),$(2)).bin; \
259                 $(STAGING_DIR_HOST)/bin/mkplanexfw \
260                         -B $(2) \
261                         -v 2.00.00 \
262                         -i $(call imgname,$(1),$(2)).bin \
263                         -o $(call imgname,$(1),$(2)).webui; \
264         fi; fi
265 endef
266
267 define Image/Build/TPLINK
268         $(call PatchKernelGzip,$(2),$(3))
269         -$(STAGING_DIR_HOST)/bin/mktplinkfw \
270                 -B $(4) -N OpenWrt -V $(REVISION)\
271                 -k $(KDIR)/vmlinux-$(2).bin.gz \
272                 -r $(BIN_DIR)/openwrt-$(BOARD)-root.$(1) \
273                 -o $(call imgname,$(1),$(2))-universal.bin
274 endef
275
276 define Image/Build/TPLINK/initramfs
277         $(call PatchKernelGzip,$(2),$(3))
278         -$(STAGING_DIR_HOST)/bin/mktplinkfw -c \
279                 -B $(4) -N OpenWrt -V $(REVISION)\
280                 -k $(KDIR)/vmlinux-$(2).bin.gz \
281                 -o $(call imgname,$(1),$(2))-uImage.bin
282 endef
283
284 define Image/Build/CyberTAN
285         $(call PatchKernelGzip,$(2),$(3))
286         $(call MkImageGzip,$(KDIR)/vmlinux-$(2).bin.gz,$(KDIR)/vmlinux-$(2).uImage)
287         ( \
288                 dd if=$(KDIR)/vmlinux-$(2).uImage bs=64k conv=sync; \
289                 dd if=/dev/zero bs=1 count=65476; \
290                 dd if=$(KDIR)/root.$(1) bs=64k; \
291         ) > $(KDIR)/vmlinux-$(2).image
292         $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/vmlinux-$(2).trx \
293                 -f $(KDIR)/vmlinux-$(2).image
294         -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(4) -g \
295                 -i $(KDIR)/vmlinux-$(2).trx \
296                 -o $(call imgname,$(1),$(2)).bin
297 endef
298
299 wndr3700_mtdlayout=mtdparts=spi0.0:320k(u-boot)ro,128k(u-boot-env)ro,1024k(kernel),6656k(rootfs),64k(art)ro,7680k@0x70000(firmware)
300 define Image/Build/WNDR3700
301         $(call PatchKernelLzma,$(2),$(3) $(wndr3700_mtdlayout))
302         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage)
303         mkdir -p $(KDIR)/wndr3700/image
304         $(STAGING_DIR_HOST)/bin/wndr3700 \
305                 $(KDIR)/vmlinux-$(2).uImage \
306                 $(KDIR)/wndr3700/image/uImage
307         $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
308                 $(KDIR)/wndr3700 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp \
309                 -nopad -noappend -root-owned -be
310         -rm -rf $(KDIR)/wndr3700
311         mkimage -A mips -O linux -T filesystem -C none \
312                 -a 0xbf070000 -e 0xbf070000 \
313                 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
314                 -d $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp \
315                 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp2
316         $(STAGING_DIR_HOST)/bin/wndr3700 \
317                 $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp2 \
318                 $(KDIR)/vmlinux-$(2).uImage.squashfs
319         -rm -f $(KDIR)/vmlinux-$(2).uImage.squashfs.tmp*
320         ( \
321                 dd if=$(KDIR)/vmlinux-$(2).uImage.squashfs bs=1024k conv=sync; \
322                 dd if=$(KDIR)/root.$(1) bs=64k; \
323         ) > $(call imgname,$(1),$(2))-sysupgrade.bin
324         $(STAGING_DIR_HOST)/bin/mkdniimg \
325                 -B WNDR3700 -v OpenWrt.$(REVISION) \
326                 -i $(call imgname,$(1),$(2))-sysupgrade.bin \
327                 -o $(call imgname,$(1),$(2))-factory.img
328 endef
329
330 define Image/Build/WNDR3700/initramfs
331         $(call PatchKernelLzma,$(2),$(3) $(wndr3700_mtdlayout))
332         $(call MkImageLzma,$(KDIR)/vmlinux-$(2).bin.lzma,$(KDIR)/vmlinux-$(2).uImage)
333         $(STAGING_DIR_HOST)/bin/wndr3700 \
334                 $(KDIR)/vmlinux-$(2).uImage \
335                 $(call imgname,$(1),$(2))-uImage.bin
336 endef
337
338 define Image/Build/Template/initramfs/initramfs
339         $(call Image/Build/$(1)/initramfs,initramfs,$(2),$(3),$(4),$(5),$(6),$(7))
340 endef
341
342 define Image/Build/Template/all/squashfs
343         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
344 endef
345
346 define Image/Build/Template/all/jffs2-64k
347         $(call Image/Build/$(1),jffs2-64k,$(2),$(3),$(4),$(5),$(6),$(7))
348 endef
349
350 define Image/Build/Template/all/jffs2-128k
351         $(call Image/Build/$(1),jffs2-128k,$(2),$(3),$(4),$(5),$(6),$(7))
352 endef
353
354 define Image/Build/Template/squashfs-only/squashfs
355         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
356 endef
357
358 define Image/Build/Template/4k/squashfs
359         $(call Image/Build/$(1),squashfs-4k,$(2),$(3),$(4),$(5),$(6),$(7))
360 endef
361
362 define Image/Build/Template/64k/squashfs
363         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
364 endef
365
366 define Image/Build/Template/64k/jffs2-64k
367         $(call Image/Build/$(1),jffs2-64k,$(2),$(3),$(4),$(5),$(6),$(7))
368 endef
369
370 define Image/Build/Template/128k/squashfs
371         $(call Image/Build/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7))
372 endef
373
374 define Image/Build/Template/128k/jffs2-128k
375         $(call Image/Build/$(1),jffs2-128k,$(2),$(3),$(4),$(5),$(6),$(7))
376 endef
377
378 define Image/Build/Profile/AP81
379         $(call Image/Build/Template/$(fs_64k)/$(1),AP83,ap81,board=AP81)
380 endef
381
382 define Image/Build/Profile/AP83
383         $(call Image/Build/Template/$(fs_64k)/$(1),AP83,ap83,board=AP83)
384 endef
385
386 define Image/Build/Profile/PB42
387         $(call Image/Build/Template/$(fs_64k)/$(1),PB4X,pb42,board=PB42)
388 endef
389
390 define Image/Build/Profile/PB44
391         $(call Image/Build/Template/$(fs_64k)/$(1),PB4X,pb44,board=PB44)
392 endef
393
394 define Image/Build/Profile/WP543
395         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x200000,2M)
396         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x400000,4M)
397         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x800000,8M)
398         $(call Image/Build/Template/$(fs_64k)/$(1),MyLoader,wp543,0x1000000,16M)
399 endef
400
401 define Image/Build/Profile/DIR600A1
402         $(call Image/Build/Template/$(fs_64k)/$(1),DIR600A1,dir-600-a1,board=DIR-600-A1)
403 endef
404
405 define Image/Build/Profile/DIR615C1
406         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,dir-615-c1,board=DIR-615-C1,"AP81-AR9130-RT-070614-02")
407 endef
408
409 define Image/Build/Profile/TEW632BRP
410         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,tew-632brp,board=TEW-632BRP,"AP81-AR9130-RT-070614-00")
411 endef
412
413 define Image/Build/Profile/TEW652BRP
414         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,tew-652brp,board=TEW-632BRP,"AP81-AR9130-RT-080609-05")
415 endef
416
417 define Image/Build/Profile/A02RBW300N
418         $(call Image/Build/Template/$(fs_squash)/$(1),Cameo,a02-rb-w300n,board=TEW-632BRP,"AP81-AR9130-RT-070614-03")
419 endef
420
421 define Image/Build/Profile/UBNTRS
422         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-rs,board=UBNT-RS,RS,RSx,ar7100)
423 endef
424
425 define Image/Build/Profile/UBNTRSPRO
426         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-rspro,board=UBNT-RSPRO,RSPRO,RSPRO,ar7100pro)
427 endef
428
429 define Image/Build/Profile/UBNTLSSR71
430         $(call Image/Build/Template/$(fs_64k)/$(1),UBNT,ubnt-ls-sr71,board=UBNT-LS-SR71,LS-SR71,LS-SR71,ar7100)
431 endef
432
433 define Image/Build/Profile/UBNTBULLETM
434         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-bullet-m,board=UBNT-BM,XM,UBNTXM,ar7240)
435 endef
436
437 define Image/Build/Profile/UBNTROCKETM
438         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-rocket-m,board=UBNT-RM,XM,UBNTXM,ar7240)
439 endef
440
441 define Image/Build/Profile/UBNTNANOM
442         $(call Image/Build/Template/$(fs_64k)/$(1),UBNTXM,ubnt-nano-m,board=UBNT-NM,XM,UBNTXM,ar7240)
443 endef
444
445 define Image/Build/Profile/UBNT
446         $(call Image/Build/Profile/UBNTRS,$(1))
447         $(call Image/Build/Profile/UBNTRSPRO,$(1))
448         $(call Image/Build/Profile/UBNTLSSR71,$(1))
449         $(call Image/Build/Profile/UBNTBULLETM,$(1))
450         $(call Image/Build/Profile/UBNTROCKETM,$(1))
451         $(call Image/Build/Profile/UBNTNANOM,$(1))
452 endef
453
454 define Image/Build/Profile/MZKW04NU
455         $(call Image/Build/Template/$(fs_64k)/$(1),Planex,mzk-w04nu,board=MZK-W04NU)
456 endef
457
458 define Image/Build/Profile/MZKW300NH
459         $(call Image/Build/Template/$(fs_64k)/$(1),Planex,mzk-w300nh,board=MZK-W300NH)
460 endef
461
462 define Image/Build/Profile/TLWR741NDV1
463         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr741nd-v1,board=TL-WR741ND,TL-WR741NDv1)
464 endef
465
466 define Image/Build/Profile/TLWR841NV15
467         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr841n-v1.5,board=TL-WR841N-v1.5,TL-WR841Nv1.5)
468 endef
469
470 define Image/Build/Profile/TLWR841NDV3
471         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr841nd-v3,board=TL-WR941ND,TL-WR841NDv3)
472 endef
473
474 define Image/Build/Profile/TLWR841NDV5
475         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr841nd-v5,board=TL-WR741ND,TL-WR841NDv5)
476 endef
477
478 define Image/Build/Profile/TLWR941NDV2
479         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr941nd-v2,board=TL-WR941ND,TL-WR941NDv2)
480 endef
481
482 define Image/Build/Profile/TLWR941NDV4
483         $(call Image/Build/Template/$(fs_4k)/$(1),TPLINK,tl-wr941nd-v4,board=TL-WR741ND,TL-WR941NDv4)
484 endef
485
486 define Image/Build/Profile/TLWR1043NDV1
487         $(call Image/Build/Template/$(fs_squash)/$(1),TPLINK,tl-wr1043nd-v1,board=TL-WR1043ND,TL-WR1043NDv1)
488 endef
489
490 define Image/Build/Profile/WNDR3700
491         $(call Image/Build/Template/$(fs_64k)/$(1),WNDR3700,wndr3700,board=WNDR3700)
492 endef
493
494 define Image/Build/Profile/WRT400N
495         $(call Image/Build/Template/$(fs_64k)/$(1),WRT400N,wrt400n,board=WRT400N)
496 endef
497
498 define Image/Build/Profile/DIR825B1
499         $(call Image/Build/Template/$(fs_64k)/$(1),DIR825B1,dir-825-b1,board=DIR-825-B1)
500 endef
501
502 define Image/Build/Profile/WRT160NL
503         $(call Image/Build/Template/$(fs_64k)/$(1),CyberTAN,wrt160nl,board=WRT160NL,1.00.01)
504 endef
505
506 define Image/Build/Profile/WZRHPG300NH
507         $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG300NH,wzr-hp-g300nh,board=WZR-HP-G300NH)
508 endef
509
510 define Image/Build/Profile/Default
511         $(call Image/Build/Profile/AP81,$(1))
512         $(call Image/Build/Profile/AP83,$(1))
513         $(call Image/Build/Profile/A02RBW300N,$(1))
514         $(call Image/Build/Profile/DIR600A1,$(1))
515         $(call Image/Build/Profile/DIR615C1,$(1))
516         $(call Image/Build/Profile/DIR825B1,$(1))
517         $(call Image/Build/Profile/MZKW04NU,$(1))
518         $(call Image/Build/Profile/MZKW300NH,$(1))
519         $(call Image/Build/Profile/PB42,$(1))
520         $(call Image/Build/Profile/PB44,$(1))
521         $(call Image/Build/Profile/TEW632BRP,$(1))
522         $(call Image/Build/Profile/TEW652BRP,$(1))
523         $(call Image/Build/Profile/TLWR741NDV1,$(1))
524         $(call Image/Build/Profile/TLWR841NV15,$(1))
525         $(call Image/Build/Profile/TLWR841NDV3,$(1))
526         $(call Image/Build/Profile/TLWR841NDV5,$(1))
527         $(call Image/Build/Profile/TLWR941NDV2,$(1))
528         $(call Image/Build/Profile/TLWR941NDV4,$(1))
529         $(call Image/Build/Profile/TLWR1043NDV1,$(1))
530         $(call Image/Build/Profile/UBNT,$(1))
531         $(call Image/Build/Profile/WP543,$(1))
532         $(call Image/Build/Profile/WNDR3700,$(1))
533         $(call Image/Build/Profile/WRT400N,$(1))
534         $(call Image/Build/Profile/WRT160NL,$(1))
535         $(call Image/Build/Profile/WZRHPG300NH,$(1))
536 endef
537
538 define Image/Build/Profile/Madwifi
539         $(call Image/Build/Profile/UBNTRS,$(1))
540         $(call Image/Build/Profile/UBNTRSPRO,$(1))
541         $(call Image/Build/Profile/UBNTLSSR71,$(1))
542         $(call Image/Build/Profile/WP543,$(1))
543 endef
544
545 define Image/Build/squashfs
546         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
547         dd if=$(KDIR)/root.squashfs of=$(KDIR)/root.squashfs-4k.tmp0 bs=4k conv=sync
548         $(call add_jffs2_mark,$(KDIR)/root.squashfs-4k.tmp0)
549         dd if=$(KDIR)/root.squashfs-4k.tmp0 of=$(IMGNAME)-root.squashfs-4k bs=4k conv=sync
550         $(call add_jffs2_mark,$(IMGNAME)-root.squashfs-4k)
551         rm -f $(KDIR)/root.squashfs-4k.tmp0
552 endef
553
554 define Image/Build/Initramfs
555         $(call Image/Build/Profile/$(PROFILE),initramfs)
556 endef
557
558 define Image/Build
559         $(call Image/Build/$(1))
560         dd if=$(KDIR)/root.$(1) of=$(IMGNAME)-root.$(1) bs=128k conv=sync
561
562         $(call Image/Build/Profile/$(PROFILE),$(1))
563 endef
564
565 $(eval $(call BuildImage))