a226b4db578cbe1df7aa197a5ff8441e4407b63e
[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 ARV4519PW 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 define CompressLzma
18 $(STAGING_DIR_HOST)/bin/lzma e $(1) $(2)
19 endef
20
21 define PatchKernelLzma
22 cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
23 $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(1).dtb ./$(1).dts
24 $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux-$(1) $(KDIR)/$(1).dtb
25 $(call CompressLzma,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).lzma)
26 endef
27
28 define PatchKernelRaw
29 cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
30 $(LINUX_DIR)/scripts/dtc/dtc -O dtb -o $(KDIR)/$(1).dtb ./$(1).dts
31 $(STAGING_DIR_HOST)/bin/patch-dtb $(KDIR)/vmlinux-$(1) $(KDIR)/$(1).dtb
32 endef
33
34 define MkBrnImage
35 mkbrncmdline -i $(KDIR)/vmlinux-$(4) -o $(KDIR)/vmlinux-$(4)-brn BRN-BOOT $(6)
36 $(call CompressLzma,$(KDIR)/vmlinux-$(4)-brn,$(KDIR)/vmlinux-$(4)-brn.lzma)
37 mkbrnimg -s $(1) -m $(2) -o $(3) $(KDIR)/vmlinux-$(4)-brn.lzma $(KDIR)/root.$(5)
38 endef
39
40 define MkImageLzma
41 mkimage -A mips -O linux -T kernel -a 0x80002000 -C lzma \
42 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
43 -d $(KDIR)/vmlinux-$(1).lzma $(KDIR)/uImage-$(1)
44 endef
45
46 define MkImageEVA
47 lzma2eva 0x80002000 0x80002000 $(KDIR)/vmlinux-$(1).lzma $(KDIR)/$(1).eva.prealign
48 dd if=$(KDIR)/$(1).eva.prealign of=$(KDIR)/$(1).eva bs=64k conv=sync
49 cat ./eva.dummy.squashfs >> $(KDIR)/$(1).eva
50 endef
51
52 define CompressGzip
53 gzip -c $(1) > $(2)
54 endef
55
56 define PatchKernelGzip
57 cp $(KDIR)/vmlinux $(KDIR)/vmlinux-$(1)
58 $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-$(1) '$(strip $(2))'
59 $(call CompressGzip,$(KDIR)/vmlinux-$(1),$(KDIR)/vmlinux-$(1).gzip)
60 endef
61
62 define MkImageGzip
63 mkimage -A mips -O linux -T kernel -a 0x80002000 -C gzip \
64 -e 0x80002000 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
65 -d $(KDIR)/vmlinux-$(1).gzip $(KDIR)/uImage-$(1)
66 endef
67
68 define Image/Build/squashfs
69 cat $(KDIR)/uImage-$(2) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
70 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
71 $(if $(3),$(call MkBrnImage,$(3),$(4),$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(3)-brnImage,$(2),$(1),$(5)))
72 endef
73
74 define Image/BuildEVA/squashfs
75 cat $(KDIR)/$(2).eva $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva
76 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image.eva)
77 endef
78
79 define Image/BuildRaw/squashfs
80 dd if=$(KDIR)/vmlinux-$(2) of=$(KDIR)/vmlinux-$(2)-$(1) bs=1M conv=sync
81 cat $(KDIR)/vmlinux-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
82 $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image)
83 endef
84
85 define Image/BuildNANDEVA/jffs2-128k
86 cp $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).rootfs
87 endef
88
89 define Image/Build/jffs2-64k
90 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=64k conv=sync
91 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
92 endef
93
94 define Image/Build/jffs2-128k
95 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=128k conv=sync
96 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
97 endef
98
99 define Image/Build/jffs2-256k
100 dd if=$(KDIR)/uImage-$(2) of=$(KDIR)/uImage-$(2)-$(1) bs=256k conv=sync
101 cat $(KDIR)/uImage-$(2)-$(1) $(KDIR)/root.$(1) > $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(1).image
102 endef
103
104 define Image/BuildKernel/Template
105 $(call PatchKernelLzma,$(1),$(if $(2),$(2) machtype=$(1),))
106 $(call MkImageLzma,$(1))
107 $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
108 endef
109
110 define Image/BuildKernelRaw/Template
111 $(call PatchKernelRaw,$(1))
112 $(CP) $(KDIR)/vmlinux-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux
113 endef
114
115 define Image/BuildKernelEVA/Template
116 $(call PatchKernelLzma,$(1),$(if $(2),$(2) machtype=$(1),))
117 $(call MkImageEVA,$(1))
118 $(CP) $(KDIR)/$(1).eva $(BIN_DIR)/$(IMG_PREFIX)-$(1).eva
119 endef
120
121 define Image/BuildKernelGzip/Template
122 $(call PatchKernelGzip,$(1),$(if $(2),$(2) machtype=$(1),))
123 $(call MkImageGzip,$(1))
124 $(CP) $(KDIR)/uImage-$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1)-uImage
125 endef
126
127
128 ifeq ($(CONFIG_TARGET_lantiq_falcon),y)
129
130 Image/BuildKernel/Profile/EASY98000NOR=$(call Image/BuildKernel/Template,EASY98000NOR)
131 Image/Build/Profile/EASY98000NOR=$(call Image/Build/$(1),$(1),EASY98000NOR)
132
133 Image/BuildKernel/Profile/EASY98000SFLASH=$(call Image/BuildKernel/Template,EASY98000SFLASH)
134 Image/Build/Profile/EASY98000SFLASH=$(call Image/Build/$(1),$(1),EASY98000SFLASH)
135
136 endif
137
138
139
140 ifeq ($(CONFIG_TARGET_lantiq_ase),y)
141
142 Image/BuildKernel/Profile/DGN1000B=$(call Image/BuildKernel/Template,DGN1000B)
143 Image/Build/Profile/DGN1000B=$(call Image/Build/$(1),$(1),DGN1000B)
144
145 endif
146
147
148
149 ifeq ($(CONFIG_TARGET_lantiq_xway),y)
150
151 # Danube
152 Image/BuildKernel/Profile/EASY50712=$(call Image/BuildKernel/Template,EASY50712)
153 Image/Build/Profile/EASY50712=$(call Image/Build/$(1),$(1),EASY50712)
154
155 Image/BuildKernel/Profile/ACMP252=$(call Image/BuildKernel/Template,ACMP252)
156 Image/Build/Profile/ACMP252=$(call Image/Build/$(1),$(1),ACMP252)
157
158 Image/BuildKernel/Profile/ARV4510PW=$(call Image/BuildKernel/Template,ARV4510PW)
159 Image/Build/Profile/ARV4510PW=$(call Image/Build/$(1),$(1),ARV4510PW)
160
161 Image/BuildKernel/Profile/ARV4525PW=$(call Image/BuildKernel/Template,ARV4525PW)
162 Image/Build/Profile/ARV4525PW=$(call Image/Build/$(1),$(1),ARV4525PW)
163
164 Image/BuildKernel/Profile/ARV7525PW=$(call Image/BuildKernel/Template,ARV7525PW)
165 Image/Build/Profile/ARV7525PW=$(call Image/Build/$(1),$(1),ARV7525PW)
166
167 Image/BuildKernel/Profile/ARV4518PWR01=$(call Image/BuildKernel/Template,ARV4518PWR01)
168 Image/Build/Profile/ARV4518PWR01=$(call Image/Build/$(1),$(1),ARV4518PWR01)
169
170 Image/BuildKernel/Profile/ARV4518PWR01A=$(call Image/BuildKernel/Template,ARV4518PWR01A)
171 Image/Build/Profile/ARV4518PWR01A=$(call Image/Build/$(1),$(1),ARV4518PWR01A)
172
173 Image/BuildKernel/Profile/ARV4520PW=$(call Image/BuildKernel/Template,ARV4520PW)
174 Image/Build/Profile/ARV4520PW=$(call Image/Build/$(1),$(1),ARV4520PW)
175
176 Image/BuildKernel/Profile/ARV452CQW=$(call Image/BuildKernel/Template,ARV452CQW)
177 Image/Build/Profile/ARV452CQW=$(call Image/Build/$(1),$(1),ARV452CQW)
178
179 Image/BuildKernel/Profile/ARV7518PW=$(call Image/BuildKernel/Template,ARV7518PW)
180 Image/Build/Profile/ARV7518PW=$(call Image/Build/$(1),$(1),ARV7518PW)
181
182 Image/BuildKernel/Profile/ARV752DPW=$(call Image/BuildKernel/Template,ARV752DPW)
183 Image/Build/Profile/ARV752DPW=$(call Image/Build/$(1),$(1),ARV752DPW)
184
185 Image/BuildKernel/Profile/ARV752DPW22=$(call Image/BuildKernel/Template,ARV752DPW22)
186 Image/Build/Profile/ARV752DPW22=$(call Image/Build/$(1),$(1),ARV752DPW22)
187
188
189 # AR9
190 Image/BuildKernel/Profile/DGN3500=$(call Image/BuildKernel/Template,DGN3500)
191 Image/Build/Profile/DGN3500=$(call Image/Build/$(1),$(1),DGN3500)
192
193 Image/BuildKernel/Profile/DGN3500B=$(call Image/BuildKernel/Template,DGN3500)
194 Image/Build/Profile/DGN3500B=$(call Image/Build/$(1),$(1),DGN3500)
195
196 Image/BuildKernel/Profile/WBMRA=$(call Image/BuildKernel/Template,WBMR)
197 Image/Build/Profile/WBMRA=$(call Image/Build/$(1),$(1),WBMR)
198
199 Image/BuildKernel/Profile/WBMRB=$(call Image/BuildKernel/Template,WBMR)
200 Image/Build/Profile/WBMRB=$(call Image/Build/$(1),$(1),WBMR)
201
202 Image/BuildKernel/Profile/FRITZ7320=$(call Image/BuildKernelEVA/Template,FRITZ7320)
203 Image/Build/Profile/FRITZ7320=$(call Image/BuildEVA/$(1),$(1),FRITZ7320)
204
205
206 # VR9
207 Image/BuildKernel/Profile/EASY80920NAND=$(call Image/BuildKernel/Template,EASY80920NAND)
208 Image/Build/Profile/EASY80920NAND=$(call Image/Build/$(1),$(1),EASY80920NAND)
209
210 Image/BuildKernel/Profile/EASY80920NOR=$(call Image/BuildKernel/Template,EASY80920NOR)
211 Image/Build/Profile/EASY80920NOR=$(call Image/Build/$(1),$(1),EASY80920NOR)
212
213 Image/BuildKernel/Profile/FRITZ3370=$(call Image/BuildKernelEVA/Template,FRITZ3370)
214 Image/Build/Profile/FRITZ3370=$(call Image/BuildNANDEVA/$(1),$(1),FRITZ3370)
215
216 Image/BuildKernel/Profile/VG3503J=$(call Image/BuildKernelRaw/Template,VG3503J)
217 Image/Build/Profile/VG3503J=$(call Image/BuildRaw/$(1),$(1),VG3503J)
218
219 endif
220
221
222
223 ifeq ($(CONFIG_TARGET_lantiq_svip_be),y)
224
225 Image/BuildKernel/Profile/EASY33016=$(call Image/BuildKernelGzip/Template,EASY33016)
226 Image/Build/Profile/EASY33016=$(call Image/Build/$(1),$(1),EASY33016)
227
228 endif
229
230
231 define Image/BuildKernel
232 $(call Image/BuildKernel/Profile/$(PROFILE))
233 endef
234
235 define Image/Build
236 $(call Image/Build/Profile/$(PROFILE),$(1))
237 endef
238
239 $(eval $(call BuildImage))