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