adds dts files and make devicetree images buildable
[openwrt/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_5),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 Image/BuildKernel/Profile/EASY80920-NAND=$(call Image/BuildKernel/Template,EASY80920-NAND)
206 Image/Build/Profile/EASY80920-NAND=$(call Image/Build/$(1),$(1),EASY80920-NAND)
207 Image/BuildKernel/Profile/EASY80920-NOR=$(call Image/BuildKernel/Template,EASY80920-NOR)
208 Image/Build/Profile/EASY80920-NOR=$(call Image/Build/$(1),$(1),EASY80920-NOR)
209
210 endif
211
212 ifeq ($(CONFIG_TARGET_lantiq_vr9),y)
213 define Image/BuildKernel/Profile/FRITZ3370
214 $(call Image/BuildKernel/Template,FRITZ3370,$(xway_cmdline))
215 $(call Image/BuildKernelEVA/Template,FRITZ3370,$(xway_cmdline))
216 endef
217
218 Image/Build/Profile/FRITZ3370=$(call Image/Build/$(1),$(1),FRITZ3370)
219
220 define Image/BuildKernel/Profile/Generic
221 $(call Image/BuildKernel/Template,NONE)
222 endef
223
224 define Image/Build/Profile/Generic
225 $(call Image/Build/$(1),$(1),NONE)
226 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
227 endef
228 endif
229
230 ifeq ($(CONFIG_TARGET_lantiq_svip_be),y)
231 define Image/BuildKernel/Profile/EASY33016
232 $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
233 endef
234
235 define Image/Build/Profile/EASY33016
236 $(call Image/Build/$(1),$(1),EASY33016)
237 endef
238
239 define Image/BuildKernel/Profile/EASY336
240 $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
241 endef
242
243 define Image/Build/Profile/EASY336
244 $(call Image/Build/$(1),$(1),EASY33016)
245 endef
246
247 define Image/BuildKernel/Profile/Generic
248 $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
249 $(call Image/BuildKernelGzip/Template,EASY336,$(svip_cmdline))
250 $(call Image/BuildKernelGzip/Template,NONE)
251 endef
252
253 define Image/Build/Profile/Generic
254 $(call Image/Build/$(1),$(1),EASY33016)
255 $(call Image/Build/$(1),$(1),EASY336)
256 $(call Image/Build/$(1),$(1),NONE)
257 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
258 endef
259 endif
260
261 ifeq ($(CONFIG_TARGET_lantiq_svip_le),y)
262 define Image/BuildKernel/Profile/EASY336
263 $(call Image/BuildKernelGzip/Template,EASY33016,$(svip_cmdline))
264 endef
265
266 define Image/Build/Profile/EASY336
267 $(call Image/Build/$(1),$(1),EASY33016)
268 endef
269
270 define Image/BuildKernel/Profile/Generic
271 $(call Image/BuildKernelGzip/Template,EASY336,$(svip_cmdline))
272 $(call Image/BuildKernelGzip/Template,NONE)
273 endef
274
275 define Image/Build/Profile/Generic
276 $(call Image/Build/$(1),$(1),EASY336)
277 $(call Image/Build/$(1),$(1),NONE)
278 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).rootfs
279 endef
280 endif
281
282 define Image/BuildKernel
283 $(call Image/BuildKernel/Profile/$(PROFILE))
284 endef
285
286 define Image/Build
287 $(call Image/Build/Profile/$(PROFILE),$(1))
288 endef
289
290 $(eval $(call BuildImage))