brcm47xx: image: switch Netgear WGT634U to the new building system
[openwrt/staging/chunkeey.git] / target / linux / brcm47xx / image / Makefile
1 #
2 # Copyright (C) 2006-2016 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 Build/Clean
11 $(MAKE) -C lzma-loader clean
12 endef
13
14 define Image/Prepare
15 # Optimized LZMA compression (with dictionary), handled by lzma-loader.
16 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
17
18 # Less optimal LZMA compression (no dictionary), handled by CFE.
19 $(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux > $(KDIR)/vmlinux-nodictionary.lzma
20
21 gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
22 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
23 cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
24 $(STAGING_DIR_HOST)/bin/lzma e -so -d16 $(KDIR)/vmlinux-initramfs > $(KDIR)/vmlinux-initramfs-nodictionary.lzma
25 endif
26 rm -f $(KDIR)/loader.gz
27 $(MAKE) -C lzma-loader \
28 BUILD_DIR="$(KDIR)" \
29 TARGET="$(KDIR)" \
30 clean install
31 echo -ne "\\x00" >> $(KDIR)/loader.gz
32 rm -f $(KDIR)/fs_mark
33 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
34 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
35 endef
36
37 # $(1): filesystem type.
38 # $(2): device model (used for output file).
39 # $(3): pattern (device specific magic).
40 # $(4): version.
41 # $(5): simplified filesystem type (without block size).
42 define Image/Build/CyberTAN
43 $(STAGING_DIR_HOST)/bin/addpattern -4 -p $(3) -v v$(4) -i $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(5).bin $(if $(6),-s $(6))
44 endef
45 define Image/Build/CyberTAN2
46 $(STAGING_DIR_HOST)/bin/addpattern -4 -p $(3) -v v$(4) -i $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(5).noheader.bin -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(5).bin $(if $(6),-s $(6))
47 endef
48 define Image/Build/CyberTANHead
49 $(STAGING_DIR_HOST)/bin/addpattern -5 -p $(3) -v v$(4) -i /dev/null -o $(KDIR)/$(IMG_PREFIX)-$(2)-header.bin $(if $(6),-s $(6))
50 endef
51
52 # $(1): filesystem type.
53 # $(2): device model (used for output file).
54 # $(3): board_id (device specific magic).
55 # $(4): region.
56 # $(5): simplified filesystem type (without block size).
57 define Image/Build/Chk
58 $(STAGING_DIR_HOST)/bin/mkchkimg -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(5).chk -k $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx -b $(3) -r $(4)
59 endef
60
61 define trxalign/jffs2-128k
62 -a 0x20000 -f $(KDIR)/root.$(1)
63 endef
64 define trxalign/jffs2-64k
65 -a 0x10000 -f $(KDIR)/root.$(1)
66 endef
67 define trxalign/squashfs
68 -a 1024 -f $(KDIR)/root.$(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
69 endef
70
71 define Image/Build/trxV2
72 $(call Image/Build/CyberTANHead,$(1),$(2),$(3),$(4),$(5),$(if $(6),$(6)))
73 $(STAGING_DIR_HOST)/bin/trx \
74 -m 33554432 \
75 -2 \
76 -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(5).noheader.bin \
77 -f $(KDIR)/loader.gz \
78 -f $(KDIR)/vmlinux.lzma \
79 $(call trxalign/$(1),$(1),$(KDIR)/$(IMG_PREFIX)-$(2)-header.bin)
80 $(call Image/Build/CyberTAN2,$(1),$(2),$(3),$(4),$(5),$(if $(6),$(6)))
81 endef
82
83 #################################################
84 # Images
85 #################################################
86
87 define Build/trx-with-loader
88 $(STAGING_DIR_HOST)/bin/trx \
89 -m 33554432 \
90 -o $@ \
91 -f $(KDIR)/loader.gz \
92 -f $(word 1,$^) \
93 $(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
94 endef
95
96 define Build/trx-without-loader
97 $(STAGING_DIR_HOST)/bin/trx \
98 -m 33554432 \
99 -o $@ \
100 -f $(word 1,$^) \
101 $(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
102 endef
103
104 define Build/asus-trx
105 $(STAGING_DIR_HOST)/bin/asustrx -p "$(PRODUCTID)" -i $@ -o $@.new
106 mv $@.new $@
107 endef
108
109 define Build/edimax-bin
110 $(STAGING_DIR_HOST)/bin/trx2edips $@ $@.new
111 mv $@.new $@
112 endef
113
114 define Build/huawei-bin
115 dd if=/dev/zero of=$@.new bs=92 count=1
116 echo -ne 'HDR0\x08\x00\x00\x00' >> $@.new
117 cat $@ >> $@.new
118 mv $@.new $@
119 endef
120
121 define Build/linksys-bin
122 $(STAGING_DIR_HOST)/bin/addpattern -4 -p $(DEVICE_ID) -v v$(VERSION) -i $@ -o $@.new
123 mv $@.new $@
124 endef
125
126 define Build/motorola-bin
127 $(STAGING_DIR_HOST)/bin/motorola-bin -$(MOTOROLA_DEVICE) $@ $@.new
128 mv $@.new $@
129 endef
130
131 define Build/prepend-with-elf
132 mv $@ $@.old
133 dd if=$(KDIR)/loader.elf of=$@ bs=131072 conv=sync
134 cat $@.old >> $@
135 endef
136
137 define Build/tailed-bin
138 echo $(BIN_TAIL) >> $@
139 endef
140
141 define Build/usrobotics-bin
142 $(STAGING_DIR_HOST)/bin/trx2usr $@ $@.new
143 mv $@.new $@
144 endef
145
146 #################################################
147 # Devices
148 #################################################
149
150 DEVICE_VARS += PRODUCTID
151 DEVICE_VARS += DEVICE_ID VERSION
152 DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION
153 DEVICE_VARS += MOTOROLA_DEVICE
154 DEVICE_VARS += BIN_TAIL
155
156 define Device/Default
157 KERNEL := kernel-bin
158 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
159 KERNEL_NAME = vmlinux.lzma
160 FILESYSTEMS := $(FS_64K)
161 IMAGES := trx
162 IMAGE/trx := trx-with-loader
163 endef
164
165 define Device/asus
166 IMAGES := trx
167 IMAGE/trx := trx-with-loader | asus-trx
168 endef
169
170 define AsusDevice
171 define Device/asus-$(1)
172 $$(Device/asus)
173 PRODUCTID := $(2)
174 endef
175 TARGET_DEVICES += asus-$(1)
176 endef
177
178 define Device/linksys
179 IMAGES := bin
180 IMAGE/bin := trx-with-loader | linksys-bin
181 endef
182
183 define LinksysDevice
184 define Device/linksys-$(1)
185 $$(Device/linksys)
186 DEVICE_ID := $(2)
187 VERSION := $(3)
188 endef
189 TARGET_DEVICES += linksys-$(1)
190 endef
191
192 define Device/motorola
193 IMAGES := bin
194 IMAGE/bin := trx-with-loader | motorola-bin
195 endef
196
197 define MotorolaDevice
198 define Device/motorola-$(1)
199 $$(Device/motorola)
200 MOTOROLA_DEVICE := $(2)
201 endef
202 TARGET_DEVICES += motorola-$(1)
203 endef
204
205 define Device/netgear
206 IMAGES := chk
207 IMAGE/chk := trx-with-loader | netgear-chk
208 endef
209
210 define NetgearDevice
211 define Device/netgear-$(1)
212 $$(Device/netgear)
213 NETGEAR_BOARD_ID := $(2)
214 NETGEAR_REGION := $(3)
215 endef
216 TARGET_DEVICES += netgear-$(1)
217 endef
218
219 #################################################
220 # Subtarget generic
221 #################################################
222
223 ifeq ($(SUBTARGET),generic)
224 # BCM4705 with tg3
225 $(eval $(call LinksysDevice,wrt300n-v1.1,EWC2,1.51.2))
226 $(eval $(call LinksysDevice,wrt310n-v1,310N,1.0.10))
227 $(eval $(call LinksysDevice,wrt350n-v1,EWCG,1.04.1))
228 $(eval $(call LinksysDevice,wrt610n-v1,610N,1.0.1))
229
230 # BCMA SoC with SSB WiFi
231 $(eval $(call LinksysDevice,wrt610n-v2,610N,2.0.0))
232 $(eval $(call LinksysDevice,e3000-v1,61XN,1.0.3))
233 endif
234
235 #################################################
236 # Subtarget legacy
237 #################################################
238
239 # $(1): filesystem type.
240 define Image/Build/legacy/devices-with-128k-blocks
241 $(call Image/Build/trxV2,$(1),wrt54g3gv2-vf,3G2V,3.00.24,$(patsubst jffs2-%,jffs2,$(1)),6)
242 endef
243
244 # $(1): filesystem type.
245 define Image/Build/legacy/jffs2-128k
246 $(call Image/Build/legacy/devices-with-128k-blocks,$(1))
247 endef
248
249 # $(1): filesystem type.
250 define Image/Build/legacy/squashfs
251 $(call Image/Build/legacy/devices-with-128k-blocks,$(1))
252 endef
253
254 define Device/dlink-dwl-3150
255 IMAGES := bin
256 IMAGE/bin := trx-with-loader | tailed-bin
257 BIN_TAIL := BCM-5352-2050-0000000-01
258 endef
259
260 define Device/edimax-ps1208-mfg
261 IMAGES := bin
262 IMAGE/bin := trx-with-loader | edimax-bin
263 endef
264
265 define Device/huawei-e970
266 KERNEL_NAME = vmlinux.gz
267 IMAGES := bin
268 IMAGE/bin := trx-without-loader | huawei-bin
269 endef
270
271 define Device/linksys-wrt54gs
272 $(Device/linksys)
273 FILESYSTEMS := $(FS_128K)
274 DEVICE_ID := W54S
275 VERSION := 4.80.1
276 endef
277
278 define Device/linksys-wrtsl54gs
279 $(Device/linksys)
280 FILESYSTEMS := $(FS_128K)
281 DEVICE_ID := W54U
282 VERSION := 2.08.1
283 endef
284
285 define Device/netgear-wgt634u
286 FILESYSTEMS := $(FS_128K)
287 IMAGES := bin
288 IMAGE/bin := trx-with-loader | prepend-with-elf
289 endef
290
291 define Device/usrobotics-usr5461
292 IMAGES := bin
293 IMAGE/bin := trx-with-loader | usrobotics-bin
294 endef
295
296 ifeq ($(SUBTARGET),legacy)
297 TARGET_DEVICES += \
298 dlink-dwl-3150 \
299 edimax-ps1208-mfg \
300 huawei-e970 \
301 linksys-wrt54gs \
302 linksys-wrtsl54gs \
303 netgear-wgt634u \
304 usrobotics-usr5461
305
306 $(eval $(call AsusDevice,wl-300g,WL300g ))
307 $(eval $(call AsusDevice,wl-320gp,WL320gP ))
308 $(eval $(call AsusDevice,wl-330ge,WL-330gE ))
309 $(eval $(call AsusDevice,wl-500gp-v1,WL500gp ))
310 $(eval $(call AsusDevice,wl-500gp-v2,WL500gpv2 ))
311 $(eval $(call AsusDevice,wl-500w,WL500W ))
312 $(eval $(call AsusDevice,wl-520gu,WL520gu ))
313 $(eval $(call AsusDevice,wl-550ge,WL550gE ))
314 $(eval $(call AsusDevice,wl-hdd25,WLHDD ))
315 $(eval $(call LinksysDevice,wrt54g3g,W54F,2.20.1))
316 $(eval $(call LinksysDevice,wrt54g3g-em,W3GN,2.20.1))
317 $(eval $(call LinksysDevice,wrt54g,W54G,4.71.1))
318 $(eval $(call LinksysDevice,wrt54gs-v4,W54s,1.09.1))
319 $(eval $(call LinksysDevice,wrt150n,N150,1.51.3))
320 $(eval $(call LinksysDevice,wrt160n-v1,N150,1.50.1))
321 $(eval $(call LinksysDevice,wrt300n-v1,EWCB,1.03.6))
322 $(eval $(call MotorolaDevice,wa840g,2))
323 $(eval $(call MotorolaDevice,we800g,3))
324 $(eval $(call MotorolaDevice,wr850g,1))
325 $(eval $(call NetgearDevice,wgr614-v8,U12H072T00_NETGEAR,2))
326 $(eval $(call NetgearDevice,wndr3300-v1,U12H093T00_NETGEAR,2))
327 $(eval $(call NetgearDevice,wnr834b-v2,U12H081T00_NETGEAR,2))
328 endif
329
330 #################################################
331 # Subtarget mips74k
332 #################################################
333
334 ifeq ($(SUBTARGET),mips74k)
335 $(eval $(call AsusDevice,rt-ac53u,RT-AC53U))
336 # $(eval $(call AsusDevice,rt-ac66u,RT-AC66U))
337 $(eval $(call AsusDevice,rt-n10,RT-N10 ))
338 $(eval $(call AsusDevice,rt-n10p,RT-N10P))
339 $(eval $(call AsusDevice,rt-n10p-v2,RT-N10PV2))
340 $(eval $(call AsusDevice,rt-n10u,RT-N10U))
341 $(eval $(call AsusDevice,rt-n10u-b,RT-N10U))
342 $(eval $(call AsusDevice,rt-n12,RT-N12 ))
343 $(eval $(call AsusDevice,rt-n12-b1,RT-N12B1))
344 $(eval $(call AsusDevice,rt-n12-c1,RT-N12C1))
345 $(eval $(call AsusDevice,rt-n12-d1,RT-N12D1))
346 $(eval $(call AsusDevice,rt-n12hp,RT-N12HP))
347 $(eval $(call AsusDevice,rt-n14uhp,RT-N14UHP))
348 $(eval $(call AsusDevice,rt-n15u,RT-N15U))
349 $(eval $(call AsusDevice,rt-n16,RT-N16))
350 $(eval $(call AsusDevice,rt-n53,RT-N53))
351 $(eval $(call AsusDevice,rt-n66u,RT-N66U))
352 $(eval $(call AsusDevice,rt-n66w,RT-N66U))
353 $(eval $(call LinksysDevice,wrt160n-v3,N150,3.0.3))
354 $(eval $(call LinksysDevice,wrt310n-v2,310N,2.0.1))
355 $(eval $(call LinksysDevice,wrt320n-v1,320N,1.0.5))
356 $(eval $(call LinksysDevice,e900-v1,E900,1.0.4))
357 $(eval $(call LinksysDevice,e1000-v1-v2-v2.1,E100,1.1.3))
358 $(eval $(call LinksysDevice,e1200-v1,E120,1.0.3))
359 $(eval $(call LinksysDevice,e1200-v2,E122,1.0.4))
360 $(eval $(call LinksysDevice,e1500-v1,E150,1.0.5))
361 $(eval $(call LinksysDevice,e1550-v1,1550,1.0.3))
362 $(eval $(call LinksysDevice,e2000-v1,32XN,1.0.4))
363 $(eval $(call LinksysDevice,e2500-v1,E25X,1.0.7))
364 $(eval $(call LinksysDevice,e2500-v2,E25X,2.0.0))
365 $(eval $(call LinksysDevice,e2500-v2.1,25RU,2.1.0))
366 $(eval $(call LinksysDevice,e2500-v3,25V3,3.0.0))
367 $(eval $(call LinksysDevice,e3200-v1,3200,1.0.1))
368 $(eval $(call LinksysDevice,e4200-v1,4200,1.0.5))
369 $(eval $(call NetgearDevice,wgr614-v10_north-america,U12H139T01_NETGEAR,2))
370 $(eval $(call NetgearDevice,wgr614-v10_other-regions,U12H139T01_NETGEAR,1))
371 $(eval $(call NetgearDevice,wn2500rp-v1,U12H197T00_NETGEAR,1))
372 $(eval $(call NetgearDevice,wndr3400-v1,U12H155T00_NETGEAR,2))
373 $(eval $(call NetgearDevice,wndr3400-v2,U12H187T00_NETGEAR,2))
374 $(eval $(call NetgearDevice,wndr3400-v3,U12H208T00_NETGEAR,1))
375 $(eval $(call NetgearDevice,wndr3700-v3,U12H194T00_NETGEAR,2))
376 $(eval $(call NetgearDevice,wndr4000,U12H181T00_NETGEAR,2))
377 $(eval $(call NetgearDevice,wnr1000-v3,U12H139T00_NETGEAR,2))
378 $(eval $(call NetgearDevice,wnr2000v2,U12H114T00_NETGEAR,2))
379 $(eval $(call NetgearDevice,wnr3000rp,U12H163T01_NETGEAR,1))
380 $(eval $(call NetgearDevice,wnr3500l-v1-north-america,U12H136T99_NETGEAR,2))
381 $(eval $(call NetgearDevice,wnr3500l-v1-other-regions,U12H136T99_NETGEAR,1))
382 $(eval $(call NetgearDevice,wnr3500l-v2,U12H172T00_NETGEAR,1))
383 $(eval $(call NetgearDevice,wnr3500-v2,U12H127T00_NETGEAR,2))
384 endif
385
386 #################################################
387 # Shared BuildImage defines
388 #################################################
389
390 define Image/Build/Initramfs
391 $(STAGING_DIR_HOST)/bin/trx \
392 -m 33554432 \
393 -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs.trx \
394 -f $(KDIR)/loader.gz \
395 -f $(KDIR)/vmlinux-initramfs.lzma
396 $(STAGING_DIR_HOST)/bin/trx \
397 -m 33554432 \
398 -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs-noloader-nodictionary.trx \
399 -f $(KDIR)/vmlinux-initramfs-nodictionary.lzma
400 endef
401
402 # $(1): filesystem type.
403 define Image/Build
404 $(STAGING_DIR_HOST)/bin/trx \
405 -m 33554432 \
406 -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
407 -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
408 $(call trxalign/$(1),$(1))
409 $(STAGING_DIR_HOST)/bin/trx \
410 -m 33554432 \
411 -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-noloader-nodictionary.trx \
412 -f $(KDIR)/vmlinux-nodictionary.lzma \
413 $(call trxalign/$(1),$(1))
414 $(STAGING_DIR_HOST)/bin/trx \
415 -m 33554432 \
416 -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
417 -f $(KDIR)/vmlinux.gz \
418 $(call trxalign/$(1),$(1))
419 $(call Image/Build/$(SUBTARGET)/$(1),$(1))
420 # $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
421 # $(call Image/Build/Chk,$(1),wndr3400_vcna,U12H155T01_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
422 # $(call Image/Build/Chk,$(1),wnr3500U,U12H136T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
423 # $(call Image/Build/Chk,$(1),wnr3500v2_VC,U12H127T70_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
424 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
425 $(call Image/Build/Initramfs)
426 endif
427 endef
428
429 $(eval $(call BuildImage))