5e2d6b7762c2730b7143cd060d5e18bd9ee441f5
[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
21 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
22 VMLINUX:=$(IMG_PREFIX)-vmlinux-initramfs
23 UIMAGE:=$(IMG_PREFIX)-uImage-initramfs
24 define Image/Build/Initramfs
25         $(call Image/Build/Profile/$(PROFILE),initramfs)
26 endef
27 endif
28
29 ifeq ($(CONFIG_SOC_RT288X),y)
30 define kernel_entry
31 -a 0x88000000 -e 0x88000000
32 endef
33 else
34 define kernel_entry
35 -a 0x80000000 -e 0x80000000
36 endef
37 endif
38
39 define MkCombineduImage
40         $(call PatchKernelLzma,$(2),$(3))
41         if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt `expr $(4) - 64` ]; then \
42                 echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big" >&2; \
43         else if [ `stat -c%s "$(KDIR)/root.$(1)"` -gt $(5) ]; then \
44                 echo "Warning: $(KDIR)/root.$(1) is too big" >&2; \
45         else \
46                 ( dd if=$(KDIR)/vmlinux-$(2).bin.lzma bs=`expr $(4) - 64` conv=sync ; dd if=$(KDIR)/root.$(1) ) > $(KDIR)/vmlinux-$(2).bin.lzma.combined ; \
47         fi ; fi
48         $(call MkImage,lzma,$(KDIR)/vmlinux-$(2).bin.lzma.combined,$(call sysupname,$(1),$(2)),$(6))
49 endef
50
51
52 #
53 # The real magic happens inside these templates
54 #
55
56 define MkImage
57         $(eval imagename=$(if $(4),$(4),MIPS OpenWrt Linux-$(LINUX_VERSION)))
58         -mkimage -A mips -O linux -T kernel -C $(1) $(call kernel_entry)\
59                 -n "$(imagename)" \
60                 -d $(2) $(3)
61 endef
62
63 define CompressLzma
64         $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
65 endef
66
67 define MkImageSysupgrade/squashfs
68         $(eval output_name=$(IMG_PREFIX)-$(2)-$(1)-$(if $(4),$(4),sysupgrade).bin)
69         cat $(KDIR)/vmlinux-$(2).uImage $(KDIR)/root.$(1) > $(KDIR)/$(output_name)
70         $(call prepare_generic_squashfs,$(KDIR)/$(output_name))
71         if [ `stat -c%s "$(KDIR)/$(output_name)"` -gt $(3) ]; then \
72                 echo "Warning: $(KDIR)/$(output_name) is too big" >&2; \
73         else \
74                 $(CP) $(KDIR)/$(output_name) $(BIN_DIR)/$(output_name); \
75         fi
76 endef
77
78 define PatchKernelLzmaDtb
79         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
80         $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(2).dtb ../dts/$(2).dts
81         $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux-$(1) $(KDIR)/$(2).dtb
82         $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).bin.lzma)
83 endef
84
85 define MkImageLzmaDtb
86         $(call PatchKernelLzmaDtb,$(1),$(2))
87         $(call MkImage,lzma,$(KDIR)/vmlinux-$(1).bin.lzma,$(KDIR)/vmlinux-$(1).uImage,$(3))
88 endef
89
90 define BuildFirmware/OF
91         $(call MkImageLzmaDtb,$(2),$(3),$(5))
92         $(call MkImageSysupgrade/$(1),$(1),$(2),$(4),$(6))
93 endef
94
95 define BuildFirmware/OF/initramfs
96         $(call MkImageLzmaDtb,$(2),$(3))
97         $(CP) $(KDIR)/vmlinux-$(2).uImage $(call imgname,$(1),$(2))-uImage.bin
98 endef
99
100
101 # Build images for default ralink layout for 4MB flash
102 # kernel + roots = 0x3b0000
103 # $(1) = squashfs/initramfs
104 # $(2) = lowercase board name
105 # $(3) = dts file
106 ralink_default_fw_size_4M=3866624
107 BuildFirmware/Default4M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_4M))
108 BuildFirmware/Default4M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
109
110 # Build images for default ralink layout for 8MB flash
111 # kernel + roots = 0x7b0000
112 # $(1) = squashfs/initramfs
113 # $(2) = lowercase board name
114 # $(3) = dts file
115 ralink_default_fw_size_8M=8060928
116 BuildFirmware/Default8M/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_8M))
117 BuildFirmware/Default8M/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
118
119 # Build images for a custom sized flash layout
120 # $(1) = squashfs/initramfs
121 # $(2) = lowercase board name
122 # $(3) = dts file
123 # $(4) = kernel + rootfs size
124 BuildFirmware/CustomFlash/squashfs=$(call BuildFirmware/OF,$(1),$(2),$(3),$(4),$(5),$(6))
125 BuildFirmware/CustomFlash/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
126
127 # wrappers for boards that have 4MB and 8MB versions
128 define BuildFirmware/DefaultDualSize/squashfs
129         $(call BuildFirmware/Default4M/$(1),$(1),$(2)-4M,$(3)-4M)
130         $(call BuildFirmware/Default8M/$(1),$(1),$(2)-8M,$(3)-8M)
131 endef
132 define BuildFirmware/DefaultDualSize/initramfs
133         $(call BuildFirmware/OF/initramfs,$(1),$(2)-4M,$(3)-4M)
134         $(call BuildFirmware/OF/initramfs,$(1),$(2)-8M,$(3)-8M)
135 endef
136
137 # Some boards need a special header inside the uImage to make them bootable
138 define BuildFirmware/CustomFlashFactory/squashfs
139         $(call BuildFirmware/CustomFlash/$(1),$(1),$(2),$(3),$(4))
140         $(call BuildFirmware/CustomFlash/$(1),$(1),$(2),$(3),$(4),$(5),$(6))
141 endef
142 BuildFirmware/CustomFlashFactory/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
143
144 # sign an image to make it work with edimax tftp recovery
145 define BuildFirmware/Edimax/squashfs
146         $(call BuildFirmware/OF,$(1),$(2),$(3),$(4))
147         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
148                 mkedimaximg -i $(call sysupname,$(1),$(2)) \
149                         -o $(call imgname,$(1),$(2))-factory.bin \
150                         -s $(5) -m $(6) -f $(7) -S $(8); \
151         fi
152 endef
153 BuildFirmware/Edimax/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
154
155 # build Seama header images
156 define BuildFirmware/Seama/squashfs
157         $(call BuildFirmware/OF,$(1),$(2),$(3),$(ralink_default_fw_size_8M))
158         cat $(KDIR)/vmlinux-$(2).bin.lzma $(KDIR)/root.$(1) > $(KDIR)/img_$(2).$(1).tmp
159         if [ `stat -c%s "$(KDIR)/img_$(2).$(1).tmp"` -gt 8060864 ]; then \
160                 echo "Warning: $(KDIR)/img_$(2).$(1).tmp is too big" >&2; \
161         else \
162                 dd if=$(KDIR)/vmlinux-$(2).bin.lzma of=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=64k conv=sync; \
163                 ( \
164                         dd if=$(KDIR)/vmlinux-$(2).bin.lzma.padded bs=1 count=`expr \`stat -c%s $(KDIR)/vmlinux-$(2).bin.lzma.padded\` - 64`; \
165                         dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
166                 ) > $(KDIR)/vmlinux-$(2).tmp; \
167                 $(STAGING_DIR_HOST)/bin/seama \
168                         -i $(KDIR)/vmlinux-$(2).tmp \
169                         -m "dev=/dev/mtdblock/2" -m "type=firmware"; \
170                 $(STAGING_DIR_HOST)/bin/seama \
171                         -s $(call imgname,$(1),$(2))-factory.bin \
172                         -m "signature=$(4)" \
173                         -i $(KDIR)/vmlinux-$(2).tmp.seama; \
174         fi
175 endef
176 BuildFirmware/Seama/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
177
178 # sign Buffalo images
179 define BuildFirmware/Buffalo
180         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
181                 buffalo-enc -p $(3) -v 1.76 \
182                         -i $(KDIR)/vmlinux-$(2).uImage \
183                         -o $(KDIR)/vmlinux-$(2).uImage.enc; \
184                 buffalo-enc -p $(3) -v 1.76 \
185                         -i $(KDIR)/root.$(1) \
186                         -o $(KDIR)/root.$(2).enc; \
187                 buffalo-tag -b $(3) -p $(3) -a ram -v 1.76 -m 1.01 \
188                         -l mlang8 -f 1 -r EU \
189                         -i $(KDIR)/vmlinux-$(2).uImage.enc \
190                         -i $(KDIR)/root.$(2).enc \
191                         -o $(call imgname,$(1),$(2))-factory-EU.bin; \
192         fi
193 endef
194
195 # sign trednet / UMedia images
196 define BuildFirmware/UMedia/squashfs
197         $(call BuildFirmware/Default8M/$(1),$(1),$(2),$(3))
198         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
199                 fix-u-media-header -T 0x46 -B $(4) \
200                         -i $(call sysupname,$(1),$(2)) \
201                         -o $(call imgname,$(1),$(2))-factory.bin; \
202         fi
203 endef
204 BuildFirmware/UMedia/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
205
206 # sign dap 1350 based images
207 dap1350_mtd_size=7667712
208 define BuildFirmware/dap1350/squashfs
209         $(call BuildFirmware/CustomFlash/$(1),$(1),$(2),$(3),$(dap1350_mtd_size))
210         -mkdapimg -s $(4) \
211                 -i $(call sysupname,$(1),$(2)) \
212                 -o $(call imgname,$(1),$(2))-factory.bin
213 endef
214 BuildFirmware/dap1350/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
215
216 #
217 # RT288X Profiles
218 #
219
220 # 0x790000
221 belkin_f5d8235v1_mtd_size=7929856
222 Image/Build/Profile/F5D8235V1=$(call BuildFirmware/CustomFlash/$(1),$(1),f5d8235v1,F5D8235_V1,$(belkin_f5d8235v1_mtd_size))
223
224 Image/Build/Profile/RTN15=$(call BuildFirmware/Default4M/$(1),$(1),rt-n15,RT-N15)
225
226 Image/Build/Profile/V11STFE=$(call BuildFirmware/Default4M/$(1),$(1),v11st-fe,V11STFE)
227
228 Image/Build/Profile/WLITX4AG300N=$(call BuildFirmware/Default4M/$(1),$(1),wli-tx4-ag300n,WLI-TX4-AG300N)
229
230 ifeq ($(SUBTARGET),rt288x)
231 define Image/Build/Profile/Default
232         $(call Image/Build/Profile/F5D8235V1,$(1))
233         $(call Image/Build/Profile/RTN15,$(1))
234         $(call Image/Build/Profile/V11STFE,$(1))
235         $(call Image/Build/Profile/WLITX4AG300N,$(1))
236 endef
237 endif
238
239
240
241 #
242 # RT305X Profiles
243 #
244
245 edimax_3g6200n_mtd_size=3735552
246 Image/Build/Profile/3G6200N=$(call BuildFirmware/Edimax/$(1),$(1),3g-6200n,3G-6200N,$(edimax_3g6200n_mtd_size),CSYS,3G62,0x50000,0xc0000)
247
248 Image/Build/Profile/3G6200NL=$(call BuildFirmware/Edimax/$(1),$(1),3g-6200nl,3G-6200NL,$(edimax_3g6200n_mtd_size),CSYS,3G62,0x50000,0xc0000)
249
250 Image/Build/Profile/3G300M=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),3g300m,3G300M,$(ralink_default_fw_size_4M),3G150M_SPI Kernel Image,factory)
251
252 Image/Build/Profile/AIR3GII=$(call BuildFirmware/Default4M/$(1),$(1),air3gii,AIR3GII)
253
254 define BuildFirmware/UIMAGE_8M
255         $(call MkCombineduImage,$(1),$(2),$(call mkcmdline,$(3),$(4),$(5)) $(call mkmtd/$(6),$(mtdlayout_8M)),$(kernel_size_8M),$(rootfs_size_8M),$(7))
256 endef
257 define Image/Build/Profile/ALL02393G
258         $(call Image/Build/Template/$(image_type)/$(1),UIMAGE_8M,all0239-3g,ALL0239-3G,ttyS1,57600,phys)
259 endef
260
261 Image/Build/Profile/ALL0256N=$(call BuildFirmware/DefaultDualSize/$(1),$(1),all0256n,ALL0256N)
262
263 allnet_all5002_mtd_size=33226752
264 Image/Build/Profile/ALL5002=$(call BuildFirmware/CustomFlash/$(1),$(1),all5002,ALL5002,$(allnet_all5002_mtd_size))
265 Image/Build/Profile/ALL5003=$(call BuildFirmware/CustomFlash/$(1),$(1),all5003,ALL5003,$(allnet_all5002_mtd_size))
266
267 argus_atp52b_mtd_size=7995392
268 Image/Build/Profile/ARGUS_ATP52B=$(call BuildFirmware/CustomFlash/$(1),$(1),argus_atp52b,ARGUS_ATP52B,$(argus_atp52b_mtd_size))
269
270 asl26555_8mb_mtd_size=7929856
271 asl26555_16mb_mtd_size=16252928
272 define BuildFirmware/ASL26555/squashfs
273         $(call BuildFirmware/CustomFlash/$(1),$(1),$(2)-8M,$(3)-8M,$(asl26555_8mb_mtd_size))
274         $(call BuildFirmware/CustomFlash/$(1),$(1),$(2)-16M,$(3)-16M,$(asl26555_16mb_mtd_size))
275 endef
276 define BuildFirmware/ASL26555/initramfs
277         $(call BuildFirmware/OF/initramfs,$(1),$(2)-8M,$(3)-8M)
278         $(call BuildFirmware/OF/initramfs,$(1),$(2)-16M,$(3)-16M)
279 endef
280 Image/Build/Profile/ASL26555=$(call BuildFirmware/ASL26555/$(1),$(1),asl26555,ASL26555)
281
282 Image/Build/Profile/BC2=$(call BuildFirmware/Default8M/$(1),$(1),bc2,BC2)
283
284 broadway_mtd_size=7929856
285 Image/Build/Profile/BROADWAY=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),broadway,BROADWAY,$(broadway_mtd_size),Broadway Kernel Image,factory)
286
287 Image/Build/Profile/CARAMBOLA=$(call BuildFirmware/Default8M/$(1),$(1),carambola,CARAMBOLA)
288
289 Image/Build/Profile/D105=$(call BuildFirmware/Default4M/$(1),$(1),d105,D105)
290
291 define BuildFirmware/DIR300B1/squashfs
292         $(call BuildFirmware/Default4M/$(1),$(1),$(2),$(3))
293         -mkwrgimg -s $(4) -d /dev/mtdblock/2 \
294                 -i $(call sysupname,$(1),$(2)) \
295                 -o $(call imgname,$(1),$(2))-factory.bin
296 endef
297 BuildFirmware/DIR300B1/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
298 Image/Build/Profile/DIR-300-B1=$(call BuildFirmware/DIR300B1/$(1),$(1),dir-300-b1,DIR-300-B1,wrgn23_dlwbr_dir300b)
299 Image/Build/Profile/DIR-600-B1=$(call BuildFirmware/DIR300B1/$(1),$(1),dir-600-b1,DIR-600-B1,wrgn23_dlwbr_dir600b)
300 Image/Build/Profile/DIR-600-B2=$(call BuildFirmware/DIR300B1/$(1),$(1),dir-600-b2,DIR-600-B2,wrgn23_dlwbr_dir600b)
301 Image/Build/Profile/DIR-615-D=$(call BuildFirmware/DIR300B1/$(1),$(1),dir-615-d,DIR-615-D,wrgn23_dlwbr_dir615d)
302
303 Image/Build/Profile/DIR-620-A1=$(call BuildFirmware/Default8M/$(1),$(1),dir-620-a1,DIR-620-A1)
304 Image/Build/Profile/DIR-620-D1=$(call BuildFirmware/Default8M/$(1),$(1),dir-620-d1,DIR-620-D1)
305
306 define BuildFirmware/DIR615H1/squashfs
307         $(call BuildFirmware/Default4M/$(1),$(1),dir-615-h1,DIR-615-H1)
308         -mkdir615h1 -e $(call sysupname,$(1),dir-615-h1) \
309                 -o $(call imgname,$(1),dir-615-h1)-factory.bin
310 endef
311 BuildFirmware/DIR615H1/initramfs=$(call BuildFirmware/OF/initramfs,$(1),dir-615-h1,DIR-615-H1)
312 Image/Build/Profile/DIR615H1=$(call BuildFirmware/DIR615H1/$(1),$(1))
313
314 Image/Build/Profile/DAP1350=$(call BuildFirmware/dap1350/$(1),$(1),dap-1350,DAP-1350,RT3052-AP-DAP1350-3)
315
316 Image/Build/Profile/DAP1350WW=$(call BuildFirmware/dap1350/$(1),$(1),dap-1350WW,DAP-1350,RT3052-AP-DAP1350WW-3)
317
318 Image/Build/Profile/ESR-9753=$(call BuildFirmware/Default4M/$(1),$(1),esr-9753,ESR-9753)
319
320 Image/Build/Profile/HW550-3G=$(call BuildFirmware/Default8M/$(1),$(1),hw550-3g,HW550-3G)
321
322 belkin_f5d8235v2_mtd_size=7929856
323 Image/Build/Profile/F5D8235V2=$(call BuildFirmware/CustomFlash/$(1),$(1),f5d8235v2,F5D8235_V2,$(belkin_f5d8235v2_mtd_size))
324
325 Image/Build/Profile/FONERA20N=$(call BuildFirmware/Edimax/$(1),$(1),fonera20n,FONERA20N,$(ralink_default_fw_size_8M),RSDK,NL1T,0x50000,0xc0000)
326
327 Image/Build/Profile/RT-N13U=$(call BuildFirmware/Default8M/$(1),$(1),rt-n13u,RT-N13U)
328
329 Image/Build/Profile/FREESTATION5=$(call BuildFirmware/Default8M/$(1),$(1),freestation5,FREESTATION5)
330
331 Image/Build/Profile/MOFI3500-3GN=$(call BuildFirmware/Default8M/$(1),$(1),mofi3500-3gn,MOFI3500-3GN)
332
333 Image/Build/Profile/NBG-419N=$(call BuildFirmware/Default4M/$(1),$(1),nbg-419n,NBG-419N)
334
335 Image/Build/Profile/MZKW300NH2=$(call BuildFirmware/Edimax/$(1),$(1),mzk-w300nh2,MZK-W300NH2,$(mzkw300nh2_mtd_size),CSYS,RN52,0x50000,0xc0000)
336
337 nw718_mtd_size=3801088
338 Image/Build/Profile/NW718=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),nw718m,NW718,$(nw718_mtd_size),ARA1B4NCRNW718;1,factory)
339
340 Image/Build/Profile/OMNI-EMB=$(call BuildFirmware/Default8M/$(1),$(1),omni-emb,OMNI-EMB)
341
342 Image/Build/Profile/PSR-680W=$(call BuildFirmware/Default4M/$(1),$(1),psr-680w,PSR-680W)
343
344 Image/Build/Profile/PWH2004=$(call BuildFirmware/Default8M/$(1),$(1),pwh2004,PWH2004)
345
346 Image/Build/Profile/RTG32B1=$(call BuildFirmware/Default4M/$(1),$(1),rt-g32-b1,RT-G32-B1)
347
348 Image/Build/Profile/RTN10PLUS=$(call BuildFirmware/Default4M/$(1),$(1),rt-n10-plus,RT-N10-PLUS)
349
350 Image/Build/Profile/SL-R7205=$(call BuildFirmware/Default4M/$(1),$(1),sl-r7205,SL-R7205)
351
352 Image/Build/Profile/V22RW-2X2=$(call BuildFirmware/Default4M/$(1),$(1),v22rw-2x2,V22RW-2X2)
353
354 Image/Build/Profile/W150M=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),w150m,W150M,$(ralink_default_fw_size_4M),W150M Kernel Image,factory)
355
356 Image/Build/Profile/W306R_V20=$(call BuildFirmware/CustomFlashFactory/$(1),$(1),w306r-v20,W306R_V20,$(ralink_default_fw_size_4M),linkn Kernel Image,factory)
357
358 Image/Build/Profile/W502U=$(call BuildFirmware/Default8M/$(1),$(1),w502u,W502U)
359
360 Image/Build/Profile/WCR150GN=$(call BuildFirmware/Default4M/$(1),$(1),wcr150gn,WCR150GN)
361
362 buffalo_whrg300n_mtd_size=3801088
363 define BuildFirmware/WHRG300N/squashfs
364         $(call BuildFirmware/Default4M/$(1),$(1),whr-g300n,WHR-G300N)
365         # the following line has a bad argument 3 ... the old Makefile was already broken       
366         $(call BuildFirmware/Buffalo,$(1),whr-g300n,whr-g300n)
367         ( \
368                 echo -n -e "# Airstation FirmWare\nrun u_fw\nreset\n\n" | \
369                         dd bs=512 count=1 conv=sync; \
370                 dd if=$(call sysupname,$(1),whr-g300n); \
371         ) > $(KDIR)/whr-g300n-tftp.tmp
372         buffalo-tftp -i $(KDIR)/whr-g300n-tftp.tmp \
373                 -o $(call imgname,$(1),whr-g300n)-tftp.bin
374 endef
375 BuildFirmware/WHRG300N/initramfs=$(call BuildFirmware/OF/initramfs,$(1),whr-g300n,WHR-G300N)
376 Image/Build/Profile/WHRG300N=$(call BuildFirmware/WHRG300N/$(1),$(1))
377
378 Image/Build/Profile/WL_330N=$(call BuildFirmware/Default4M/$(1),$(1),wl-330n,WL_330N)
379
380 Image/Build/Profile/WL_330N3G=$(call BuildFirmware/Default4M/$(1),$(1),wl-330n3g,WL_330N3G)
381
382 kernel_size_wl341v3=917504
383 rootfs_size_wl341v3=2949120
384 define BuildFirmware/WL341V3/squashfs
385         $(call BuildFirmware/Default4M/$(1),$(1),wl341v3,WL341V3)
386         # This code looks broken and really needs to be converted to C
387         if [ -e "$(call sysupname,$(1),$(2))" ]; then \
388                 ( \
389                         dd if=/dev/zero bs=195936 count=1; \
390                         echo "1.01"; \
391                         dd if=/dev/zero bs=581 count=1; \
392                         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"; \
393                         dd if=/dev/zero bs=65552 count=1; \
394                         dd if=$(KDIR)/vmlinux-$(2).uImage bs=$(kernel_size_wl341v3) conv=sync; \
395                         dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
396                         dd if=/dev/zero bs=`expr 4194304 - 262144 - 16 - $(kernel_size_wl341v3) - \( \( \( \`stat -c%s $(KDIR)/root.$(1)\` / 65536 \) + 1 \) \* 65536 \)` count=1; \
397                         echo -n -e "\x11\x03\x80\x00\x10\x12\x90\xF7\x65\x52\x63\x4F\x6D\x4D\x00\x00"; \
398                 ) > $(call imgname,$(1),$(2))-factory.bin; \
399         fi
400 endef
401 BuildFirmware/WL341V3/initramfs=$(call BuildFirmware/OF/initramfs,$(1),wl341v3,WL341V3)
402 Image/Build/Profile/WL341V3=$(call BuildFirmware/WL341V3/$(1),$(1))
403
404 Image/Build/Profile/WL-351=$(call BuildFirmware/Default4M/$(1),$(1),wl-351,WL-351)
405
406 define BuildFirmware/WNCE2001/squashfs
407         $(call BuildFirmware/Default4M/$(1),$(1),$(2),$(3))
408         -mkdapimg -s RT3052-AP-WNCE2001-3 -r WW -v 1.0.0.99 \
409                 -i $(call sysupname,$(1),$(2)) \
410                 -o $(call imgname,$(1),$(2))-factory-worldwide.bin
411         -mkdapimg -s RT3052-AP-WNCE2001-3 -r NA -v 1.0.0.99 \
412                 -i $(call sysupname,$(1),$(2)) \
413                 -o $(call imgname,$(1),$(2))-factory-northamerica.bin
414 endef
415 BuildFirmware/WNCE2001/initramfs=$(call BuildFirmware/OF/initramfs,$(1),$(2),$(3))
416 Image/Build/Profile/WNCE2001=$(call BuildFirmware/WNCE2001/$(1),$(1),wnce2001,WNCE2001)
417
418 Image/Build/Profile/WR512-3GN=$(call BuildFirmware/DefaultDualSize/$(1),$(1),wr512-3ng,WR512-3GN)
419
420 Image/Build/Profile/UR-326N4G=$(call BuildFirmware/Default4M/$(1),$(1),ur-326n4g,UR-326N4G)
421
422 Image/Build/Profile/UR-336UN=$(call BuildFirmware/Default8M/$(1),$(1),ur-336un,UR-336UN)
423
424 Image/Build/Profile/WR6202=$(call BuildFirmware/Default8M/$(1),$(1),wr6202,WR6202)
425
426 Image/Build/Profile/XDXRN502J=$(call BuildFirmware/Default4M/$(1),$(1),xdxrn502j,XDXRN502J)
427
428 ifeq ($(SUBTARGET),rt305x)
429 define Image/Build/Profile/Default
430         $(call Image/Build/Profile/3G6200N,$(1))
431         $(call Image/Build/Profile/3G6200NL,$(1))
432         $(call Image/Build/Profile/3G300M,$(1))
433         $(call Image/Build/Profile/AIR3GII,$(1))
434         $(call Image/Build/Profile/ALL02393G,$(1))
435         $(call Image/Build/Profile/ALL0256N,$(1))
436         $(call Image/Build/Profile/ALL5002,$(1))
437         $(call Image/Build/Profile/ALL5003,$(1))
438         $(call Image/Build/Profile/ARGUS_ATP52B,$(1))
439         $(call Image/Build/Profile/ASL26555,$(1))
440         $(call Image/Build/Profile/BC2,$(1))
441         $(call Image/Build/Profile/BROADWAY,$(1))
442         $(call Image/Build/Profile/CARAMBOLA,$(1))
443         $(call Image/Build/Profile/D105,$(1))
444         $(call Image/Build/Profile/DIR-300-B1,$(1))
445         $(call Image/Build/Profile/DIR-600-B1,$(1))
446         $(call Image/Build/Profile/DIR-600-B2,$(1))
447         $(call Image/Build/Profile/DIR-615-D,$(1))
448         $(call Image/Build/Profile/DIR-620-A1,$(1))
449         $(call Image/Build/Profile/DIR-620-D1,$(1))
450         $(call Image/Build/Profile/DIR615H1,$(1))
451         $(call Image/Build/Profile/DAP1350,$(1))
452         $(call Image/Build/Profile/DAP1350WW,$(1))
453         $(call Image/Build/Profile/ESR-9753,$(1))
454         $(call Image/Build/Profile/F5D8235V2,$(1))
455         $(call Image/Build/Profile/FONERA20N,$(1))
456         $(call Image/Build/Profile/FREESTATION5,$(1))
457         $(call Image/Build/Profile/HW550-3G,$(1))
458         $(call Image/Build/Profile/MOFI3500-3GN,$(1))
459         $(call Image/Build/Profile/MZKW300NH2,$(1))
460         $(call Image/Build/Profile/NBG-419N,$(1))
461         $(call Image/Build/Profile/NW718,$(1))
462         $(call Image/Build/Profile/OMNI-EMB,$(1))
463         $(call Image/Build/Profile/PSR-680W,$(1))
464         $(call Image/Build/Profile/PWH2004,$(1))
465         $(call Image/Build/Profile/RTG32B1,$(1))
466         $(call Image/Build/Profile/RTN10PLUS,$(1))
467         $(call Image/Build/Profile/RT-N13U,$(1))
468         $(call Image/Build/Profile/SL-R7205,$(1))
469         $(call Image/Build/Profile/UR-326N4G,$(1))
470         $(call Image/Build/Profile/V22RW-2X2,$(1))
471         $(call Image/Build/Profile/W150M,$(1))
472         $(call Image/Build/Profile/W306R_V20,$(1))
473         $(call Image/Build/Profile/W502U,$(1))
474         $(call Image/Build/Profile/WCR150GN,$(1))
475         $(call Image/Build/Profile/WHRG300N,$(1))
476         $(call Image/Build/Profile/WL_330N,$(1))
477         $(call Image/Build/Profile/WL_330N3G,$(1))
478         $(call Image/Build/Profile/WL341V3,$(1))
479         $(call Image/Build/Profile/WL-351,$(1))
480         $(call Image/Build/Profile/WNCE2001,$(1))
481         $(call Image/Build/Profile/WR512-3GN,$(1))
482         $(call Image/Build/Profile/WR6202,$(1))
483         $(call Image/Build/Profile/XDXRN502J,$(1))
484 endef
485 endif
486
487
488
489 #
490 # RT3662/RT3883 Profiles
491 #
492 Image/Build/Profile/DIR645=$(call BuildFirmware/Seama/$(1),$(1),dir-645,DIR-645,wrgn39_dlob.hans_dir645)
493
494 omniembhpm_mtd_size=16449536
495 Image/Build/Profile/OMNIEMBHPM=$(call BuildFirmware/CustomFlash/$(1),$(1),omni-emb-hpm,OMNI-EMB-HPM,$(omniembhpm_mtd_size))
496
497 Image/Build/Profile/RTN56U=$(call BuildFirmware/Default8M/$(1),$(1),rt-n56u,RTN56U)
498
499 Image/Build/Profile/TEW691GR=$(call BuildFirmware/UMedia/$(1),$(1),tew-691gr,TEW-691GR,0x026910)
500
501 #Image/Build/Profile/TEW692GR=$(call BuildFirmware/UMedia/$(1),$(1),tew-692gr,TEW-692GR,0x026920)
502
503 ifeq ($(SUBTARGET),rt3883)
504 define Image/Build/Profile/Default
505         $(call Image/Build/Profile/DIR645,$(1))
506         $(call Image/Build/Profile/OMNIEMBHPM,$(1))
507         $(call Image/Build/Profile/RTN56U,$(1))
508         $(call Image/Build/Profile/TEW691GR,$(1))
509         $(call Image/Build/Profile/TEW692GR,$(1))
510 endef
511 endif
512
513
514 #
515 # Generic Targets
516 #
517 define Image/BuildKernel
518         cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(VMLINUX).elf
519         cp $(KDIR)/vmlinux $(BIN_DIR)/$(VMLINUX).bin
520         $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
521         $(call MkImage,lzma,$(KDIR)/vmlinux.bin.lzma,$(KDIR)/uImage.lzma)
522         cp $(KDIR)/uImage.lzma $(BIN_DIR)/$(UIMAGE).bin
523         $(call Image/Build/Initramfs)
524 endef
525
526 define Image/Build
527         $(call Image/Build/$(1))
528         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
529         $(call Image/Build/Profile/$(PROFILE),$(1))
530 endef
531
532 $(eval $(call BuildImage))