9bdc838ca87308856145e82d049d94b6db6bc61f
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / image / Makefile
1 #
2 # Copyright (C) 2006-2012 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 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
16 gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
17 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
18 cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
19 endif
20 rm -f $(KDIR)/loader.gz
21 $(MAKE) -C lzma-loader \
22 BUILD_DIR="$(KDIR)" \
23 TARGET="$(KDIR)" \
24 clean install
25 echo -ne "\\x00" >> $(KDIR)/loader.gz
26 rm -f $(KDIR)/fs_mark
27 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
28 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
29 endef
30
31 define Image/Build/wgt634u
32 dd if=$(KDIR)/loader.elf of=$(BIN_DIR)/openwrt-wgt634u-$(2).bin bs=131072 conv=sync
33 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx >> $(BIN_DIR)/openwrt-wgt634u-$(2).bin
34 endef
35
36 define Image/Build/dwl3150
37 cp $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx $(BIN_DIR)/openwrt-dwl3150-$(2).bin
38 echo "BCM-5352-2050-0000000-01" >> $(BIN_DIR)/openwrt-dwl3150-$(2).bin
39 endef
40
41 # $(1): filesystem type.
42 # $(2): device model (used for output file).
43 # $(3): pattern (device specific magic).
44 # $(4): version.
45 # $(5): simplified filesystem type (without block size).
46 define Image/Build/CyberTAN
47 $(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))
48 endef
49 define Image/Build/CyberTAN2
50 $(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))
51 endef
52 define Image/Build/CyberTANHead
53 $(STAGING_DIR_HOST)/bin/addpattern -5 -p $(3) -v v$(4) -i /dev/null -o $(KDIR)/openwrt-$(2)-header.bin $(if $(6),-s $(6))
54 endef
55
56 define Image/Build/Motorola
57 $(STAGING_DIR_HOST)/bin/motorola-bin -$(3) $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(4).bin
58 endef
59
60 define Image/Build/USR
61 $(STAGING_DIR_HOST)/bin/trx2usr $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(3).bin
62 endef
63
64 define Image/Build/Edi
65 $(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(3).bin
66 endef
67
68 define Image/Build/Huawei
69 dd if=/dev/zero of=$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin bs=92 count=1
70 echo -ne 'HDR0\x08\x00\x00\x00' >> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
71 cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
72 endef
73
74 # $(1): filesystem type.
75 # $(2): device model (used for output file).
76 # $(3): board_id (device specific magic).
77 # $(4): region.
78 # $(5): simplified filesystem type (without block size).
79 define Image/Build/Chk
80 $(STAGING_DIR_HOST)/bin/mkchkimg -o $(BIN_DIR)/openwrt-$(2)-$(5).chk -k $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx -b $(3) -r $(4)
81 endef
82
83 define trxalign/jffs2-128k
84 -a 0x20000 -f $(KDIR)/root.$(1)
85 endef
86 define trxalign/jffs2-64k
87 -a 0x10000 -f $(KDIR)/root.$(1)
88 endef
89 define trxalign/squashfs
90 -a 1024 -f $(KDIR)/root.$(1) $(if $(2),-f $(2)) -a 0x10000 -A $(KDIR)/fs_mark
91 endef
92
93 define Image/Build/trxV2
94 $(call Image/Build/CyberTANHead,$(1),$(2),$(3),$(4),$(5),$(if $(6),$(6)))
95 $(STAGING_DIR_HOST)/bin/trx -2 -o $(BIN_DIR)/openwrt-$(2)-$(5).noheader.bin \
96 -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
97 $(call trxalign/$(1),$(1),$(KDIR)/openwrt-$(2)-header.bin)
98 $(call Image/Build/CyberTAN2,$(1),$(2),$(3),$(4),$(5),$(if $(6),$(6)))
99 endef
100
101 #################################################
102 # Subtarget generic
103 #################################################
104
105 # $(1): filesystem type.
106 define Image/Build/generic/jffs2-64k
107 # BCM4705 with tg3
108 $(call Image/Build/CyberTAN,$(1),wrt300n_v11,EWC2,1.51.2,$(patsubst jffs2-%,jffs2,$(1)))
109 $(call Image/Build/CyberTAN,$(1),wrt310n_v1,310N,1.0.10,$(patsubst jffs2-%,jffs2,$(1)))
110 $(call Image/Build/CyberTAN,$(1),wrt350n_v1,EWCG,1.04.1,$(patsubst jffs2-%,jffs2,$(1)))
111 $(call Image/Build/CyberTAN,$(1),wrt610n_v1,610N,1.0.1,$(patsubst jffs2-%,jffs2,$(1)))
112
113 # BCMA SoC with SSB WiFi
114 $(call Image/Build/CyberTAN,$(1),wrt610n_v2,610N,2.0.0,$(patsubst jffs2-%,jffs2,$(1)))
115 $(call Image/Build/CyberTAN,$(1),e3000_v1,61XN,1.0.3,$(patsubst jffs2-%,jffs2,$(1)))
116 endef
117
118 # $(1): filesystem type.
119 define Image/Build/generic/squashfs
120 $(call Image/Build/generic/jffs2-64k,$(1))
121 $(call Image/Build/generic/jffs2-128k,$(1))
122 endef
123
124 #################################################
125 # Subtarget legacy
126 #################################################
127
128 # $(1): filesystem type.
129 define Image/Build/legacy/devices-with-128k-blocks
130 $(call Image/Build/CyberTAN,$(1),wrt54gs,W54S,4.80.1,$(patsubst jffs2-%,jffs2,$(1)))
131 $(call Image/Build/CyberTAN,$(1),wrtsl54gs,W54U,2.08.1,$(patsubst jffs2-%,jffs2,$(1)))
132 $(call Image/Build/trxV2,$(1),wrt54g3gv2-vf,3G2V,3.00.24,$(patsubst jffs2-%,jffs2,$(1)),6)
133 $(call Image/Build/wgt634u,$(1),$(patsubst jffs2-%,jffs2,$(1)))
134 endef
135
136 # $(1): filesystem type.
137 define Image/Build/legacy/devices-with-64k-blocks
138 $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
139 $(call Image/Build/Chk,$(1),wndr3300_v1,U12H093T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
140 $(call Image/Build/Chk,$(1),wnr834b_v2,U12H081T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
141 $(call Image/Build/CyberTAN,$(1),wrt54g3g,W54F,2.20.1,$(patsubst jffs2-%,jffs2,$(1)))
142 $(call Image/Build/CyberTAN,$(1),wrt54g3g-em,W3GN,2.20.1,$(patsubst jffs2-%,jffs2,$(1)))
143 $(call Image/Build/CyberTAN,$(1),wrt54g,W54G,4.71.1,$(patsubst jffs2-%,jffs2,$(1)))
144 $(call Image/Build/CyberTAN,$(1),wrt54gs_v4,W54s,1.09.1,$(patsubst jffs2-%,jffs2,$(1)))
145 $(call Image/Build/CyberTAN,$(1),wrt150n,N150,1.51.3,$(patsubst jffs2-%,jffs2,$(1)))
146 $(call Image/Build/CyberTAN,$(1),wrt160n_v1,N150,1.50.1,$(patsubst jffs2-%,jffs2,$(1)))
147 $(call Image/Build/CyberTAN,$(1),wrt300n_v1,EWCB,1.03.6,$(patsubst jffs2-%,jffs2,$(1)))
148 $(call Image/Build/dwl3150,$(1),$(patsubst jffs2-%,jffs2,$(1)))
149 $(call Image/Build/Edi,$(1),ps1208mfg,$(patsubst jffs2-%,jffs2,$(1)))
150 $(call Image/Build/Huawei,$(1),e970,$(1))
151 $(call Image/Build/Motorola,$(1),wa840g,2,$(patsubst jffs2-%,jffs2,$(1)))
152 $(call Image/Build/Motorola,$(1),we800g,3,$(patsubst jffs2-%,jffs2,$(1)))
153 $(call Image/Build/Motorola,$(1),wr850g,1,$(1))
154 $(call Image/Build/USR,$(1),usr5461,$(1))
155 endef
156
157 # $(1): filesystem type.
158 define Image/Build/legacy/jffs2-64k
159 $(call Image/Build/legacy/devices-with-64k-blocks,$(1))
160 endef
161
162 # $(1): filesystem type.
163 define Image/Build/legacy/jffs2-128k
164 $(call Image/Build/legacy/devices-with-128k-blocks,$(1))
165 endef
166
167 # $(1): filesystem type.
168 define Image/Build/legacy/squashfs
169 $(call Image/Build/legacy/devices-with-64k-blocks,$(1))
170 $(call Image/Build/legacy/devices-with-128k-blocks,$(1))
171 endef
172
173 #################################################
174 # Subtarget mips74k
175 #################################################
176
177 define Image/Build/mips74k/devices-with-64k-blocks
178 $(call Image/Build/Chk,$(1),wndr3400_v1,U12H155T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
179 $(call Image/Build/Chk,$(1),wndr3400_v2,U12H187T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
180 $(call Image/Build/Chk,$(1),wndr3700_v3,U12H194T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
181 $(call Image/Build/Chk,$(1),wndr4000,U12H181T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
182 $(call Image/Build/Chk,$(1),wnr2000v2,U12H114T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
183 $(call Image/Build/Chk,$(1),wnr3500L,U12H136T99_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
184 $(call Image/Build/Chk,$(1),wnr3500v2,U12H127T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
185 $(call Image/Build/CyberTAN,$(1),wrt160n_v3,N150,3.0.3,$(patsubst jffs2-%,jffs2,$(1)))
186 $(call Image/Build/CyberTAN,$(1),wrt310n_v2,310N,2.0.1,$(patsubst jffs2-%,jffs2,$(1)))
187 $(call Image/Build/CyberTAN,$(1),wrt320n_v1,320N,1.0.5,$(patsubst jffs2-%,jffs2,$(1)))
188 $(call Image/Build/CyberTAN,$(1),e900_v1,E900,1.0.4,$(patsubst jffs2-%,jffs2,$(1)))
189 $(call Image/Build/CyberTAN,$(1),e1000_v1_v2,E100,1.1.2,$(patsubst jffs2-%,jffs2,$(1)))
190 $(call Image/Build/CyberTAN,$(1),e1200_v1,E120,1.0.3,$(patsubst jffs2-%,jffs2,$(1)))
191 $(call Image/Build/CyberTAN,$(1),e1200_v2,E122,1.0.4,$(patsubst jffs2-%,jffs2,$(1)))
192 $(call Image/Build/CyberTAN,$(1),e1500_v1,E150,1.0.5,$(patsubst jffs2-%,jffs2,$(1)))
193 $(call Image/Build/CyberTAN,$(1),e1550_v1,1550,1.0.3,$(patsubst jffs2-%,jffs2,$(1)))
194 $(call Image/Build/CyberTAN,$(1),e2000_v1,32XN,1.0.4,$(patsubst jffs2-%,jffs2,$(1)))
195 $(call Image/Build/CyberTAN,$(1),e2500_v1_v2,E25X,1.0.7,$(patsubst jffs2-%,jffs2,$(1)))
196 $(call Image/Build/CyberTAN,$(1),e3200_v1,3200,1.0.1,$(patsubst jffs2-%,jffs2,$(1)))
197 $(call Image/Build/CyberTAN,$(1),e4200_v1,4200,1.0.5,$(patsubst jffs2-%,jffs2,$(1)))
198 endef
199
200 # $(1): filesystem type.
201 define Image/Build/mips74k/jffs2-64k
202 $(call Image/Build/mips74k/devices-with-64k-blocks,$(1))
203 endef
204
205 # $(1): filesystem type.
206 define Image/Build/mips74k/jffs2-128k
207 $(call Image/Build/mips74k/devices-with-128k-blocks,$(1))
208 endef
209
210 # $(1): filesystem type.
211 define Image/Build/mips74k/squashfs
212 $(call Image/Build/mips74k/devices-with-64k-blocks,$(1))
213 $(call Image/Build/mips74k/devices-with-128k-blocks,$(1))
214 endef
215
216 #################################################
217 # Shared BuildImage defines
218 #################################################
219
220 define Image/Build/Initramfs
221 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-initramfs.trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux-initramfs.lzma
222 endef
223
224 # $(1): filesystem type.
225 define Image/Build
226 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
227 -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
228 $(call trxalign/$(1),$(1))
229 $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
230 -f $(KDIR)/vmlinux.gz \
231 $(call trxalign/$(1),$(1))
232 $(call Image/Build/$(SUBTARGET)/$(1),$(1))
233 # $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
234 # $(call Image/Build/Chk,$(1),wndr3400_vcna,U12H155T01_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
235 # $(call Image/Build/Chk,$(1),wnr3500U,U12H136T00_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
236 # $(call Image/Build/Chk,$(1),wnr3500v2_VC,U12H127T70_NETGEAR,2,$(patsubst jffs2-%,jffs2,$(1)))
237 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
238 $(call Image/Build/Initramfs)
239 endif
240 endef
241
242 $(eval $(call BuildImage))