2 # Copyright (C) 2006-2012 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 Image
/Build
/wgt634u
38 dd if
=$(KDIR
)/loader.elf of
=$(BIN_DIR
)/openwrt-wgt634u-
$(2).bin bs
=131072 conv
=sync
39 cat
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
>> $(BIN_DIR
)/openwrt-wgt634u-
$(2).bin
42 define Image
/Build
/dwl3150
43 cp
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
$(BIN_DIR
)/openwrt-dwl3150-
$(2).bin
44 echo
"BCM-5352-2050-0000000-01" >> $(BIN_DIR
)/openwrt-dwl3150-
$(2).bin
47 # $(1): filesystem type.
48 # $(2): device model (used for output file).
49 # $(3): pattern (device specific magic).
51 # $(5): simplified filesystem type (without block size).
52 define Image
/Build
/CyberTAN
53 $(STAGING_DIR_HOST
)/bin
/addpattern
-4 -p
$(3) -v v
$(4) -i
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
-o
$(BIN_DIR
)/openwrt-
$(2)-$(5).bin
$(if
$(6),-s
$(6))
55 define Image
/Build
/CyberTAN2
56 $(STAGING_DIR_HOST
)/bin
/addpattern
-4 -p
$(3) -v v
$(4) -i
$(BIN_DIR
)/openwrt-
$(2)-$(5).noheader.bin
-o
$(BIN_DIR
)/openwrt-
$(2)-$(5).bin
$(if
$(6),-s
$(6))
58 define Image
/Build
/CyberTANHead
59 $(STAGING_DIR_HOST
)/bin
/addpattern
-5 -p
$(3) -v v
$(4) -i
/dev
/null
-o
$(KDIR
)/openwrt-
$(2)-header.bin
$(if
$(6),-s
$(6))
62 define Image
/Build
/Motorola
63 $(STAGING_DIR_HOST
)/bin
/motorola-bin
-$(3) $(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
$(BIN_DIR
)/openwrt-
$(2)-$(4).bin
66 define Image
/Build
/USR
67 $(STAGING_DIR_HOST
)/bin
/trx2usr
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
$(BIN_DIR
)/openwrt-
$(2)-$(3).bin
70 define Image
/Build
/Edi
71 $(STAGING_DIR_HOST
)/bin
/trx2edips
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
$(BIN_DIR
)/openwrt-
$(2)-$(3).bin
74 define Image
/Build
/Huawei
75 dd if
=/dev
/zero of
=$(BIN_DIR
)/openwrt-
$(2)-$(3)-gz.bin bs
=92 count
=1
76 echo
-ne
'HDR0\x08\x00\x00\x00' >> $(BIN_DIR
)/openwrt-
$(2)-$(3)-gz.bin
77 cat
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-gz.trx
>> $(BIN_DIR
)/openwrt-
$(2)-$(3)-gz.bin
80 # $(1): filesystem type.
81 # $(2): device model (used for output file).
82 # $(3): board_id (device specific magic).
84 # $(5): simplified filesystem type (without block size).
85 define Image
/Build
/Chk
86 $(STAGING_DIR_HOST
)/bin
/mkchkimg
-o
$(BIN_DIR
)/openwrt-
$(2)-$(5).chk
-k
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx
-b
$(3) -r
$(4)
89 define trxalign
/jffs2-128k
90 -a
0x20000 -f
$(KDIR
)/root.
$(1)
92 define trxalign
/jffs2-64k
93 -a
0x10000 -f
$(KDIR
)/root.
$(1)
95 define trxalign
/squashfs
96 -a
1024 -f
$(KDIR
)/root.
$(1) $(if
$(2),-f
$(2)) -a
0x10000 -A
$(KDIR
)/fs_mark
99 define Image
/Build
/trxV2
100 $(call Image
/Build
/CyberTANHead
,$(1),$(2),$(3),$(4),$(5),$(if
$(6),$(6)))
101 $(STAGING_DIR_HOST
)/bin
/trx
-2 -o
$(BIN_DIR
)/openwrt-
$(2)-$(5).noheader.bin \
102 -f
$(KDIR
)/loader.gz
-f
$(KDIR
)/vmlinux.lzma \
103 $(call trxalign
/$(1),$(1),$(KDIR
)/openwrt-
$(2)-header.bin
)
104 $(call Image
/Build
/CyberTAN2
,$(1),$(2),$(3),$(4),$(5),$(if
$(6),$(6)))
107 #################################################
109 #################################################
111 define Build
/trx-with-loader
112 $(STAGING_DIR_HOST
)/bin
/trx \
114 -f
$(KDIR
)/loader.gz \
116 $(call trxalign
/$(lastword
$(subst .
, ,$(word 2,$^
))),$(lastword
$(subst .
, ,$(word 2,$^
))))
119 define Build
/linksys-bin
120 $(STAGING_DIR_HOST
)/bin
/addpattern
-4 -p
$(DEVICE_ID
) -v v
$(VERSION
) -i
$@
-o
$@.new
124 define Build
/netgear-chk
125 $(STAGING_DIR_HOST
)/bin
/mkchkimg \
133 #################################################
135 #################################################
137 DEVICE_VARS
+= DEVICE_ID VERSION
138 DEVICE_VARS
+= BOARD_ID REGION
140 define Device
/Default
142 IMAGE_NAME
= $$(IMAGE_PREFIX
)-$$(1).
$$(2)
143 KERNEL_NAME
= vmlinux.lzma
144 FILESYSTEMS
:= $(FS_64K
)
146 IMAGE
/trx
:= trx-with-loader
149 define Device
/linksys
151 IMAGE
/bin
:= trx-with-loader | linksys-bin
155 define Device
/linksys-
$(1)
160 TARGET_DEVICES
+= linksys-
$(1)
163 define Device
/netgear
165 IMAGE
/chk
:= trx-with-loader | netgear-chk
169 define Device
/netgear-
$(1)
174 TARGET_DEVICES
+= netgear-
$(1)
177 #################################################
179 #################################################
181 ifeq ($(SUBTARGET
),generic
)
183 $(eval
$(call LinksysDevice
,wrt300n-v1.1
,EWC2
,1.51.2))
184 $(eval
$(call LinksysDevice
,wrt310n-v1
,310N
,1.0.10))
185 $(eval
$(call LinksysDevice
,wrt350n-v1
,EWCG
,1.04.1))
186 $(eval
$(call LinksysDevice
,wrt610n-v1
,610N
,1.0.1))
188 # BCMA SoC with SSB WiFi
189 $(eval
$(call LinksysDevice
,wrt610n-v2
,610N
,2.0.0))
190 $(eval
$(call LinksysDevice
,e3000-v1
,61XN
,1.0.3))
193 #################################################
195 #################################################
197 # $(1): filesystem type.
198 define Image
/Build
/legacy
/devices-with-128k-blocks
199 $(call Image
/Build
/CyberTAN
,$(1),wrt54gs
,W54S
,4.80.1,$(patsubst jffs2-
%,jffs2
,$(1)))
200 $(call Image
/Build
/CyberTAN
,$(1),wrtsl54gs
,W54U
,2.08.1,$(patsubst jffs2-
%,jffs2
,$(1)))
201 $(call Image
/Build
/trxV2
,$(1),wrt54g3gv2-vf
,3G2V
,3.00.24,$(patsubst jffs2-
%,jffs2
,$(1)),6)
202 $(call Image
/Build
/wgt634u
,$(1),$(patsubst jffs2-
%,jffs2
,$(1)))
205 # $(1): filesystem type.
206 define Image
/Build
/legacy
/devices-with-64k-blocks
207 $(call Image
/Build
/Chk
,$(1),wgr614_v8
,U12H072T00_NETGEAR
,2,$(patsubst jffs2-
%,jffs2
,$(1)))
208 $(call Image
/Build
/Chk
,$(1),wndr3300_v1
,U12H093T00_NETGEAR
,2,$(patsubst jffs2-
%,jffs2
,$(1)))
209 $(call Image
/Build
/Chk
,$(1),wnr834b_v2
,U12H081T00_NETGEAR
,2,$(patsubst jffs2-
%,jffs2
,$(1)))
210 $(call Image
/Build
/CyberTAN
,$(1),wrt54g3g
,W54F
,2.20.1,$(patsubst jffs2-
%,jffs2
,$(1)))
211 $(call Image
/Build
/CyberTAN
,$(1),wrt54g3g-em
,W3GN
,2.20.1,$(patsubst jffs2-
%,jffs2
,$(1)))
212 $(call Image
/Build
/CyberTAN
,$(1),wrt54g
,W54G
,4.71.1,$(patsubst jffs2-
%,jffs2
,$(1)))
213 $(call Image
/Build
/CyberTAN
,$(1),wrt54gs_v4
,W54s
,1.09.1,$(patsubst jffs2-
%,jffs2
,$(1)))
214 $(call Image
/Build
/CyberTAN
,$(1),wrt150n
,N150
,1.51.3,$(patsubst jffs2-
%,jffs2
,$(1)))
215 $(call Image
/Build
/CyberTAN
,$(1),wrt160n_v1
,N150
,1.50.1,$(patsubst jffs2-
%,jffs2
,$(1)))
216 $(call Image
/Build
/CyberTAN
,$(1),wrt300n_v1
,EWCB
,1.03.6,$(patsubst jffs2-
%,jffs2
,$(1)))
217 $(call Image
/Build
/dwl3150
,$(1),$(patsubst jffs2-
%,jffs2
,$(1)))
218 $(call Image
/Build
/Edi
,$(1),ps1208mfg
,$(patsubst jffs2-
%,jffs2
,$(1)))
219 $(call Image
/Build
/Huawei
,$(1),e970
,$(1))
220 $(call Image
/Build
/Motorola
,$(1),wa840g
,2,$(patsubst jffs2-
%,jffs2
,$(1)))
221 $(call Image
/Build
/Motorola
,$(1),we800g
,3,$(patsubst jffs2-
%,jffs2
,$(1)))
222 $(call Image
/Build
/Motorola
,$(1),wr850g
,1,$(1))
223 $(call Image
/Build
/USR
,$(1),usr5461
,$(1))
226 # $(1): filesystem type.
227 define Image
/Build
/legacy
/jffs2-64k
228 $(call Image
/Build
/legacy
/devices-with-64k-blocks
,$(1))
231 # $(1): filesystem type.
232 define Image
/Build
/legacy
/jffs2-128k
233 $(call Image
/Build
/legacy
/devices-with-128k-blocks
,$(1))
236 # $(1): filesystem type.
237 define Image
/Build
/legacy
/squashfs
238 $(call Image
/Build
/legacy
/devices-with-64k-blocks
,$(1))
239 $(call Image
/Build
/legacy
/devices-with-128k-blocks
,$(1))
242 #################################################
244 #################################################
246 ifeq ($(SUBTARGET
),mips74k
)
247 $(eval
$(call LinksysDevice
,wrt160n-v3
,N150
,3.0.3))
248 $(eval
$(call LinksysDevice
,wrt310n-v2
,310N
,2.0.1))
249 $(eval
$(call LinksysDevice
,wrt320n-v1
,320N
,1.0.5))
250 $(eval
$(call LinksysDevice
,e900-v1
,E900
,1.0.4))
251 $(eval
$(call LinksysDevice
,e1000-v1-v2-v2.1
,E100
,1.1.3))
252 $(eval
$(call LinksysDevice
,e1200-v1
,E120
,1.0.3))
253 $(eval
$(call LinksysDevice
,e1200-v2-new
,E122
,1.0.4))
254 $(eval
$(call LinksysDevice
,e1500-v1
,E150
,1.0.5))
255 $(eval
$(call LinksysDevice
,e1550-v1
,1550,1.0.3))
256 $(eval
$(call LinksysDevice
,e2000-v1
,32XN
,1.0.4))
257 $(eval
$(call LinksysDevice
,e2500-v1
,E25X
,1.0.7))
258 $(eval
$(call LinksysDevice
,e2500-v2
,E25X
,2.0.0))
259 $(eval
$(call LinksysDevice
,e2500-v2.1
,25RU
,2.1.0))
260 $(eval
$(call LinksysDevice
,e2500-v3
,25V3
,3.0.0))
261 $(eval
$(call LinksysDevice
,e3200-v1
,3200,1.0.1))
262 $(eval
$(call LinksysDevice
,e4200-v1
,4200,1.0.5))
263 $(eval
$(call NetgearDevice
,wgr614-v10_north-america
,U12H139T01_NETGEAR
,2))
264 $(eval
$(call NetgearDevice
,wgr614-v10_other-regions
,U12H139T01_NETGEAR
,1))
265 $(eval
$(call NetgearDevice
,wndr3400-v1
,U12H155T00_NETGEAR
,2))
266 $(eval
$(call NetgearDevice
,wndr3400-v2
,U12H187T00_NETGEAR
,2))
267 $(eval
$(call NetgearDevice
,wndr3400-v3
,U12H208T00_NETGEAR
,1))
268 $(eval
$(call NetgearDevice
,wndr3700-v3
,U12H194T00_NETGEAR
,2))
269 $(eval
$(call NetgearDevice
,wndr4000
,U12H181T00_NETGEAR
,2))
270 $(eval
$(call NetgearDevice
,wnr1000-v3
,U12H139T00_NETGEAR
,2))
271 $(eval
$(call NetgearDevice
,wnr2000v2
,U12H114T00_NETGEAR
,2))
272 $(eval
$(call NetgearDevice
,wnr3000rp
,U12H163T01_NETGEAR
,1))
273 $(eval
$(call NetgearDevice
,wnr3500l-v1-north-america
,U12H136T99_NETGEAR
,2))
274 $(eval
$(call NetgearDevice
,wnr3500l-v1-other-regions
,U12H136T99_NETGEAR
,1))
275 $(eval
$(call NetgearDevice
,wnr3500l-v2
,U12H172T00_NETGEAR
,1))
276 $(eval
$(call NetgearDevice
,wnr3500-v2
,U12H127T00_NETGEAR
,2))
279 #################################################
280 # Shared BuildImage defines
281 #################################################
283 define Image
/Build
/Initramfs
284 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(BIN_DIR
)/$(IMG_PREFIX
)-initramfs.trx
-f
$(KDIR
)/loader.gz
-f
$(KDIR
)/vmlinux-initramfs.lzma
285 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(BIN_DIR
)/$(IMG_PREFIX
)-initramfs-noloader-nodictionary.trx
-f
$(KDIR
)/vmlinux-initramfs-nodictionary.lzma
288 # $(1): filesystem type.
290 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1).trx \
291 -f
$(KDIR
)/loader.gz
-f
$(KDIR
)/vmlinux.lzma \
292 $(call trxalign
/$(1),$(1))
293 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-noloader-nodictionary.trx \
294 -f
$(KDIR
)/vmlinux-nodictionary.lzma \
295 $(call trxalign
/$(1),$(1))
296 $(STAGING_DIR_HOST
)/bin
/trx
-o
$(BIN_DIR
)/$(IMG_PREFIX
)-$(1)-gz.trx \
297 -f
$(KDIR
)/vmlinux.gz \
298 $(call trxalign
/$(1),$(1))
299 $(call Image
/Build
/$(SUBTARGET
)/$(1),$(1))
300 # $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
301 # $(call Image/Build/Chk,$(1),wndr3400_vcna,U12H155T01_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
302 # $(call Image/Build/Chk,$(1),wnr3500U,U12H136T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
303 # $(call Image/Build/Chk,$(1),wnr3500v2_VC,U12H127T70_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
304 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),)
305 $(call Image
/Build
/Initramfs
)
309 $(eval
$(call BuildImage
))