2 # Copyright (C) 2006-2016 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
11 $(MAKE) -C lzma-loader clean
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
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
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
26 rm -f $(KDIR)/loader.gz
27 $(MAKE) -C lzma-loader \
31 echo -ne "\\x00" >> $(KDIR)/loader.gz
33 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
34 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
37 define trxalign/jffs2-128k
38 -a 0x20000 -f $(KDIR)/root.$(1)
40 define trxalign/jffs2-64k
41 -a 0x10000 -f $(KDIR)/root.$(1)
43 define trxalign/squashfs
44 -a 1024 -f $(KDIR)/root.$(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
47 #################################################
49 #################################################
51 define Build/trx-with-loader
52 $(STAGING_DIR_HOST)/bin/trx \
54 -f $(KDIR)/loader.gz \
56 $(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
59 define Build/trx-v2-with-loader
60 $(STAGING_DIR_HOST)/bin/trx \
64 -f $(KDIR)/loader.gz \
65 -f $(KDIR)/vmlinux.lzma \
66 $(call trxalign/$(FILESYSTEM),$(FILESYSTEM),$@)
70 define Build/trx-without-loader
71 $(STAGING_DIR_HOST)/bin/trx \
75 $(call trxalign/$(FILESYSTEM),$(FILESYSTEM))
79 $(STAGING_DIR_HOST)/bin/asustrx -p "$(PRODUCTID)" -i $@ -o $@.new
83 define Build/edimax-bin
84 $(STAGING_DIR_HOST)/bin/trx2edips $@ $@.new
88 define Build/huawei-bin
89 dd if=/dev/zero of=$@.new bs=92 count=1
90 echo -ne 'HDR0\x08\x00\x00\x00' >> $@.new
95 define Build/linksys-bin
96 $(STAGING_DIR_HOST)/bin/addpattern -4 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i $@ -o $@.new
100 define Build/linksys-pattern-partition
101 $(STAGING_DIR_HOST)/bin/addpattern -5 -p $(DEVICE_ID) -v v$(VERSION) $(if $(SERIAL),-s $(SERIAL)) -i /dev/null -o $@
104 define Build/motorola-bin
105 $(STAGING_DIR_HOST)/bin/motorola-bin -$(MOTOROLA_DEVICE) $@ $@.new
109 define Build/netgear-chk
110 $(STAGING_DIR_HOST)/bin/mkchkimg \
118 define Build/prepend-with-elf
120 dd if=$(KDIR)/loader.elf of=$@ bs=131072 conv=sync
124 define Build/tailed-bin
125 echo $(BIN_TAIL) >> $@
128 define Build/usrobotics-bin
129 $(STAGING_DIR_HOST)/bin/trx2usr $@ $@.new
133 #################################################
135 #################################################
137 DEVICE_VARS += PRODUCTID
138 DEVICE_VARS += DEVICE_ID VERSION SERIAL
139 DEVICE_VARS += BOARD_ID REGION
140 DEVICE_VARS += MOTOROLA_DEVICE
141 DEVICE_VARS += BIN_TAIL
143 define Device/Default
145 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
146 KERNEL_NAME = vmlinux.lzma
147 FILESYSTEMS := $(FS_64K)
149 IMAGE/trx := trx-with-loader
152 define Device/standard
155 define Device/standard-noloader-gz
156 KERNEL_NAME = vmlinux.gz
157 IMAGE/trx := trx-without-loader
160 define Device/standard-noloader-nodictionarylzma
161 KERNEL_NAME = vmlinux-nodictionary.lzma
162 IMAGE/trx := trx-without-loader
167 IMAGE/trx := trx-with-loader | asus-trx
171 define Device/asus-$(1)
175 TARGET_DEVICES += asus-$(1)
178 define Device/linksys
180 IMAGE/bin := trx-with-loader | linksys-bin
184 define Device/linksys-$(1)
189 TARGET_DEVICES += linksys-$(1)
192 define Device/motorola
194 IMAGE/bin := trx-with-loader | motorola-bin
197 define MotorolaDevice
198 define Device/motorola-$(1)
200 MOTOROLA_DEVICE := $(2)
202 TARGET_DEVICES += motorola-$(1)
205 define Device/netgear
207 IMAGE/chk := trx-with-loader | netgear-chk
211 define Device/netgear-$(1)
216 TARGET_DEVICES += netgear-$(1)
219 #################################################
221 #################################################
223 ifeq ($(SUBTARGET),generic)
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))
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))
234 TARGET_DEVICES += standard
237 #################################################
239 #################################################
241 define Device/dlink-dwl-3150
243 IMAGE/bin := trx-with-loader | tailed-bin
244 BIN_TAIL := BCM-5352-2050-0000000-01
247 define Device/edimax-ps1208-mfg
249 IMAGE/bin := trx-with-loader | edimax-bin
252 define Device/huawei-e970
253 KERNEL_NAME = vmlinux.gz
255 IMAGE/bin := trx-without-loader | huawei-bin
258 define Device/linksys-wrt54g3gv2-vf
259 FILESYSTEMS := $(FS_128K)
260 IMAGES := noheader.bin bin
261 IMAGE/noheader.bin := linksys-pattern-partition | trx-v2-with-loader
262 IMAGE/bin := linksys-pattern-partition | trx-v2-with-loader | linksys-bin
268 define Device/linksys-wrt54gs
270 FILESYSTEMS := $(FS_128K)
275 define Device/linksys-wrtsl54gs
277 FILESYSTEMS := $(FS_128K)
282 define Device/netgear-wgt634u
283 FILESYSTEMS := $(FS_128K)
285 IMAGE/bin := trx-with-loader | prepend-with-elf
288 define Device/usrobotics-usr5461
290 IMAGE/bin := trx-with-loader | usrobotics-bin
293 ifeq ($(SUBTARGET),legacy)
298 linksys-wrt54g3gv2-vf \
304 $(eval $(call AsusDevice,wl-300g,WL300g ))
305 $(eval $(call AsusDevice,wl-320gp,WL320gP ))
306 $(eval $(call AsusDevice,wl-330ge,WL-330gE ))
307 $(eval $(call AsusDevice,wl-500gp-v1,WL500gp ))
308 $(eval $(call AsusDevice,wl-500gp-v2,WL500gpv2 ))
309 $(eval $(call AsusDevice,wl-500w,WL500W ))
310 $(eval $(call AsusDevice,wl-520gu,WL520gu ))
311 $(eval $(call AsusDevice,wl-550ge,WL550gE ))
312 $(eval $(call AsusDevice,wl-hdd25,WLHDD ))
313 $(eval $(call LinksysDevice,wrt54g3g,W54F,2.20.1))
314 $(eval $(call LinksysDevice,wrt54g3g-em,W3GN,2.20.1))
315 $(eval $(call LinksysDevice,wrt54g,W54G,4.71.1))
316 $(eval $(call LinksysDevice,wrt54gs-v4,W54s,1.09.1))
317 $(eval $(call LinksysDevice,wrt150n,N150,1.51.3))
318 $(eval $(call LinksysDevice,wrt160n-v1,N150,1.50.1))
319 $(eval $(call LinksysDevice,wrt300n-v1,EWCB,1.03.6))
320 $(eval $(call MotorolaDevice,wa840g,2))
321 $(eval $(call MotorolaDevice,we800g,3))
322 $(eval $(call MotorolaDevice,wr850g,1))
323 $(eval $(call NetgearDevice,wgr614-v8,U12H072T00_NETGEAR,2))
324 $(eval $(call NetgearDevice,wndr3300-v1,U12H093T00_NETGEAR,2))
325 $(eval $(call NetgearDevice,wnr834b-v2,U12H081T00_NETGEAR,2))
327 TARGET_DEVICES += standard standard-noloader-gz
330 #################################################
332 #################################################
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,wndr3400-v1,U12H155T00_NETGEAR,2))
372 $(eval $(call NetgearDevice,wndr3400-v2,U12H187T00_NETGEAR,2))
373 $(eval $(call NetgearDevice,wndr3400-v3,U12H208T00_NETGEAR,1))
374 $(eval $(call NetgearDevice,wndr3700-v3,U12H194T00_NETGEAR,2))
375 # $(eval $(call NetgearDevice,wndr3400-vcna,U12H155T01_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,wnr3500u,U12H136T00_NETGEAR,2))
384 $(eval $(call NetgearDevice,wnr3500-v2,U12H127T00_NETGEAR,2))
385 # $(eval $(call NetgearDevice,wnr3500-v2-vc,U12H127T70_NETGEAR,2))
387 TARGET_DEVICES += standard standard-noloader-nodictionarylzma
390 #################################################
391 # Shared BuildImage defines
392 #################################################
394 define Image/Build/Initramfs
395 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs.trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux-initramfs.lzma
396 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs-noloader-nodictionary.trx -f $(KDIR)/vmlinux-initramfs-nodictionary.lzma
399 # $(1): filesystem type.
401 # TODO: Move it to Device/*
402 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
403 $(call Image/Build/Initramfs)
407 $(eval $(call BuildImage))