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