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