fea32bef221abc53343dff3f2b04d2d21d7be23a
[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
8 # boards missing since devicetree update
9 #EASY50712 ARV3527P GIGASX76X BTHOMEHUBV2B BTHOMEHUBV2BOPENRG
10 #WBMR P2601HNFX H201L
11
12 include $(TOPDIR)/rules.mk
13 include $(INCLUDE_DIR)/image.mk
14
15 JFFS2_BLOCKSIZE = 64k 128k 256k
16
17 LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR)
18
19 define Image/BuildLoader/Template
20 -rm -rf $(KDIR)/lzma-loader
21 $(LOADER_MAKE) LOADER=loader$(2)-$(1).bin\
22 LZMA_TEXT_START=0x80a00000 \
23 LOADADDR=0x80002000 \
24 LOADER_DATA="$(KDIR)/vmlinux$(2)-$(1).lzma" BOARD="$(1)" \
25 compile loader.bin
26 endef
27
28
29 define CompressLzma
30 $(STAGING_DIR_HOST)/bin/lzma e $(1) $(2)
31 endef
32
33 define PatchKernelLzma
34 cp $(KDIR)/vmlinux$(2) $(KDIR)/vmlinux$(2)-$(1)
35 $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(1).dtb ../dts/$(1).dts
36 $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux$(2)-$(1) $(KDIR)/$(1).dtb
37 $(call CompressLzma,$(KDIR)/vmlinux$(2)-$(1),$(KDIR)/vmlinux$(2)-$(1).lzma)
38 endef
39
40 define MkBrnImage
41 mkbrncmdline -i $(KDIR)/vmlinux-$(4) -o $(KDIR)/vmlinux-$(4)-brn BRN-BOOT $(6)
42 $(call CompressLzma,$(KDIR)/vmlinux-$(4)-brn,$(KDIR)/vmlinux-$(4)-brn.lzma)
43 mkbrnimg -s $(1) -m $(2) -o $(3) $(KDIR)/vmlinux-$(4)-brn.lzma $(KDIR)/root.$(5)
44 endef
45
46 define MkImageLzma
47 mkimage -A mips -O linux -T kernel -a 0x80002000 -C lzma \
48 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
49 -d $(KDIR)/vmlinux$(2)-$(1).lzma $(KDIR)/uImage-$(1)$(2)
50 endef
51
52 define TPLinkImageLzma
53 mktplinkfw2 -c -B $(2) -s \
54 -k $(KDIR)/vmlinux$(3)-$(1).lzma -o $(KDIR)/uImage-$(1)$(3)
55 endef
56
57 define MkImageEVA
58 lzma2eva 0x80002000 0x80002000 $(KDIR)/vmlinux-$(1).lzma $(KDIR)/$(1).eva.prealign
59 dd if=$(KDIR)/$(1).eva.prealign of=$(KDIR)/$(1).eva bs=64k conv=sync
60 cat ./eva.dummy.squashfs >> $(KDIR)/$(1).eva
61 endef
62
63 define CompressGzip
64 gzip -c $(1) > $(2)
65 endef
66
67 define PatchKernelGzip
68 cp $(KDIR)/vmlinux$(3) $(KDIR)/vmlinux$(3)-$(1)
69 $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux$(3)-$(1) '$(strip $(2))'
70 $(call CompressGzip,$(KDIR)/vmlinux$(3)-$(1),$(KDIR)/vmlinux$(3)-$(1).gzip)
71 endef
72
73 define MkImageGzip
74 mkimage -A mips -O linux -T kernel -a 0x80002000 -C gzip \
75 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
76 -d $(KDIR)/vmlinux$(2)-$(1).gzip $(KDIR)/uImage-$(1)$(2)
77 endef
78
79 define Image/Build/squashfs
80 cat $(KDIR)/uImage-$(2) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
81 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
82 $(if $(3),$(call MkBrnImage,$(3),$(4),$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-brnImage,$(2),$(1),$(5)))
83 endef
84
85 define Image/BuildTPLink/squashfs
86 mktplinkfw2 -B $(3) -s -a 0x4 -j \
87 -k $(KDIR)/vmlinux-$(2).lzma -r $(KDIR)/root.$(1) \
88 -o $(BIN_DIR)/$(IMG_PREFIX)-$(2)-sysupgrade.image
89 endef
90
91 define Image/BuildEVA/squashfs
92 cat $(KDIR)/$(2).eva $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva
93 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva)
94 endef
95
96 define Image/BuildLoader/squashfs
97 dd if=$(KDIR)/loader-$(2).bin of=$(KDIR)/loader-$(2).bin.padded bs=1536k conv=sync
98 cat $(KDIR)/loader-$(2).bin.padded $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
99 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
100 endef
101
102 define Image/BuildNANDEVA/jffs2-128k
103 cp $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).rootfs
104 endef
105
106 define Image/Build/jffs2-64k
107 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=64k conv=sync
108 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
109 endef
110
111 define Image/Build/jffs2-128k
112 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=128k conv=sync
113 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
114 endef
115
116 define Image/Build/jffs2-256k
117 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=256k conv=sync
118 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
119 endef
120
121 define Image/BuildKernel/Template
122 $(call PatchKernelLzma,$(1))
123 $(call MkImageLzma,$(1))
124 $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
125 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
126 $(call PatchKernelLzma,$(1),-initramfs)
127 $(call MkImageLzma,$(1),-initramfs)
128 $(CP) $(KDIR)/uImage-$(1)-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage-initramfs
129 endif
130 endef
131
132 define Image/BuildKernelLoader/Template
133 $(call PatchKernelLzma,$(1))
134 $(call Image/BuildLoader/Template,$(1))
135 $(CP) $(KDIR)/loader-$(1).bin $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-loader
136 $(CP) $(KDIR)/vmlinux-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux
137 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
138 $(call PatchKernelLzma,$(1),-initramfs)
139 $(call Image/BuildLoader/Template,$(1),-initramfs)
140 $(CP) $(KDIR)/loader-initramfs-$(1).bin $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs-loader
141 $(CP) $(KDIR)/vmlinux-initramfs-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs
142 endif
143 endef
144
145 define Image/BuildKernelTPLink/Template
146 $(call PatchKernelLzma,$(1))
147 $(call TPLinkImageLzma,$(1),$(2))
148 $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
149 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
150 $(call PatchKernelLzma,$(1),-initramfs)
151 $(call Image/BuildLoader/Template,$(1),-initramfs)
152 $(CP) $(KDIR)/loader-initramfs-$(1).bin $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs-loader
153 $(CP) $(KDIR)/vmlinux-initramfs-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs
154 endif
155 endef
156
157 define Image/BuildKernelEVA/Template
158 $(call PatchKernelLzma,$(1))
159 $(call MkImageEVA,$(1))
160 $(CP) $(KDIR)/$(1).eva $(BIN_DIR)/$(IMG_PREFIX)-$(1).eva
161 endef
162
163 define Image/BuildKernelGzip/Template
164 $(call PatchKernelGzip,$(1),$(if $(2),$(2) machtype=$(1),))
165 $(call MkImageGzip,$(1))
166 $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
167 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
168 $(call PatchKernelGzip,$(1),$(if $(2),$(2) machtype=$(1),),-initramfs)
169 $(call MkImageGzip,$(1),-initramfs)
170 $(CP) $(KDIR)/uImage-$(1)-initramfs $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage-initramfs
171 endif
172 endef
173
174
175 ifeq ($(CONFIG_TARGET_lantiq_falcon),y)
176
177 Image/BuildKernel/Profile/EASY98000NOR=$(call Image/BuildKernel/Template,EASY98000NOR)
178 Image/Build/Profile/EASY98000NOR=$(call Image/Build/$(1),$(1),EASY98000NOR)
179
180 Image/BuildKernel/Profile/EASY98000SFLASH=$(call Image/BuildKernel/Template,EASY98000SFLASH)
181 Image/Build/Profile/EASY98000SFLASH=$(call Image/Build/$(1),$(1),EASY98000SFLASH)
182
183 endif
184
185
186
187 ifeq ($(CONFIG_TARGET_lantiq_ase),y)
188
189 Image/BuildKernel/Profile/DGN1000B=$(call Image/BuildKernel/Template,DGN1000B)
190 Image/Build/Profile/DGN1000B=$(call Image/Build/$(1),$(1),DGN1000B)
191
192 endif
193
194
195
196 ifeq ($(CONFIG_TARGET_lantiq_xway),y)
197
198 # Danube
199 Image/BuildKernel/Profile/EASY50712=$(call Image/BuildKernel/Template,EASY50712)
200 Image/Build/Profile/EASY50712=$(call Image/Build/$(1),$(1),EASY50712)
201
202 Image/BuildKernel/Profile/ACMP252=$(call Image/BuildKernel/Template,ACMP252)
203 Image/Build/Profile/ACMP252=$(call Image/Build/$(1),$(1),ACMP252)
204
205 Image/BuildKernel/Profile/ARV4510PW=$(call Image/BuildKernel/Template,ARV4510PW)
206 Image/Build/Profile/ARV4510PW=$(call Image/Build/$(1),$(1),ARV4510PW)
207
208 Image/BuildKernel/Profile/ARV4525PW=$(call Image/BuildKernel/Template,ARV4525PW)
209 Image/Build/Profile/ARV4525PW=$(call Image/Build/$(1),$(1),ARV4525PW)
210
211 Image/BuildKernel/Profile/ARV7525PW=$(call Image/BuildKernel/Template,ARV7525PW)
212 Image/Build/Profile/ARV7525PW=$(call Image/Build/$(1),$(1),ARV7525PW)
213
214 Image/BuildKernel/Profile/ARV4518PWR01=$(call Image/BuildKernel/Template,ARV4518PWR01)
215 Image/Build/Profile/ARV4518PWR01=$(call Image/Build/$(1),$(1),ARV4518PWR01)
216
217 Image/BuildKernel/Profile/ARV4518PWR01A=$(call Image/BuildKernel/Template,ARV4518PWR01A)
218 Image/Build/Profile/ARV4518PWR01A=$(call Image/Build/$(1),$(1),ARV4518PWR01A)
219
220 Image/BuildKernel/Profile/ARV4519PW=$(call Image/BuildKernel/Template,ARV4519PW)
221 Image/Build/Profile/ARV4519PW=$(call Image/Build/$(1),$(1),ARV4519PW)
222
223 Image/BuildKernel/Profile/ARV4520PW=$(call Image/BuildKernel/Template,ARV4520PW)
224 Image/Build/Profile/ARV4520PW=$(call Image/Build/$(1),$(1),ARV4520PW)
225
226 Image/BuildKernel/Profile/ARV452CQW=$(call Image/BuildKernel/Template,ARV452CQW)
227 Image/Build/Profile/ARV452CQW=$(call Image/Build/$(1),$(1),ARV452CQW)
228
229 Image/BuildKernel/Profile/ARV7518PW=$(call Image/BuildKernel/Template,ARV7518PW)
230 Image/Build/Profile/ARV7518PW=$(call Image/Build/$(1),$(1),ARV7518PW)
231
232 Image/BuildKernel/Profile/ARV752DPW=$(call Image/BuildKernel/Template,ARV752DPW)
233 Image/Build/Profile/ARV752DPW=$(call Image/Build/$(1),$(1),ARV752DPW)
234
235 Image/BuildKernel/Profile/ARV752DPW22=$(call Image/BuildKernel/Template,ARV752DPW22)
236 Image/Build/Profile/ARV752DPW22=$(call Image/Build/$(1),$(1),ARV752DPW22)
237
238
239 # AR9
240 Image/BuildKernel/Profile/DGN3500=$(call Image/BuildKernel/Template,DGN3500)
241 Image/Build/Profile/DGN3500=$(call Image/Build/$(1),$(1),DGN3500)
242
243 Image/BuildKernel/Profile/DGN3500B=$(call Image/BuildKernel/Template,DGN3500)
244 Image/Build/Profile/DGN3500B=$(call Image/Build/$(1),$(1),DGN3500)
245
246 Image/BuildKernel/Profile/WBMRA=$(call Image/BuildKernel/Template,WBMR)
247 Image/Build/Profile/WBMRA=$(call Image/Build/$(1),$(1),WBMR)
248
249 Image/BuildKernel/Profile/WBMRB=$(call Image/BuildKernel/Template,WBMR)
250 Image/Build/Profile/WBMRB=$(call Image/Build/$(1),$(1),WBMR)
251
252 Image/BuildKernel/Profile/FRITZ7320=$(call Image/BuildKernelEVA/Template,FRITZ7320)
253 Image/Build/Profile/FRITZ7320=$(call Image/BuildEVA/$(1),$(1),FRITZ7320)
254
255 Image/BuildKernel/Profile/GR7000=$(call Image/BuildKernel/Template,GR7000)
256 Image/Build/Profile/GR7000=$(call Image/Build/$(1),$(1),GR7000)
257
258 endif
259
260
261 ifeq ($(CONFIG_TARGET_lantiq_xrx200),y)
262
263 # VR9
264 Image/BuildKernel/Profile/EASY80920NAND=$(call Image/BuildKernel/Template,EASY80920NAND)
265 Image/Build/Profile/EASY80920NAND=$(call Image/Build/$(1),$(1),EASY80920NAND)
266
267 Image/BuildKernel/Profile/EASY80920NOR=$(call Image/BuildKernel/Template,EASY80920NOR)
268 Image/Build/Profile/EASY80920NOR=$(call Image/Build/$(1),$(1),EASY80920NOR)
269
270 Image/BuildKernel/Profile/FRITZ3370=$(call Image/BuildKernelEVA/Template,FRITZ3370)
271 Image/Build/Profile/FRITZ3370=$(call Image/BuildNANDEVA/$(1),$(1),FRITZ3370)
272
273 Image/BuildKernel/Profile/VG3503J=$(call Image/BuildKernelLoader/Template,VG3503J)
274 Image/Build/Profile/VG3503J=$(call Image/BuildLoader/$(1),$(1),VG3503J)
275
276 Image/BuildKernel/Profile/TDW8970=$(call Image/BuildKernelTPLink/Template,TDW8970,TD-W8970v1,$(1))
277 Image/Build/Profile/TDW8970=$(call Image/BuildTPLink/$(1),$(1),TDW8970,TD-W8970v1)
278
279 endif
280
281
282
283 ifeq ($(CONFIG_TARGET_lantiq_svip_be),y)
284
285 Image/BuildKernel/Profile/EASY33016=$(call Image/BuildKernelGzip/Template,EASY33016)
286 Image/Build/Profile/EASY33016=$(call Image/Build/$(1),$(1),EASY33016)
287
288 endif
289
290
291 define Image/BuildKernel
292 $(call Image/BuildKernel/Profile/$(PROFILE))
293 endef
294
295 define Image/Build
296 $(call Image/Build/Profile/$(PROFILE),$(1))
297 endef
298
299 $(eval $(call BuildImage))