[lantiq] add lantiq svip support
[openwrt.git] / target / linux / lantiq / image / Makefile
1
2 # Copyright (C) 2010-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 JFFS2_BLOCKSIZE = 64k 128k 256k
11
12 ase_cmdline=-console=ttyLTQ0,115200 rootfstype=squashfs,jffs2
13 xway_cmdline=-console=ttyLTQ1,115200 rootfstype=squashfs,jffs2
14 falcon_cmdline=-console=ttyLTQ0,115200 rootfstype=squashfs,jffs2
15 svip_cmdline=-console=ttyLTQ0,115200 rootfstype=squashfs,jffs2
16 sx76x_cmdline=console=ttyLTQ1,115200 rootfstype=squashfs,jffs2
17
18 define CompressLzma
19   $(STAGING_DIR_HOST)/bin/lzma e $(1) $(2)
20 endef
21
22 define PatchKernelLzma
23         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
24         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
25         $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).lzma)
26 endef
27
28 define MkBrnImage
29         mkbrncmdline -i $(KDIR)/vmlinux-$(4) -o $(KDIR)/vmlinux-$(4)-brn BRN-BOOT $(6)
30         $(call CompressLzma,$(KDIR)/vmlinux-$(4)-brn,$(KDIR)/vmlinux-$(4)-brn.lzma)
31         mkbrnimg -s $(1) -m $(2) -o $(3) $(KDIR)/vmlinux-$(4)-brn.lzma $(KDIR)/root.$(5)
32 endef
33
34 define MkImageLzma
35         mkimage -A mips -O linux -T kernel -a 0x80002000 -C lzma \
36                 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
37                 -d $(KDIR)/vmlinux-$(1).lzma $(KDIR)/uImage-$(1)
38 endef
39
40 define MkImageEVA
41         lzma2eva 0x80002000 0x80002000 $(KDIR)/vmlinux-$(1).lzma $(KDIR)/$(1).eva.prealign
42         dd if=$(KDIR)/$(1).eva.prealign of=$(KDIR)/$(1).eva bs=64k conv=sync
43         cat ./eva.dummy.squashfs >> $(KDIR)/$(1).eva
44 endef
45
46 define CompressGzip
47   gzip -c $(1) > $(2)
48 endef
49
50 define PatchKernelGzip
51         cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
52         $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
53         $(call CompressGzip,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).gzip)
54 endef
55
56 define MkImageGzip
57         mkimage -A mips -O linux -T kernel -a 0x80002000 -C gzip \
58                 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
59                 -d $(KDIR)/vmlinux-$(1).gzip $(KDIR)/uImage-$(1)
60 endef
61
62 define Image/Build/squashfs
63         cat $(KDIR)/uImage-$(2) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
64         $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
65         $(if $(3),$(call MkBrnImage,$(3),$(4),$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-brnImage,$(2),$(1),$(5)))
66 endef
67
68 define Image/BuildEVA/squashfs
69         cat $(KDIR)/$(2).eva $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva
70         $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva)
71 endef
72
73 define Image/Build/jffs2-64k
74         dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=64k conv=sync
75         cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
76 endef
77
78 define Image/Build/jffs2-128k
79         dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=128k conv=sync
80         cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
81 endef
82
83 define Image/Build/jffs2-256k
84         dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=256k conv=sync
85         cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
86 endef
87
88 define Image/BuildKernel/Template
89         $(call PatchKernelLzma,$(1),$(if $(2),$(2) machtype=$(1),))
90         $(call MkImageLzma,$(1))
91         $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
92 endef
93
94 define Image/BuildKernelEVA/Template
95         $(call PatchKernelLzma,$(1),$(if $(2),$(2) machtype=$(1),))
96         $(call MkImageEVA,$(1))
97         $(CP) $(KDIR)/$(1).eva $(BIN_DIR)/$(IMG_PREFIX)-$(1).eva
98 endef
99
100 define Image/BuildKernelGzip/Template
101         $(call PatchKernelGzip,$(1),$(if $(2),$(2) machtype=$(1),))
102         $(call MkImageGzip,$(1))
103         $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
104 endef
105
106 ifeq ($(CONFIG_TARGET_lantiq_danube),y)
107
108 Image/BuildKernel/Profile/EASY50712=$(call Image/BuildKernel/Template,EASY50712,$(xway_cmdline))
109 Image/BuildKernel/Profile/ARV3527P=$(call Image/BuildKernel/Template,ARV3527P,$(xway_cmdline))
110 Image/BuildKernel/Profile/ARV4510PW=$(call Image/BuildKernel/Template,ARV4510PW,$(xway_cmdline))
111 Image/BuildKernel/Profile/ARV4518PW=$(call Image/BuildKernel/Template,ARV4518PW,$(xway_cmdline))
112 Image/BuildKernel/Profile/ARV4519PW=$(call Image/BuildKernel/Template,ARV4519PW,$(xway_cmdline))
113 Image/BuildKernel/Profile/ARV4520PW=$(call Image/BuildKernel/Template,ARV4520PW,$(xway_cmdline))
114 Image/BuildKernel/Profile/ARV4525PW=$(call Image/BuildKernel/Template,ARV4525PW,$(xway_cmdline))
115 Image/BuildKernel/Profile/ARV7525PW=$(call Image/BuildKernel/Template,ARV7525PW,$(xway_cmdline))
116 Image/BuildKernel/Profile/ARV452CPW=$(call Image/BuildKernel/Template,ARV452CPW,$(xway_cmdline))
117 Image/BuildKernel/Profile/ARV7518PW=$(call Image/BuildKernel/Template,ARV7518PW,$(xway_cmdline))
118 Image/BuildKernel/Profile/ARV752DPW=$(call Image/BuildKernel/Template,ARV752DPW,$(xway_cmdline))
119 Image/BuildKernel/Profile/ARV752DPW22=$(call Image/BuildKernel/Template,ARV752DPW22,$(xway_cmdline))
120 Image/BuildKernel/Profile/GIGASX76X=$(call Image/BuildKernel/Template,GIGASX76X,$(sx76x_cmdline))
121 Image/BuildKernel/Profile/BTHOMEHUBV2B=$(call Image/BuildKernel/Template,BTHOMEHUBV2B,$(xway_cmdline))
122 Image/BuildKernel/Profile/BTHOMEHUBV2BOPENRG=$(call Image/BuildKernel/Template,BTHOMEHUBV2BOPENRG,$(xway_cmdline))
123
124 Image/Build/Profile/EASY50712=$(call Image/Build/$(1),$(1),EASY50712)
125 Image/Build/Profile/ARV3527P=$(call Image/Build/$(1),$(1),ARV3527P)
126 Image/Build/Profile/ARV4510PW=$(call Image/Build/$(1),$(1),ARV4510PW)
127 Image/Build/Profile/ARV4518PW=$(call Image/Build/$(1),$(1),ARV4518PW)
128 Image/Build/Profile/ARV4519PW=$(call Image/Build/$(1),$(1),ARV4519PW,BRNDA4519,0x12345678,memsize=32)
129 Image/Build/Profile/ARV4520PW=$(call Image/Build/$(1),$(1),ARV4520PW,BRNDANUBE,0x12345678,memsize=32)
130 Image/Build/Profile/ARV4525PW=$(call Image/Build/$(1),$(1),ARV4525PW,BRNDTW502,0x12345678,memsize=32)
131 Image/Build/Profile/ARV7525PW=$(call Image/Build/$(1),$(1),ARV7525PW)
132 Image/Build/Profile/ARV452CPW=$(call Image/Build/$(1),$(1),ARV452CPW)
133 Image/Build/Profile/ARV7518PW=$(call Image/Build/$(1),$(1),ARV7518PW,BRNDA7519,0x12345678,memsize=64)
134 Image/Build/Profile/ARV752DPW=$(call Image/Build/$(1),$(1),ARV752DPW)
135 Image/Build/Profile/ARV752DPW22=$(call Image/Build/$(1),$(1),ARV752DPW22)
136 Image/Build/Profile/GIGASX76X=$(call Image/Build/$(1),$(1),GIGASX76X)
137 Image/Build/Profile/BTHOMEHUBV2B=$(call Image/Build/$(1),$(1),BTHOMEHUBV2B)
138 Image/Build/Profile/BTHOMEHUBV2BOPENRG=$(call Image/Build/$(1),$(1),BTHOMEHUBV2BOPENRG)
139
140 define Image/BuildKernel/Profile/Generic
141         $(call Image/BuildKernel/Template,NONE)
142 endef
143
144 define Image/Build/Profile/Generic
145         $(call Image/Build/$(1),$(1),NONE)
146         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
147 endef
148 endif
149
150 ifeq ($(CONFIG_TARGET_lantiq_ar9),y)
151 Image/BuildKernel/Profile/WBMR=$(call Image/BuildKernel/Template,WBMR,$(xway_cmdline))
152 Image/BuildKernel/Profile/DGN3500B=$(call Image/BuildKernel/Template,DGN3500B,$(xway_cmdline))
153 Image/BuildKernel/Profile/P2601HNFX=$(call Image/BuildKernel/Template,P2601HNFX,$(xway_cmdline))
154 Image/BuildKernel/Profile/H201L=$(call Image/BuildKernel/Template,H201L,$(xway_cmdline))
155 Image/BuildKernel/Profile/FRITZ7320=$(call Image/BuildKernelEVA/Template,FRITZ7320,$(xway_cmdline))
156
157 Image/Build/Profile/WBMR=$(call Image/Build/$(1),$(1),WBMR)
158 Image/Build/Profile/DGN3500B=$(call Image/Build/$(1),$(1),DGN3500B)
159 Image/Build/Profile/P2601HNFX=$(call Image/Build/$(1),$(1),P2601HNFX)
160 Image/Build/Profile/H201L=$(call Image/Build/$(1),$(1),H201L)
161 Image/Build/Profile/FRITZ7320=$(call Image/BuildEVA/$(1),$(1),FRITZ7320)
162
163 define Image/BuildKernel/Profile/Generic
164         $(call Image/BuildKernel/Template,NONE)
165 endef
166
167 define Image/Build/Profile/Generic
168         $(call Image/Build/$(1),$(1),NONE)
169         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
170 endef
171 endif
172
173 ifeq ($(CONFIG_TARGET_lantiq_falcon)$(CONFIG_TARGET_lantiq_falcon_stable),y)
174
175 Image/BuildKernel/Profile/EASY98000=$(call Image/BuildKernel/Template,EASY98000,$(falcon_cmdline))
176 Image/BuildKernel/Profile/EASY98020=$(call Image/BuildKernel/Template,EASY98020,$(falcon_cmdline))
177
178 Image/Build/Profile/EASY98000=$(call Image/Build/$(1),$(1),EASY98000)
179 Image/Build/Profile/EASY98020=$(call Image/Build/$(1),$(1),EASY98020)
180
181 define Image/BuildKernel/Profile/Generic
182         $(call Image/BuildKernel/Template,NONE)
183 endef
184
185 define Image/Build/Profile/Generic
186         $(call Image/Build/$(1),$(1),NONE)
187         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
188 endef
189 endif
190
191 ifeq ($(CONFIG_TARGET_lantiq_ase),y)
192
193 Image/BuildKernel/Profile/EASY50601=$(call Image/BuildKernel/Template,EASY50601,$(ase_cmdline))
194 Image/Build/Profile/EASY50601=$(call Image/Build/$(1),$(1),EASY50601)
195
196 define Image/BuildKernel/Profile/Generic
197         $(call Image/BuildKernel/Template,NONE)
198 endef
199
200 define Image/Build/Profile/Generic
201         $(call Image/Build/$(1),$(1),NONE)
202         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
203 endef
204 endif
205
206 ifeq ($(CONFIG_TARGET_lantiq_vr9),y)
207 define Image/BuildKernel/Profile/FRITZ3370
208         $(call Image/BuildKernel/Template,FRITZ3370,$(xway_cmdline))
209         $(call Image/BuildKernelEVA/Template,FRITZ3370,$(xway_cmdline))
210 endef
211
212 Image/Build/Profile/FRITZ3370=$(call Image/Build/$(1),$(1),FRITZ3370)
213
214 define Image/BuildKernel/Profile/Generic
215         $(call Image/BuildKernel/Template,NONE)
216 endef
217
218 define Image/Build/Profile/Generic
219         $(call Image/Build/$(1),$(1),NONE)
220         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
221 endef
222 endif
223
224 ifeq ($(CONFIG_TARGET_lantiq_svip_be),y)
225 define Image/BuildKernel/Profile/EASY33016
226         $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
227 endef
228
229 define Image/Build/Profile/EASY33016
230         $(call Image/Build/$(1),$(1),EASY33016)
231 endef
232
233 define Image/BuildKernel/Profile/EASY336
234         $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
235 endef
236
237 define Image/Build/Profile/EASY336
238         $(call Image/Build/$(1),$(1),EASY33016)
239 endef
240
241 define Image/BuildKernel/Profile/Generic
242         $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
243         $(call Image/BuildKernelGzip/Template,EASY336,$(svip_cmdline))
244         $(call Image/BuildKernelGzip/Template,NONE)
245 endef
246
247 define Image/Build/Profile/Generic
248         $(call Image/Build/$(1),$(1),EASY33016)
249         $(call Image/Build/$(1),$(1),EASY336)
250         $(call Image/Build/$(1),$(1),NONE)
251         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
252 endef
253 endif
254
255 ifeq ($(CONFIG_TARGET_lantiq_svip_le),y)
256 define Image/BuildKernel/Profile/EASY336
257         $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
258 endef
259
260 define Image/Build/Profile/EASY336
261         $(call Image/Build/$(1),$(1),EASY33016)
262 endef
263
264 define Image/BuildKernel/Profile/Generic
265         $(call Image/BuildKernelGzip/Template,EASY336,$(svip_cmdline))
266         $(call Image/BuildKernelGzip/Template,NONE)
267 endef
268
269 define Image/Build/Profile/Generic
270         $(call Image/Build/$(1),$(1),EASY336)
271         $(call Image/Build/$(1),$(1),NONE)
272         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
273 endef
274 endif
275
276 define Image/BuildKernel
277         $(call Image/BuildKernel/Profile/$(PROFILE))
278 endef
279
280 define Image/Build
281         $(call Image/Build/Profile/$(PROFILE),$(1))
282 endef
283
284 $(eval $(call BuildImage))