ramips: add user-space support for the Planex MZK-W300NH2 Router
[openwrt/openwrt.git] / target / linux / ramips / 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 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 define imgname
11 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1)
12 endef
13
14 define sysupname
15 $(call imgname,$(1),$(2))-sysupgrade.bin
16 endef
17
18 VMLINUX:=$(IMG_PREFIX)-vmlinux
19 UIMAGE:=$(IMG_PREFIX)-uImage
20 fs_squash:=squashfs-only
21 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
22 fs_squash:=initramfs
23 VMLINUX:=$(IMG_PREFIX)-vmlinux-initramfs
24 UIMAGE:=$(IMG_PREFIX)-uImage-initramfs
25 endif
26
27 ifeq ($(CONFIG_RALINK_RT288X),y)
28 define kernel_entry
29 -a 0x88000000 -e 0x88000000
30 endef
31 else
32 define kernel_entry
33 -a 0x80000000 -e 0x80000000
34 endef
35 endif
36
37 define mkcmdline
38 board=$(1) console=$(2),$(3)
39 endef
40
41 define CompressLzma
42 $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
43 endef
44
45 define PatchKernelLzma
46 cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
47 $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
48 $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).bin.lzma)
49 endef
50
51 define MkImage
52 $(eval imagename=$(if $(4),$(4),MIPS OpenWrt Linux-$(LINUX_VERSION)))
53 mkimage -A mips -O linux -T kernel -C $(1) $(call kernel_entry)\
54 -n "$(imagename)" \
55 -d $(2) $(3)
56 endef
57
58 define MkImageLzma
59 $(call PatchKernelLzma,$(1),$(2))
60 $(call MkImage,lzma,$(KDIR)/vmlinux-$(1).bin.lzma,$(KDIR)/vmlinux-$(1).uImage,$(3))
61 endef
62
63 define MkCombineduImage
64 $(call PatchKernelLzma,$(2),$(3))
65 if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt `expr $(4) - 64` ]; then \
66 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
67 else if [ `stat -c%s "$(KDIR)/root.$(1)"` -gt $(5) ]; then \
68 echo "Warning: $(KDIR)/root.$(1) is too big"; \
69 else \
70 ( dd if=$(KDIR)/vmlinux-$(2).bin.lzma bs=`expr $(4) - 64` conv=sync ; dd if=$(KDIR)/root.$(1) ) > $(KDIR)/vmlinux-$(2).bin.lzma.combined ; \
71 fi ; fi
72 $(call MkImage,lzma,$(KDIR)/vmlinux-$(2).bin.lzma.combined,$(call sysupname,$(1),$(2)),$(6))
73 endef
74
75 define CatFiles
76 if [ `stat -c%s "$(1)"` -gt $(2) ]; then \
77 echo "Warning: $(1) is too big"; \
78 else if [ `stat -c%s $(3)` -gt $(4) ]; then \
79 echo "Warning: $(3) is too big"; \
80 else \
81 ( dd if=$(1) bs=$(2) conv=sync; dd if=$(3) ) > $(5); \
82 fi; fi
83 endef
84
85 define Sysupgrade/KRuImage
86 $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,$(3),$(KDIR)/root.$(1),$(4),$(call sysupname,$(1),$(2)))
87 endef
88
89 define mkmtd
90 mtdparts=$(1):$(2)
91 endef
92
93 define mkmtd/phys
94 $(call mkmtd,physmap-flash.0,$(1))
95 endef
96
97 define mkmtd/spi
98 $(call mkmtd,spi0.0,$(1))
99 endef
100
101 define Image/BuildKernel
102 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(VMLINUX).elf
103 cp $(KDIR)/vmlinux $(BIN_DIR)/$(VMLINUX).bin
104 $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
105 $(call MkImage,lzma,$(KDIR)/vmlinux.bin.lzma,$(KDIR)/uImage.lzma)
106 cp $(KDIR)/uImage.lzma $(BIN_DIR)/$(UIMAGE).bin
107 $(call Image/Build/Initramfs)
108 endef
109
110 define BuildFirmware/Generic
111 $(call MkImageLzma,$(2),$(3),$(6))
112 $(call Sysupgrade/KRuImage,$(1),$(2),$(4),$(5))
113 endef
114
115 define BuildFirmware/Generic/initramfs
116 $(call MkImageLzma,$(2),$(3))
117 $(CP) $(KDIR)/vmlinux-$(2).uImage $(call imgname,$(1),$(2))-uImage.bin
118 endef
119
120 mtdlayout_4M=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
121 define BuildFirmware/GENERIC_4M
122 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_4M)),917504,2949120)
123 endef
124
125 define BuildFirmware/GENERIC_4M/initramfs
126 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_4M)))
127 endef
128
129 mtdlayout_8M=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),6976k(rootfs),7872k@0x50000(firmware)
130 kernel_size_8M=917504
131 rootfs_size_8M=7143424
132 define BuildFirmware/GENERIC_8M
133 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)),$(kernel_size_8M),$(rootfs_size_8M))
134 endef
135
136 define BuildFirmware/GENERIC_8M/initramfs
137 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)))
138 endef
139
140 define BuildFirmware/UIMAGE_8M
141 $(call MkCombineduImage,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)),$(kernel_size_8M),$(rootfs_size_8M),$(7))
142 endef
143
144 mtdlayout_edimax_3g6200n=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2752k(rootfs),128k@0x3e0000(cimage)ro,3648k@0x50000(firmware)
145 define BuildFirmware/3G6200N
146 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_edimax_3g6200n)),917504,2818048)
147 endef
148
149 mtdlayout_allnet_all5002=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,1024k(kernel),31424k(rootfs),32448k@0x50000(firmware)
150 define BuildFirmware/ALL5002
151 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_allnet_all5002)),1048576,32178176)
152 endef
153
154 define BuildFirmware/ALL5002/initramfs
155 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_allnet_all5002)))
156 endef
157
158 mtdlayout_argus_atp52b=192k(bootloader)ro,64k(config),64k(factory),1152k(kernel),6656k(rootfs),7808k@0x50000(firmware)
159 mtd_argus_atp52b_kernel_part_size=1179648
160 mtd_argus_atp52b_rootfs_part_size=6815744
161 define BuildFirmware/ARGUS_ATP52B
162 $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_argus_atp52b)),$(mtd_argus_atp52b_kernel_part_size),$(mtd_argus_atp52b_rootfs_part_size))
163 endef
164
165 # djh - Note all of these are marked Read-Only for now
166 mtdlayout_broadway=192k(bootloader)ro,64k(config)ro,64k(factory)ro,1024k(kernel)ro,6720k(rootfs),7744k@0x50000(firmware)
167 mtd_broadway_kernel_part_size=1048576
168 mtd_broadway_rootfs_part_size=6881280
169 define BuildFirmware/BROADWAY
170 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_broadway)),$(mtd_broadway_kernel_part_size),$(mtd_broadway_rootfs_part_size))
171 mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry)\
172 -n 'Broadway Kernel Image' \
173 -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage
174 $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,$(mtd_broadway_kernel_part_size),$(KDIR)/root.$(1),$(mtd_broadway_rootfs_part_size),$(call imgname,$(1),$(2))-factory.bin)
175 endef
176
177 define BuildFirmware/BROADWAY/initramfs
178 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_broadway)))
179 endef
180
181 define BuildFirmware/Buffalo
182 $(call MkImageLzma,$(2),$(3))
183 $(call Sysupgrade/KRuImage,$(1),$(2),$(4),$(5))
184 if [ -e "$(call sysupname,$(1),$(2))" ]; then \
185 buffalo-enc -p $(3) -v 1.76 \
186 -i $(KDIR)/vmlinux-$(2).uImage \
187 -o $(KDIR)/vmlinux-$(2).uImage.enc; \
188 buffalo-enc -p $(3) -v 1.76 \
189 -i $(KDIR)/root.$(1) \
190 -o $(KDIR)/root.$(2).enc; \
191 buffalo-tag -b $(3) -p $(3) -a ram -v 1.76 -m 1.01 \
192 -l mlang8 -f 1 -r EU \
193 -i $(KDIR)/vmlinux-$(2).uImage.enc \
194 -i $(KDIR)/root.$(2).enc \
195 -o $(call imgname,$(1),$(2))-factory-EU.bin; \
196 fi
197 endef
198
199
200 define BuildFirmware/Buffalo2
201 $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(4),$(5),$(6))
202 endef
203
204 mtdlayout_dir300b1=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
205 mtd_dir300b1_kernel_part_size=917504
206 mtd_dir300b1_rootfs_part_size=2949120
207 define BuildFirmware/DIR300B1
208 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_dir300b1)),$(mtd_dir300b1_kernel_part_size),$(mtd_dir300b1_rootfs_part_size))
209 mkwrgimg -s $(4) -d /dev/mtdblock/2 \
210 -i $(call sysupname,$(1),$(2)) \
211 -o $(call imgname,$(1),$(2))-factory.bin
212 endef
213
214 define BuildFirmware/DIR300B1/initramfs
215 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_dir300b1)),$(mtd_dir300b1_kernel_part_size),$(mtd_dir300b1_rootfs_part_size))
216 endef
217
218 mtdlayout_dir615h1=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
219 define BuildFirmware/DIR615H1
220 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_dir615h1)),917504,2949120)
221 mkdir615h1 -e $(call sysupname,$(1),$(2)) \
222 -o $(call imgname,$(1),$(2))-factory.bin
223 endef
224
225 define BuildFirmware/DIR615H1/initramfs
226 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_dir615h1)))
227 endef
228
229 mtdlayout_dap1350=192k(u-boot)ro,64k(devdata)ro,192k(devconf)ro,256k(devlang)ro,1088k(kernel),6400k(rootfs),7488k@0xb0000(firmware)
230 mtd_dap1350_kernel_part_size=1114112
231 mtd_dap1350_rootfs_part_size=6553600
232 define BuildFirmware/DAP1350
233 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),ttyS1,115200) $(call mkmtd/phys,$(mtdlayout_dap1350)),$(mtd_dap1350_kernel_part_size),$(mtd_dap1350_rootfs_part_size))
234 mkdapimg -s $(4) \
235 -i $(call sysupname,$(1),$(2)) \
236 -o $(call imgname,$(1),$(2))-factory.bin
237 endef
238
239 define BuildFirmware/DAP1350/initramfs
240 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),ttyS1,115200) $(call mkmtd/phys,$(mtdlayout_dap1350)),$(mtd_dap1350_kernel_part_size),$(mtd_dap1350_rootfs_part_size))
241 endef
242
243 mtdlayout_dir620a1=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),6976k(rootfs),7872k@0x50000(firmware)
244 kernel_size_dir620a1=917504
245 rootfs_size_dir620a1=7143424
246 define BuildFirmware/DIR620A1
247 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_dir620a1)),$(kernel_size_dir620a1),$(rootfs_size_dir620a1),DIR_620)
248 endef
249
250 define BuildFirmware/DIR620A1/initramfs
251 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_dir620a1)),$(kernel_size_dir620a1),$(rootfs_size_dir620a1))
252 endef
253
254 define BuildFirmware/Edimax
255 if [ -e "$(call sysupname,$(1),$(2))" ]; then \
256 mkedimaximg -i $(call sysupname,$(1),$(2)) \
257 -o $(call imgname,$(1),$(2))-factory.bin \
258 -s $(3) -m $(4) -f $(5) -S $(6); \
259 fi
260 endef
261
262 mtdlayout_f5d8235=320k(u-boot)ro,1536k(kernel),6208k(rootfs),64k(nvram),64k(factory),7744k@0x50000(firmware)
263 mtd_f5d8235_kernel_part_size=1572864
264 mtd_f5d8235_rootfs_part_size=6356992
265 define BuildFirmware/F5D8235
266 $(call BuildFirmware/Generic,$(1),$(2),$(call mkcmdline,$(3),ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_f5d8235)),$(mtd_f5d8235_kernel_part_size),$(mtd_f5d8235_rootfs_part_size))
267 endef
268
269 define BuildFirmware/FONERA20N
270 $(call BuildFirmware/GENERIC_8M,$(1),fonera20n,FONERA20N,ttyS1,57600,phys)
271 $(call BuildFirmware/Edimax,$(1),fonera20n,RSDK,NL1T,0x50000,0xc0000)
272 endef
273
274 define BuildFirmware/FONERA20N/initramfs
275 $(call BuildFirmware/GENERIC_8M/initramfs,$(1),fonera20n,FONERA20N,ttyS1,57600,phys)
276 endef
277
278 define BuildFirmware/RT-N13U
279 $(call BuildFirmware/GENERIC_8M,$(1),rt-n13u,RT-N13U,ttyS1,57600,phys)
280 endef
281
282 mtdlayout_nw718=192k(u-boot)ro,128k(config)ro,64k(factory)ro,896k(kernel),2816k(rootfs),3712k@0x60000(firmware)
283 kernel_size_nw718=917504
284 rootfs_size_nw718=2883584
285 cmdline_nw718=$(call mkcmdline,NW718,ttyS1,57600) $(call mkmtd/spi,$(mtdlayout_nw718))
286 define BuildFirmware/NW718
287 $(call BuildFirmware/Generic,$(1),$(2),$(cmdline_nw718),$(kernel_size_nw718),$(rootfs_size_nw718))
288 $(call PatchKernelLzma,$(2),$(cmdline_nw718))
289 mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry) \
290 -n "ARA1B4NCRNW718;1" \
291 -d "$(KDIR)/vmlinux-$(2).bin.lzma" \
292 "$(KDIR)/vmlinux-$(2).uImage"
293 $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,$(kernel_size_nw718),$(KDIR)/root.$(1),$(rootfs_size_nw718),$(call imgname,$(1),$(2))-factory.bin)
294 endef
295
296 mtdlayout_rtg32b1=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
297 mtd_rtg32b1_kernel_part_size=917504
298 mtd_rtg32b1_rootfs_part_size=2949120
299 define BuildFirmware/RTG32B1
300 $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/spi,$(mtdlayout_rtg32b1)),$(mtd_rtg32b1_kernel_part_size),$(mtd_rtg32b1_rootfs_part_size))
301 endef
302
303 mtdlayout_rtn10plus=192k(u-boot)ro,64k(devdata)ro,64k(devconf)ro,896k(kernel),2880k(rootfs),3776k@0x50000(firmware)
304 mtd_rtn10plus_kernel_part_size=917504
305 mtd_rtn10plus_rootfs_part_size=2949120
306 define BuildFirmware/RTN10PLUS
307 $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_rtn10plus)),$(mtd_rtn10plus_kernel_part_size),$(mtd_rtn10plus_rootfs_part_size))
308 endef
309
310 define BuildFirmware/Seama
311 $(call PatchKernelLzma,$(2),$(3))
312 if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt $(4) ]; then \
313 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \
314 else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(5) ]; then \
315 echo "Warning: $(KDIR)/root.$(1) is too big"; \
316 else \
317 ( \
318 dd if=$(KDIR)/vmlinux-$(2).bin.lzma bs=$(4) count=1 conv=sync; \
319 ) > $(KDIR)/vmlinux-$(2).tmp; \
320 $(STAGING_DIR_HOST)/bin/seama \
321 -i $(KDIR)/vmlinux-$(2).tmp \
322 -m "dev=/dev/mtdblock/2" -m "type=firmware"; \
323 ( \
324 dd if=$(KDIR)/vmlinux-$(2).tmp.seama; \
325 dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
326 ) > $(call imgname,$(1),$(2))-sysupgrade.bin; \
327 ( \
328 dd if=$(KDIR)/vmlinux-$(2).bin.lzma bs=$(4) count=1 conv=sync; \
329 dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
330 ) > $(KDIR)/vmlinux-$(2).tmp; \
331 $(STAGING_DIR_HOST)/bin/seama \
332 -i $(KDIR)/vmlinux-$(2).tmp \
333 -m "dev=/dev/mtdblock/2" -m "type=firmware"; \
334 $(STAGING_DIR_HOST)/bin/seama \
335 -s $(call imgname,$(1),$(2))-factory.bin \
336 -m "signature=$(6)" \
337 -i $(KDIR)/vmlinux-$(2).tmp.seama; \
338 fi; fi
339 endef
340
341 mtdlayout_dir645a1=192k(u-boot)ro,16k(u-boot-env)ro,16k(factory)ro,32k(nvram)ro,64k(devdata)ro,896k(kernel),6976k(rootfs),7872k@0x50000(firmware)
342 define BuildFirmware/DIR645
343 $(call BuildFirmware/Seama,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_dir645a1)),917440,7143424,$(7))
344 endef
345
346 define BuildFirmware/DIR645/initramfs
347 $(call BuildFirmware/Generic/initramfs,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_dir645a1)))
348 endef
349
350 define BuildFirmware/UMedia
351 $(call BuildFirmware/GENERIC_8M,$(1),$(2),$(3),ttyS1,57600,phys)
352 if [ -e "$(call sysupname,$(1),$(2))" ]; then \
353 fix-u-media-header -T 0x46 -B $(4) \
354 -i $(call sysupname,$(1),$(2)) \
355 -o $(call imgname,$(1),$(2))-factory.bin; \
356 fi
357 endef
358
359 define BuildFirmware/UMedia/initramfs
360 $(call BuildFirmware/GENERIC_8M/initramfs,$(1),$(2),$(3),ttyS1,57600,phys)
361 endef
362
363 define BuildFirmware/W306R_4M
364 $(call BuildFirmware/w306r,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_4M)),917504,2949120)
365 endef
366
367 define BuildFirmware/w306r
368 $(call PatchKernelLzma,$(2),$(3))
369 mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry)\
370 -n 'linkn Kernel Image' \
371 -d $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/vmlinux-$(2).uImage
372 $(call CatFiles,$(KDIR)/vmlinux-$(2).uImage,$(4),$(KDIR)/root.$(1),$(5),$(call imgname,$(1),$(2))-factory.bin)
373 endef
374
375 mtdlayout_whrg300n=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,960k(kernel),2752k(rootfs),64k(user)ro,3712k@0x50000(firmware)
376 define BuildFirmware/WHRG300N
377 $(call Image/Build/Template/GENERIC_4M,$(1),whr-g300n,WHR-G300N,ttyS1,57600,phys)
378 $(call BuildFirmware/Buffalo,$(1),whr-g300n,$(call mkcmdline,WHR-G300N,ttyS1,57600) $(call mkmtd/phys,$(mtdlayout_whrg300n)),983040,3801088)
379 ( \
380 echo -n -e "# Airstation FirmWare\nrun u_fw\nreset\n\n" | \
381 dd bs=512 count=1 conv=sync; \
382 dd if=$(call sysupname,$(1),whr-g300n); \
383 ) > $(KDIR)/whr-g300n-tftp.tmp
384 buffalo-tftp -i $(KDIR)/whr-g300n-tftp.tmp \
385 -o $(call imgname,$(1),whr-g300n)-tftp.bin
386 endef
387
388 mtdlayout_wl341v3=128k(u-boot)ro,64k(board-nvram)ro,64k(u-boot-env)ro,896k(kernel),2880k(rootfs),64k(signature-eRcOmM),3776k@0x40000(firmware),4096k@0x0(fullflash)
389 kernel_size_wl341v3=917504
390 rootfs_size_wl341v3=2949120
391 define BuildFirmware/WL341V3
392 $(call BuildFirmware/Generic,$(1),$(2),board=$(3) $(call mkmtd/phys,$(mtdlayout_wl341v3)),$(kernel_size_wl341v3),$(rootfs_size_wl341v3))
393 if [ -e "$(call sysupname,$(1),$(2))" ]; then \
394 ( \
395 dd if=/dev/zero bs=195936 count=1; \
396 echo "1.01"; \
397 dd if=/dev/zero bs=581 count=1; \
398 echo -n -e "\x73\x45\x72\x43\x6F\x4D\x6D\x00\x01\x00\x00\x59\x4E\x37\x95\x58\x10\x00\x20\x00\x28\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11\x03\x00\x00\x80\x00\x00\x00\x00\x03\x00\x00\x10\x12\x00\x00\x00\x10\x73\x45\x72\x43\x6F\x4D\x6D"; \
399 dd if=/dev/zero bs=65552 count=1; \
400 dd if=$(KDIR)/vmlinux-$(2).uImage bs=$(kernel_size_wl341v3) conv=sync; \
401 dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
402 dd if=/dev/zero bs=`expr 4194304 - 262144 - 16 - $(kernel_size_wl341v3) - \( \( \( \`stat -c%s $(KDIR)/root.$(1)\` / 65536 \) + 1 \) \* 65536 \)` count=1; \
403 echo -n -e "\x11\x03\x80\x00\x10\x12\x90\xF7\x65\x52\x63\x4F\x6D\x4D\x00\x00"; \
404 ) > $(call imgname,$(1),$(2))-factory.bin; \
405 fi
406 endef
407
408 mtdlayout_wlitx4ag300n=192k(u-boot)ro,64k(u-boot-env)ro,64k(factory)ro,896k(kernel),2816k(rootfs),64k(user)ro,3712k@0x50000(firmware)
409 define BuildFirmware/WLITX4AG300N
410 $(call BuildFirmware/Buffalo2,$(1),wli-tx4-ag300n,WLI-TX4-AG300N,$(call mkmtd/phys,$(mtdlayout_wlitx4ag300n)),917504,2883584)
411 endef
412
413 #
414 # Templates
415 #
416 define Image/Build/Template/initramfs/initramfs
417 $(call BuildFirmware/$(1)/initramfs,initramfs,$(2),$(3),$(4),$(5),$(6),$(7),$(8))
418 endef
419
420 define Image/Build/Template/squashfs-only/squashfs
421 $(call BuildFirmware/$(1),squashfs,$(2),$(3),$(4),$(5),$(6),$(7),$(8))
422 endef
423
424 #
425 # RT288X Profiles
426 #
427 define Image/Build/Profile/F5D8235V1
428 $(call Image/Build/Template/$(fs_squash)/$(1),F5D8235,f5d8235v1,F5D8235_V1)
429 endef
430
431 define Image/Build/Profile/RTN15
432 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,rt-n15,RT-N15,ttyS1,57600,phys)
433 endef
434
435 define Image/Build/Profile/V11STFE
436 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,v11st-fe,V11ST-FE,ttyS1,57600,phys)
437 endef
438
439 define Image/Build/Profile/WLITX4AG300N
440 $(call Image/Build/Template/$(fs_squash)/$(1),WLITX4AG300N)
441 endef
442
443 ifeq ($(CONFIG_RALINK_RT288X),y)
444 define Image/Build/Profile/Default
445 $(call Image/Build/Profile/F5D8235V1,$(1))
446 $(call Image/Build/Profile/RTN15,$(1))
447 $(call Image/Build/Profile/V11STFE,$(1))
448 $(call Image/Build/Profile/WLITX4AG300N,$(1))
449 endef
450 endif
451
452 #
453 # RT305X Profiles
454 #
455 define Image/Build/Profile/3G6200N
456 $(call Image/Build/Template/$(fs_squash)/$(1),3G6200N,3g-6200n,3G-6200N,ttyS1,57600,phys)
457 endef
458
459 define Image/Build/Profile/AIR3GII
460 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,air3gii,AIR3GII,ttyS1,57600,spi)
461 endef
462
463 define Image/Build/Profile/ALL02393G
464 $(call Image/Build/Template/$(fs_squash)/$(1),UIMAGE_8M,all0239-3g,ALL0239-3G,ttyS1,57600,phys)
465 endef
466
467 define Image/Build/Profile/ALL0256N
468 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,all0256n,ALL0256N,ttyS1,57600,spi)
469 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,all0256n-8M,ALL0256N,ttyS1,57600,spi)
470 endef
471
472 define Image/Build/Profile/ALL5002
473 $(call Image/Build/Template/$(fs_squash)/$(1),ALL5002,all5002,ALL5002,ttyS1,57600,spi)
474 endef
475
476 define Image/Build/Profile/ARGUS_ATP52B
477 $(call Image/Build/Template/$(fs_squash)/$(1),ARGUS_ATP52B,argus_atp52b,ARGUS_ATP52B)
478 endef
479
480 define Image/Build/Profile/BC2
481 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,bc2,BC2,ttyS1,57600,phys)
482 endef
483
484 define Image/Build/Profile/BROADWAY
485 $(call Image/Build/Template/$(fs_squash)/$(1),BROADWAY,broadway,BROADWAY,ttyS1,57600,phys)
486 endef
487
488 define Image/Build/Profile/CARAMBOLA
489 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,carambola,CARAMBOLA,ttyS1,115200,phys)
490 endef
491
492 define Image/Build/Profile/DIR300B1
493 $(call Image/Build/Template/$(fs_squash)/$(1),DIR300B1,dir-300-b1,DIR-300-B1,wrgn23_dlwbr_dir300b)
494 $(call Image/Build/Template/$(fs_squash)/$(1),DIR300B1,dir-600-b1,DIR-600-B1,wrgn23_dlwbr_dir600b)
495 $(call Image/Build/Template/$(fs_squash)/$(1),DIR300B1,dir-600-b2,DIR-600-B2,wrgn23_dlwbr_dir600b)
496 $(call Image/Build/Template/$(fs_squash)/$(1),DIR300B1,dir-615-d,DIR-615-D,wrgn23_dlwbr_dir615d)
497 $(call Image/Build/Template/$(fs_squash)/$(1),DIR620A1,dir-620-a1,DIR-620-A1)
498 endef
499
500 define Image/Build/Profile/DIR615H1
501 $(call Image/Build/Template/$(fs_squash)/$(1),DIR615H1,dir-615-h1,DIR-615-H1,ttyS1,57600,spi)
502 endef
503
504 define Image/Build/Profile/DAP1350
505 $(call Image/Build/Template/$(fs_squash)/$(1),DAP1350,dap-1350,DAP-1350,RT3052-AP-DAP1350-3)
506 endef
507
508 define Image/Build/Profile/ESR9753
509 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,esr-9753,ESR-9753,ttyS1,57600,phys)
510 endef
511
512 define Image/Build/Profile/HW5503G
513 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,hw550-3g,HW550-3G,ttyS1,57600,phys)
514 endef
515
516 define Image/Build/Profile/F5D8235V2
517 $(call Image/Build/Template/$(fs_squash)/$(1),F5D8235,f5d8235v2,F5D8235_V2)
518 endef
519
520 define Image/Build/Profile/FONERA20N
521 $(call Image/Build/Template/$(fs_squash)/$(1),FONERA20N)
522 endef
523
524 define Image/Build/Profile/RT-N13U
525 $(call Image/Build/Template/$(fs_squash)/$(1),RT-N13U)
526 endef
527
528 define Image/Build/Profile/FREESTATION5
529 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,freestation5,FREESTATION5,ttyS1,115200,phys)
530 endef
531
532 define Image/Build/Profile/MOFI35003GN
533 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,mofi3500-3gn,MOFI3500-3GN,ttyS1,57600,phys)
534 endef
535
536 define Image/Build/Profile/NBG419N
537 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,nbg-419n,NBG-419N,ttyS1,57600,phys)
538 endef
539
540 define Image/Build/Profile/NW718
541 $(call Image/Build/Template/$(fs_squash)/$(1),NW718,nw718)
542 endef
543
544 define Image/Build/Profile/OMNIEMB
545 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,omni-emb,OMNI-EMB,ttyS1,57600,phys)
546 endef
547
548 define Image/Build/Profile/PSR680W
549 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,psr-680w,PSR-680W,ttyS1,115200,phys)
550 endef
551
552 define Image/Build/Profile/PWH2004
553 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,pwh2004,PWH2004,ttyS1,57600,phys)
554 endef
555
556 define Image/Build/Profile/RTG32B1
557 $(call Image/Build/Template/$(fs_squash)/$(1),RTG32B1,rt-g32-b1,RT-G32-B1)
558 endef
559
560 define Image/Build/Profile/RTN10PLUS
561 $(call Image/Build/Template/$(fs_squash)/$(1),RTN10PLUS,rt-n10-plus,RT-N10-PLUS)
562 endef
563
564 define Image/Build/Profile/SLR7205
565 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,sl-r7205,SL-R7205,ttyS1,57600,phys)
566 endef
567
568 define Image/Build/Profile/V22RW2X2
569 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,v22rw-2x2,V22RW-2X2,ttyS1,57600,phys)
570 endef
571
572 define Image/Build/Profile/W306R_V20
573 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,w306r-v20,W306R_V20,ttyS1,57600,phys)
574 $(call Image/Build/Template/$(fs_squash)/$(1),W306R_4M,w306r-v20,W306R_V20,ttyS1,57600,phys)
575 endef
576
577 define Image/Build/Profile/W502U
578 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,w502u,W502U,ttyS1,115200,phys)
579 endef
580
581 define Image/Build/Profile/WCR150GN
582 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,wcr150gn,WCR150GN,ttyS1,57600,phys)
583 endef
584
585 define Image/Build/Profile/WHRG300N
586 $(call Image/Build/Template/$(fs_squashfs)/$(1),WHRG300N)
587 endef
588
589 define Image/Build/Profile/WL_330N
590 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,wl-330n,WL_330N,ttyS1,57600,spi)
591 endef
592
593 define Image/Build/Profile/WL_330N3G
594 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,wl-330n3g,WL_330N3G,ttyS1,57600,spi)
595 endef
596
597 define Image/Build/Profile/WL341V3
598 $(call Image/Build/Template/$(fs_squash)/$(1),WL341V3,wl341v3,WL341V3)
599 endef
600
601 define Image/Build/Profile/WL351
602 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,wl-351,WL-351,ttyS1,57600,phys)
603 endef
604
605 define Image/Build/Profile/WR5123GN
606 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,wr512-3gn-4M,WR512-3GN,ttyS1,57600,phys)
607 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,wr512-3gn-8M,WR512-3GN,ttyS1,57600,phys)
608 endef
609
610
611 define Image/Build/Profile/UPVEL
612 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,ur-336un,UR-336UN,ttyS1,57600,phys)
613 endef
614
615 define Image/Build/Profile/WR6202
616 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,wr6202,WR6202,ttyS1,115200,phys)
617 endef
618
619 define Image/Build/Profile/XDXRN502J
620 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_4M,xdxrn502j,XDXRN502J,ttyS1,57600,phys)
621 endef
622
623 ifeq ($(CONFIG_RALINK_RT305X),y)
624 define Image/Build/Profile/Default
625 $(call Image/Build/Profile/3G6200N,$(1))
626 $(call Image/Build/Profile/AIR3GII,$(1))
627 $(call Image/Build/Profile/ALL02393G,$(1))
628 $(call Image/Build/Profile/ALL0256N,$(1))
629 $(call Image/Build/Profile/ALL5002,$(1))
630 $(call Image/Build/Profile/ARGUS_ATP52B,$(1))
631 $(call Image/Build/Profile/BC2,$(1))
632 $(call Image/Build/Profile/BROADWAY,$(1))
633 $(call Image/Build/Profile/CARAMBOLA,$(1))
634 $(call Image/Build/Profile/DIR300B1,$(1))
635 $(call Image/Build/Profile/DIR615H1,$(1))
636 $(call Image/Build/Profile/DAP1350,$(1))
637 $(call Image/Build/Profile/ESR9753,$(1))
638 $(call Image/Build/Profile/F5D8235V2,$(1))
639 $(call Image/Build/Profile/RTN10PLUS,$(1))
640 $(call Image/Build/Profile/FONERA20N,$(1))
641 $(call Image/Build/Profile/RT-N13U,$(1))
642 $(call Image/Build/Profile/FREESTATION5,$(1))
643 $(call Image/Build/Profile/HW5503G,$(1))
644 $(call Image/Build/Profile/MOFI35003GN,$(1))
645 $(call Image/Build/Profile/NBG419N,$(1))
646 $(call Image/Build/Profile/NW718,$(1))
647 $(call Image/Build/Profile/OMNIEMB,$(1))
648 $(call Image/Build/Profile/PSR680W,$(1))
649 $(call Image/Build/Profile/PWH2004,$(1))
650 $(call Image/Build/Profile/RTG32B1,$(1))
651 $(call Image/Build/Profile/SLR7205,$(1))
652 $(call Image/Build/Profile/V22RW2X2,$(1))
653 $(call Image/Build/Profile/W306R_V20,$(1))
654 $(call Image/Build/Profile/W502U,$(1))
655 $(call Image/Build/Profile/WCR150GN,$(1))
656 $(call Image/Build/Profile/WHRG300N,$(1))
657 $(call Image/Build/Profile/WL_330N,$(1))
658 $(call Image/Build/Profile/WL_330N3G,$(1))
659 $(call Image/Build/Profile/WL341V3,$(1))
660 $(call Image/Build/Profile/WL351,$(1))
661 $(call Image/Build/Profile/WR5123GN,$(1))
662 $(call Image/Build/Profile/WR6202,$(1))
663 $(call Image/Build/Profile/XDXRN502J,$(1))
664 endef
665 endif
666
667 #
668 # RT3662/RT3883 Profiles
669 #
670 define Image/Build/Profile/DIR645
671 $(call Image/Build/Template/$(fs_squash)/$(1),DIR645,dir-645,DIR-645,ttyS1,57600,spi,wrgn39_dlob.hans_dir645)
672 endef
673
674 define Image/Build/Profile/RTN56U
675 $(call Image/Build/Template/$(fs_squash)/$(1),GENERIC_8M,rt-n56u,RT-N56U,ttyS1,57600,phys)
676 endef
677
678 define Image/Build/Profile/TEW691GR
679 $(call Image/Build/Template/$(fs_squash)/$(1),UMedia,tew-691gr,TEW-691GR,0x026910)
680 endef
681
682 define Image/Build/Profile/TEW692GR
683 $(call Image/Build/Template/$(fs_squash)/$(1),UMedia,tew-692gr,TEW-692GR,0x026920)
684 endef
685
686 ifeq ($(CONFIG_RALINK_RT3883),y)
687 define Image/Build/Profile/Default
688 $(call Image/Build/Profile/DIR645,$(1))
689 $(call Image/Build/Profile/RTN56U,$(1))
690 $(call Image/Build/Profile/TEW691GR,$(1))
691 $(call Image/Build/Profile/TEW692GR,$(1))
692 endef
693 endif
694
695 define Image/Build/Initramfs
696 $(call Image/Build/Profile/$(PROFILE),initramfs)
697 endef
698
699 define Image/Build/squashfs
700 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
701 endef
702
703 define Image/Build
704 $(call Image/Build/$(1))
705 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
706 $(call Image/Build/Profile/$(PROFILE),$(1))
707 endef
708
709 $(eval $(call BuildImage))