brcm63xx: Add userspace support for Sagemcom F@ST2704V2 ADSL router
[openwrt/openwrt.git] / target / linux / brcm63xx / image / Makefile
1 #
2 # Copyright (C) 2006-2011 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 LOADADDR = 0x80010000 # RAM start + 16M
11 KERNEL_ENTRY = $(LOADADDR) # Newer kernels add a jmp to the kernel_entry at the start of the binary
12 RAMSIZE = 0x01000000 # 64MB
13
14 LOADER_MAKEOPTS= \
15 KDIR=$(KDIR) \
16 LOADADDR=$(LOADADDR) \
17 KERNEL_ENTRY=$(KERNEL_ENTRY) \
18 RAMSIZE=$(RAMSIZE)
19
20 define trxalign/jffs2-128k
21 -a 0x20000
22 endef
23 define trxalign/jffs2-64k
24 -a 0x10000
25 endef
26 define trxalign/squashfs
27 -a 1024
28 endef
29
30 define Image/LimitName16
31 $(shell expr substr "$(1)" 1 16)
32 endef
33
34 define Image/Build/CFE
35 # Generate the tagged image
36 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
37 --output $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin \
38 --boardid $(2) --chipid $(3) --entry $(KERNEL_ENTRY) \
39 --load-addr $(LOADADDR) --rsa-signature "$(5)" \
40 --info1 "-$(call Image/LimitName16,$(4))" --info2 $(1) \
41 $(6) $(7) $(8) $(9)
42 endef
43
44 define Image/Build/CFEFIXUP
45 # Generate the tagged image
46 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
47 --output $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \
48 --boardid $(2) --chipid $(4) --entry $(KERNEL_ENTRY) \
49 --load-addr $(LOADADDR) --rsa-signature "$(6)" \
50 --info1 "+$(call Image/LimitName16,$(3))" --info2 $(1) \
51 $(7) $(8) $(9) $(10)
52 endef
53
54 define Image/Build/CFEHW553
55 # Generate the tagged image
56 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
57 --output $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \
58 --boardid $(2) --chipid $(3) --entry $(LOADADDR) \
59 --load-addr $(LOADADDR) --tag-version 7 \
60 --block-size 0x20000 --image-offset $(4)
61 endef
62
63 define Image/Build/CFEHW556
64 # Generate the tagged image
65 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
66 --output $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin \
67 --boardid $(2) --chipid $(3) --entry $(LOADADDR) \
68 --load-addr $(LOADADDR) --tag-version 8 --rsa-signature "$(5)" \
69 --image-offset $(4) --info1 "$(6)" --block-size 0x20000
70 endef
71
72 define Image/Build/CFEAGPF
73 # Generate the tagged image
74 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
75 --output $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \
76 --boardid $(2) --chipid $(3) --entry $(LOADADDR) \
77 --load-addr $(LOADADDR) --tag-version 8 \
78 --signature2 IMAGE --block-size 0x20000 \
79 --image-offset $(4) --info1 "-$(call Image/LimitName16,$(5))" --info2 $(1)
80 endef
81
82 define Image/Build/RG100A
83 # Generate the tagged image
84 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
85 --output $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin \
86 --boardid $(2) --chipid $(3) --entry $(LOADADDR) \
87 --load-addr $(LOADADDR) --block-size 0x20000 \
88 --image-offset $(4) --info1 "-$(call Image/LimitName16,$(5))" --info2 $(1)
89 endef
90
91 define Image/Build/RedBoot
92 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(1)-vmlinux.elf
93 gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
94 $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
95 dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(1)-vmlinux.lzma bs=65536 conv=sync
96 dd if=$(KDIR)/vmlinux.bin.gz of=$(BIN_DIR)/openwrt-$(1)-vmlinux.gz bs=65536 conv=sync
97 endef
98
99 define Image/Build/SPW303V
100 # Generate the tagged image
101 $(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux.lzma.cfe -f $(KDIR)/root.$(1) \
102 --output $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin.tmp \
103 --boardid $(2) --chipid $(3) --entry $(KERNEL_ENTRY) \
104 --load-addr $(LOADADDR) --rsa-signature "$(5)" \
105 --pad 4 $(6) $(7) $(8) $(9)
106 # Fix up header
107 $(STAGING_DIR_HOST)/bin/spw303v -i $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin.tmp \
108 -o $(BIN_DIR)/openwrt-$(4)-$(1)-cfe-sysupgrade.bin
109 $(STAGING_DIR_HOST)/bin/xorimage -i $(BIN_DIR)/openwrt-$(4)-$(1)-cfe-sysupgrade.bin \
110 -o $(BIN_DIR)/openwrt-$(4)-$(1)-cfe-factory.bin
111 rm -f $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin.tmp
112 endef
113
114 define Image/Build/CFEOLD
115 $(TOPDIR)/scripts/brcmImage.pl -t -p \
116 -b $(2) -c $(3) \
117 -k $(KDIR)/vmlinux.lzma.cfe \
118 -r $(KDIR)/root.$(1) \
119 -o $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin
120 endef
121
122 define Image/Build/HCS
123 $(STAGING_DIR_HOST)/bin/hcsmakeimage --magic_byte=$(3) \
124 --rev_maj=$(4) --rev_min=$(5) --input_file=$(6) \
125 --output_file=$(BIN_DIR)/openwrt-$(2)-$(1).bin
126 endef
127
128 define Build/Clean
129 $(MAKE) -C lzma-loader clean
130 endef
131
132 define Image/Prepare
133 # Standard LZMA kernel
134 cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
135
136 # CFE is a LZMA nazi! It took me hours to find out the parameters!
137 # Also I think lzma has a bug cause it generates different output depending on
138 # if you use stdin / stdout or not. Use files instead of stdio here, cause
139 # otherwise CFE will complain and not boot the image.
140 $(STAGING_DIR_HOST)/bin/lzma e -d22 -fb64 -a1 $(KDIR)/vmlinux $(KDIR)/vmlinux.lzma.tmp
141
142 # Strip out the length, CFE doesn't like this
143 dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe bs=5 count=1
144 dd if=$(KDIR)/vmlinux.lzma.tmp of=$(KDIR)/vmlinux.lzma.cfe ibs=13 obs=5 skip=1 seek=1 conv=notrunc
145 rm -f $(KDIR)/vmlinux.lzma.tmp
146
147 # Build the LZMA loader
148 rm -f $(KDIR)/loader.gz
149 $(MAKE) -C lzma-loader \
150 BUILD_DIR="$(KDIR)" \
151 TARGET="$(KDIR)" \
152 clean install
153
154 echo -ne "\\x00" >> $(KDIR)/loader.gz
155 rm -f $(KDIR)/fs_mark
156 touch $(KDIR)/fs_mark
157 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
158 endef
159
160 define Image/Build/Initramfs
161 # Netgear CVG834G
162 $(call Image/Build/HCS,initramfs,cvg834g,a020,0001,0022,$(KDIR)/vmlinux-initramfs)
163 endef
164
165 define Image/Build
166 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
167 # Various routers
168 $(call Image/Build/CFE,$(1),96328avng,6328,96328avng-4M-flash-generic,,--pad 2)
169 $(call Image/Build/CFE,$(1),96328avng,6328,96328avng-8M-flash-generic,,--pad 4)
170 $(call Image/Build/CFE,$(1),96328avng,6328,96328avng-16M-flash-generic,,--pad 8)
171 $(call Image/Build/CFE,$(1),96328A-1241N,6328,96328A-1241N-generic,,--pad 8)
172 $(call Image/Build/CFE,$(1),96328A-1441N1,6328,96328A-1441N1-generic,,--pad 8)
173 $(call Image/Build/CFE,$(1),963281TAN,6328,963281TAN-4M-flash-generic,,--pad 2)
174 $(call Image/Build/CFE,$(1),963281TAN,6328,963281TAN-8M-flash-generic,,--pad 4)
175 $(call Image/Build/CFE,$(1),963281TAN,6328,963281TAN-16M-flash-generic,,--pad 8)
176 $(call Image/Build/CFE,$(1),963281T_TEF,6328,963281T_TEF-generic,,--pad 8)
177 $(call Image/Build/CFE,$(1),96345GW2,6345,96345GW2-generic)
178 $(call Image/Build/CFE,$(1),96345GW2,6345,96348GW2-bc221,,--layoutver 5)
179 $(call Image/Build/CFE,$(1),96345GW2,6345,92345GW2-rev,OpenWRT-$(REVISION))
180 $(call Image/Build/CFE,$(1),96348GW,6348,96348GW-generic,,)
181 $(call Image/Build/CFE,$(1),96348R,6348,96348R-generic,,)
182 $(call Image/Build/CFE,$(1),96348GW,6348,96348GW-bc221,,--layoutver 5)
183 $(call Image/Build/CFE,$(1),6338GW,6338,6338GW-generic,,)
184 $(call Image/Build/CFE,$(1),6338W,6338,6338W-generic,,)
185 $(call Image/Build/CFE,$(1),96348GW-11,6348,96348GW-11-generic)
186 $(call Image/Build/CFE,$(1),96348GW-10,6348,96348GW-10-generic)
187 $(call Image/Build/CFE,$(1),96348A-122,6348,96348A-122-generic)
188 $(call Image/Build/CFE,$(1),96358VW,6358,96358VW-generic)
189 $(call Image/Build/CFE,$(1),96358VW2,6358,96358VW2-generic)
190 $(call Image/Build/CFE,$(1),96368MVNgr,6368,96368MVNgr-generic)
191 $(call Image/Build/CFE,$(1),96368MVWG,6368,96368MVWG-generic)
192
193 # BT Voyager V210_BTR
194 $(call Image/Build/CFE,$(1),V210_BB,6348,BTV210_BTR,,--layoutver 5)
195 # BT Voyager V210_ROI, V210_WB
196 $(call Image/Build/CFE,$(1),V210,6348,BTV210_ROI_WB,,--layoutver 5)
197 # BT Voyager V2091_BTR
198 $(call Image/Build/CFE,$(1),V2091_BB,6348,BTV2091_BTR,,--layoutver 5)
199 # BT Voyager V2091_ROI, V2091_WB
200 $(call Image/Build/CFE,$(1),V2091,6348,BTV2091_ROI_WB,,--layoutver 5)
201 # BT Voyager V220V, V220V_MGCP_BTR
202 $(call Image/Build/CFE,$(1),RTA1052V,6348,BTV220V_MGCP_BTR,,--layoutver 5)
203 # BT Voyager V2110, V2110_AA, V2110_ROI
204 $(call Image/Build/CFE,$(1),V2110,6348,BTV2110,,--layoutver 5)
205 # BT Voyager V2500V, V2500V_SIP_CLUB, V2500V_AA
206 $(call Image/Build/CFE,$(1),V2500V_BB,6348,BTV2500V,,--layoutver 5)
207 # RTA1025W_16 (numerous routers)
208 $(call Image/Build/CFE,$(1),RTA1025W_16,6348,RTA1025W_16,,--layoutver 5)
209 # RTA1320_16M (numerous routers)
210 $(call Image/Build/CFE,$(1),RTA1320_16M,6338,RTA1320_16M,,--layoutver 5)
211 # Tecom GW6000
212 $(call Image/Build/CFEFIXUP,$(1),96348GW,GW6000,6348,GW6000)
213 # Tecom GW6200
214 $(call Image/Build/CFEFIXUP,$(1),96348GW,GW6200,6348,GW6200,$(shell printf '\x99'))
215 # Neufbox4
216 $(call Image/Build/CFE,$(1),96358VW,6358,NEUFBOX4,OpenWRT-$(REVISION))
217
218 # Neufbox6
219 $(call Image/Build/CFE,$(1),NB6-SER-r0,6362,NEUFBOX6,OpenWRT-$(REVISION))
220
221 # Comtrend 6373
222 $(call Image/Build/CFE,$(1),CT6373-1,6358,CT6373)
223 # Comtrend 536, 5621
224 $(call Image/Build/CFEFIXUP,$(1),96348GW-11,CT536_CT5621,6348,CT536_CT5621)
225 # Davolink DV201AMR
226 $(call Image/Build/CFEOLD,$(1),DV201AMR,6348)
227 # USR 9108
228 $(call Image/Build/CFE,$(1),96348GW-A,6348,USR9108)
229 # NetGear DG834GT, DG834PN
230 $(call Image/Build/CFE,$(1),96348GW-10,6348,DG834GT_DG834PN)
231 # Belkin f5d7633
232 $(call Image/Build/CFE,$(1),96348GW-10,6348,F5D7633)
233 # D-Link DSL-2640B, rev B2
234 $(call Image/Build/CFE,$(1),D-4P-W,6348,DSL2640B-B2)
235 # D-Link DSL-2650U
236 $(call Image/Build/CFE,$(1),96358VW2,6358,DSL2650U)
237 # D-Link DSL-2740B/DSL-2741B, rev C2
238 $(call Image/Build/CFEFIXUP,$(1),96358GW,AW4139,6358,DSL274XB-C2)
239 # D-Link DSL-2740B/DSL-2741B, rev C3
240 $(call Image/Build/CFE,$(1),AW4139,6358,DSL274XB-C3)
241 # D-Link DSL-2740B/DSL-2741B, rev F1
242 $(call Image/Build/CFE,$(1),AW4339U,6328,DSL274XB-F1-EU,,--signature2="4.06.01.EUF1" --pad 4)
243 $(call Image/Build/CFE,$(1),AW4339U,6328,DSL274XB-F1-AU,,--signature2="4.06.01.AUF1" --pad 4)
244 # D-Link DVA-G3810BN/TL
245 $(call Image/Build/CFEFIXUP,$(1),96358VW,DVAG3810BN,6358,DVAG3810BN)
246
247 # TP-Link TD-8810A, TD-8810B, TD-8811A, TD-8811B
248 $(call Image/Build/CFE,$(1),8L-2M-8M,6338,TP8810_8811)
249 # TP-Link 8900GB
250 $(call Image/Build/CFE,$(1),96348GW-11,6348,TD8900GB,$(shell printf 'PRID\x89\x10\x00\x02'))
251
252 # Sagem F@ST2404
253 $(call Image/Build/CFE,$(1),F@ST2404,6348,F@ST2404-cfe)
254 $(call Image/Build/CFE,$(1),F@ST2404,6348,F@ST2404,OpenWRT-$(REVISION))
255 # Sagem F@ST2604
256 $(call Image/Build/CFE,$(1),F@ST2604,6348,F@ST2604-cfe)
257 $(call Image/Build/CFE,$(1),F@ST2604,6348,F@ST2604,OpenWRT-$(REVISION))
258 # Inventel Livebox
259 $(call Image/Build/RedBoot,livebox)
260 # Pirelli Alice Gate VoIP 2 Plus Wi-Fi AGPF-S0
261 $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,AGV2+W-cfe)
262 $(call Image/Build/CFEAGPF,$(1),AGPF-S0,6358,0x20000,AGV2+W)
263 # Pirelli A226G
264 $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,A226G-cfe)
265 $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x10000,A226G)
266
267 # Pirelli A226M
268 $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x20000,A226M-cfe)
269 $(call Image/Build/CFEAGPF,$(1),DWV-S0,6358,0x20000,A226M)
270
271 # RG100A,DB120 etc.
272 $(call Image/Build/RG100A,$(1),96358VW2,6358,0x20000,RG100A_DB120)
273
274 # Telsey CPVA642-type (e.g. CPA-ZNTE60T)
275 $(call Image/Build/CFE,$(1),CPVA642,6358,CPA-ZNTE60T,,--signature "Telsey Tlc",--signature2 "99.99.999",--second-image-flag "0")
276
277 # T-Com Speedport W 500V
278 $(call Image/Build/CFEFIXUP,$(1),96348GW,SPW500V,6348,SPW500V)
279
280 #HW553
281 $(call Image/Build/CFEHW553,$(1),HW553,6358,0x20000,HW553)
282
283 #HW556
284 $(call Image/Build/CFEHW556,$(1),HW556,6358,0x20000,EchoLife_HG556a,OpenWRT-$(REVISION))
285
286 # T-Com Speedport W 303V Typ B
287 $(call Image/Build/SPW303V,$(1),96358-502V,6358,SPW303V)
288
289 # Netgear CVG834G
290 $(call Image/Build/HCS,$(1),cvg834g,a020,0001,0022,$(KDIR)/vmlinux)
291
292 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
293 $(call Image/Build/Initramfs)
294 endif
295 endef
296
297 $(eval $(call BuildImage))