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 # $(1): filesystem type.
38 # $(2): device model (used for output file).
39 # $(3): pattern (device specific magic).
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))
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))
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))
52 # $(1): filesystem type.
53 # $(2): device model (used for output file).
54 # $(3): board_id (device specific magic).
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)
61 define trxalign
/jffs2-128k
62 -a
0x20000 -f
$(KDIR
)/root.
$(1)
64 define trxalign
/jffs2-64k
65 -a
0x10000 -f
$(KDIR
)/root.
$(1)
67 define trxalign
/squashfs
68 -a
1024 -f
$(KDIR
)/root.
$(1) $(if
$(2),-f
$(2)) -a
0x10000 -A
$(KDIR
)/fs_mark
71 define Image
/Build
/trxV2
72 $(call Image
/Build
/CyberTANHead
,$(1),$(2),$(3),$(4),$(5),$(if
$(6),$(6)))
73 $(STAGING_DIR_HOST
)/bin
/trx \
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)))
83 #################################################
85 #################################################
87 define Build
/trx-with-loader
88 $(STAGING_DIR_HOST
)/bin
/trx \
91 -f
$(KDIR
)/loader.gz \
93 $(call trxalign
/$(FILESYSTEM
),$(FILESYSTEM
))
96 define Build
/trx-without-loader
97 $(STAGING_DIR_HOST
)/bin
/trx \
101 $(call trxalign
/$(FILESYSTEM
),$(FILESYSTEM
))
104 define Build
/asus-trx
105 $(STAGING_DIR_HOST
)/bin
/asustrx
-p
"$(PRODUCTID)" -i
$@
-o
$@.new
109 define Build
/edimax-bin
110 $(STAGING_DIR_HOST
)/bin
/trx2edips
$@
$@.new
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
121 define Build
/linksys-bin
122 $(STAGING_DIR_HOST
)/bin
/addpattern
-4 -p
$(DEVICE_ID
) -v v
$(VERSION
) -i
$@
-o
$@.new
126 define Build
/motorola-bin
127 $(STAGING_DIR_HOST
)/bin
/motorola-bin
-$(MOTOROLA_DEVICE
) $@
$@.new
131 define Build
/prepend-with-elf
133 dd if
=$(KDIR
)/loader.elf of
=$@ bs
=131072 conv
=sync
137 define Build
/tailed-bin
138 echo
$(BIN_TAIL
) >> $@
141 define Build
/usrobotics-bin
142 $(STAGING_DIR_HOST
)/bin
/trx2usr
$@
$@.new
146 #################################################
148 #################################################
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
156 define Device
/Default
158 IMAGE_NAME
= $$(IMAGE_PREFIX
)-$$(1).
$$(2)
159 KERNEL_NAME
= vmlinux.lzma
160 FILESYSTEMS
:= $(FS_64K
)
162 IMAGE
/trx
:= trx-with-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)
213 NETGEAR_BOARD_ID
:= $(2)
214 NETGEAR_REGION
:= $(3)
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))
235 #################################################
237 #################################################
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)
244 # $(1): filesystem type.
245 define Image
/Build
/legacy
/jffs2-128k
246 $(call Image
/Build
/legacy
/devices-with-128k-blocks
,$(1))
249 # $(1): filesystem type.
250 define Image
/Build
/legacy
/squashfs
251 $(call Image
/Build
/legacy
/devices-with-128k-blocks
,$(1))
254 define Device
/dlink-dwl-3150
256 IMAGE
/bin
:= trx-with-loader | tailed-bin
257 BIN_TAIL
:= BCM-5352-2050-0000000-01
260 define Device
/edimax-ps1208-mfg
262 IMAGE
/bin
:= trx-with-loader | edimax-bin
265 define Device
/huawei-e970
266 KERNEL_NAME
= vmlinux.gz
268 IMAGE
/bin
:= trx-without-loader | huawei-bin
271 define Device
/linksys-wrt54gs
273 FILESYSTEMS
:= $(FS_128K
)
278 define Device
/linksys-wrtsl54gs
280 FILESYSTEMS
:= $(FS_128K
)
285 define Device
/netgear-wgt634u
286 FILESYSTEMS
:= $(FS_128K
)
288 IMAGE
/bin
:= trx-with-loader | prepend-with-elf
291 define Device
/usrobotics-usr5461
293 IMAGE
/bin
:= trx-with-loader | usrobotics-bin
296 ifeq ($(SUBTARGET
),legacy
)
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))
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
,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))
386 #################################################
387 # Shared BuildImage defines
388 #################################################
390 define Image
/Build
/Initramfs
391 $(STAGING_DIR_HOST
)/bin
/trx \
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 \
398 -o
$(BIN_DIR
)/$(IMG_PREFIX
)-initramfs-noloader-nodictionary.trx \
399 -f
$(KDIR
)/vmlinux-initramfs-nodictionary.lzma
402 # $(1): filesystem type.
404 $(STAGING_DIR_HOST
)/bin
/trx \
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 \
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 \
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
)
429 $(eval
$(call BuildImage
))