e42d612f1f684673fa80653ca076273b45ae62f2
[openwrt/openwrt.git] / target / linux / bcm53xx / image / Makefile
1 #
2 # Copyright (C) 2013 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 define Image/Prepare
11 rm -f $(KDIR)/fs_mark
12 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/fs_mark
13 $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
14
15 # For UBI we want only one extra block
16 rm -f $(KDIR)/ubi_mark
17 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
18 endef
19
20 define Build/lzma-d16
21 $(STAGING_DIR_HOST)/bin/lzma e $@ -d16 $(1) $@.new
22 mv $@.new $@
23 endef
24
25 # Similar to Build/tplink-safeloader but uses TRX instead of clean kernel
26 define Build/bcm53xx-tplink-safeloader
27 $(STAGING_DIR_HOST)/bin/trx \
28 -o $@.trx \
29 -m 33554432 \
30 -f $(IMAGE_KERNEL) -a 1024
31 $(STAGING_DIR_HOST)/bin/tplink-safeloader \
32 -B $(TPLINK_BOARD) \
33 -k $@.trx \
34 -r $@ \
35 -j \
36 -o $@.new
37 mv $@.new $@
38 rm $@.trx
39 endef
40
41 define Build/buffalo-wzr-header
42 $(eval product=$(word 1,$(1)))
43 $(eval region=$(word 2,$(1)))
44 ( \
45 echo $(product)_$(BUFFALO_TAG_VERSION)_$(BUFFALO_TAG_MINOR)_$(region)_$(BUFFALO_TAG_PLATFORM); \
46 echo filelen=$$(stat -c%s $@); \
47 cat $@ \
48 ) > $@.new
49 mv $@.new $@
50 endef
51
52 # TRX with only one (kernel) partition
53 define Build/trx
54 $(STAGING_DIR_HOST)/bin/trx \
55 -o $@.new \
56 -m 33554432 \
57 -f $@
58 mv $@.new $@
59 endef
60
61 define Build/trx-serial
62 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
63 -f $(IMAGE_KERNEL) -a 1024 \
64 -f $@ -a 0x10000 -A $(KDIR)/fs_mark
65 mv $@.new $@
66 endef
67
68 define Build/trx-nand
69 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
70 # if it grows up between releases
71 # root: UBI with one extra block containing UBI mark to trigger erasing
72 # rest of partition
73 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
74 -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
75 -f $@ \
76 -A $(KDIR)/ubi_mark -a 0x20000
77 mv $@.new $@
78 endef
79
80 define Build/asus-trx
81 $(STAGING_DIR_HOST)/bin/asustrx \
82 -p $(PRODUCTID) -i $@ -o $@.new
83 mv $@.new $@
84 endef
85
86 define Build/seama-nand
87 # Seama entity
88 $(STAGING_DIR_HOST)/bin/oseama \
89 entity $@.entity \
90 -m "dev=/dev/mtdblock/7" \
91 -m "type=firmware" \
92 -f $(IMAGE_KERNEL) \
93 -b 0x400000 \
94 -f $@ \
95 -f $(KDIR)/ubi_mark
96 # Seama container
97 $(STAGING_DIR_HOST)/bin/seama \
98 -s $@ \
99 -m "signature=$(SIGNATURE)" \
100 -i $@.entity
101 endef
102
103 DEVICE_VARS += PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION TPLINK_BOARD
104 DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
105
106 IEEE8021X := wpad-mini
107 B43 := $(IEEE8021X) kmod-b43
108 BRCMFMAC_43602A1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-43602a1-pcie
109 BRCMFMAC_4366B1 := $(IEEE8021X) kmod-brcmfmac brcmfmac-firmware-4366b1-pcie
110 BRCMFMAC_4366C0 := $(IEEE8021X) kmod-brcmfmac
111 USB2_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-phy-bcm-ns-usb2
112 USB2_PACKAGES += kmod-usb-ledtrig-usbport
113 USB3_PACKAGES := $(USB2_PACKAGES) kmod-usb3 kmod-phy-bcm-ns-usb3
114
115 define Device/Default
116 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
117 # extract the full dtb name based on the device info
118 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
119 KERNEL := kernel-bin | append-dtb | lzma-d16
120 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
121 KERNEL_INITRAMFS_SUFFIX := .trx
122 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16 | trx
123 FILESYSTEMS := squashfs
124 KERNEL_NAME := zImage
125 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
126 IMAGES := trx
127 BLOCKSIZE := 128k
128 PAGESIZE := 2048
129 IMAGE/trx := append-ubi | trx-nand
130 endef
131
132 define Device/asus
133 IMAGES := trx
134 IMAGE/trx := append-ubi | trx-nand | asus-trx
135 endef
136
137 define Device/asus-rt-ac56u
138 DEVICE_TITLE := Asus RT-AC56U
139 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
140 endef
141 TARGET_DEVICES += asus-rt-ac56u
142
143 define Device/asus-rt-ac68u
144 DEVICE_TITLE := Asus RT-AC68U
145 DEVICE_PACKAGES := $(USB3_PACKAGES)
146 endef
147 TARGET_DEVICES += asus-rt-ac68u
148
149 define Device/asus-rt-ac87u
150 DEVICE_TITLE := Asus RT-AC87U
151 DEVICE_PACKAGES := $(USB3_PACKAGES)
152 endef
153 TARGET_DEVICES += asus-rt-ac87u
154
155 define Device/asus-rt-n18u
156 DEVICE_TITLE := Asus RT-N18U
157 DEVICE_PACKAGES := $(USB3_PACKAGES)
158 endef
159 TARGET_DEVICES += asus-rt-n18u
160
161 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
162 # kernels.
163 # We should have two initramfs images for Buffalo: plain initramfs kernel and
164 # TRX with initramfs kernel. It's not possible right now so let's just build
165 # plain initramfs kernel as it may be more useful.
166 define Device/buffalo/Default
167 KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
168 KERNEL_INITRAMFS = $$(KERNEL)
169 endef
170
171 define Device/buffalo-wxr-1900dhp
172 $(call Device/buffalo/Default)
173 DEVICE_TITLE := Buffalo WXR-1900DHP
174 DEVICE_PACKAGES := $(USB3_PACKAGES)
175 endef
176 TARGET_DEVICES += buffalo-wxr-1900dhp
177
178 define Device/buffalo-wzr-600dhp2
179 $(call Device/buffalo/Default)
180 DEVICE_TITLE := Buffalo WZR-600DHP2
181 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
182 endef
183 TARGET_DEVICES += buffalo-wzr-600dhp2
184
185 define Device/buffalo-wzr-900dhp
186 $(call Device/buffalo/Default)
187 DEVICE_TITLE := Buffalo WZR-900DHP
188 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
189 BUFFALO_TAG_PLATFORM := bcm
190 BUFFALO_TAG_VERSION := 9.99
191 BUFFALO_TAG_MINOR := 9.99
192 IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
193 IMAGE/factory-DHP-EU.bin := \
194 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
195 buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
196 buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
197 buffalo-dhp-image
198 IMAGE/factory-DHP2-JP.bin := \
199 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
200 buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
201 buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
202 buffalo-dhp-image
203 endef
204 TARGET_DEVICES += buffalo-wzr-900dhp
205
206 define Device/buffalo-wzr-1750dhp
207 $(call Device/buffalo/Default)
208 DEVICE_TITLE := Buffalo WZR-1750DHP
209 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
210 endef
211 TARGET_DEVICES += buffalo-wzr-1750dhp
212
213 define Device/dlink
214 IMAGES := bin
215 IMAGE/bin := append-ubi | seama-nand
216 endef
217
218 define Device/dlink-dir-885l
219 DEVICE_TITLE := D-Link DIR-885L
220 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
221 $(Device/dlink)
222 SIGNATURE := wrgac42_dlink.2015_dir885l
223 endef
224 TARGET_DEVICES += dlink-dir-885l
225
226 # Linksys devices are disabled due to problem with 2 TRX partitions
227 define Device/linksys-ea6300-v1
228 DEVICE_TITLE := Linksys EA6300 V1
229 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
230 endef
231 # TARGET_DEVICES += linksys-ea6300-v1
232
233 define Device/linksys-ea6500-v2
234 DEVICE_TITLE := Linksys EA6500 V2
235 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
236 endef
237 TARGET_DEVICES += linksys-ea6500-v2
238
239 define Device/linksys-ea9200
240 DEVICE_TITLE := Linksys EA9200 V1
241 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
242 endef
243 # TARGET_DEVICES += linksys-ea9200
244
245 define Device/linksys-ea9500
246 DEVICE_TITLE := Linksys EA9500
247 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
248 DEVICE_DTS := bcm47094-linksys-panamera
249 endef
250 # TARGET_DEVICES += linksys-ea9500
251
252 define Device/netgear
253 IMAGES := chk
254 IMAGE/chk := append-ubi | trx-nand | netgear-chk
255 NETGEAR_REGION := 1
256 endef
257
258 define Device/netgear-r6250
259 DEVICE_TITLE := Netgear R6250
260 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
261 $(Device/netgear)
262 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
263 endef
264 TARGET_DEVICES += netgear-r6250
265
266 define Device/netgear-r6300-v2
267 DEVICE_TITLE := Netgear R6300 V2
268 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
269 $(Device/netgear)
270 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
271 endef
272 TARGET_DEVICES += netgear-r6300-v2
273
274 define Device/netgear-r7000
275 DEVICE_TITLE := Netgear R7000
276 DEVICE_PACKAGES := $(USB3_PACKAGES)
277 $(Device/netgear)
278 NETGEAR_BOARD_ID := U12H270T00_NETGEAR
279 endef
280 TARGET_DEVICES += netgear-r7000
281
282 define Device/netgear-r7900
283 DEVICE_TITLE := Netgear R7900
284 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
285 $(Device/netgear)
286 NETGEAR_BOARD_ID := U12H315T30_NETGEAR
287 endef
288 TARGET_DEVICES += netgear-r7900
289
290 define Device/netgear-r8000
291 DEVICE_TITLE := Netgear R8000
292 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
293 $(Device/netgear)
294 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
295 endef
296 TARGET_DEVICES += netgear-r8000
297
298 define Device/netgear-r8500
299 DEVICE_TITLE := Netgear R8500
300 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
301 $(Device/netgear)
302 NETGEAR_BOARD_ID := U12H334T00_NETGEAR
303 endef
304 # TARGET_DEVICES += netgear-r8500
305
306 define Device/smartrg-sr400ac
307 DEVICE_TITLE := SmartRG SR400ac
308 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
309 IMAGES := trx
310 IMAGE/trx := append-rootfs | trx-serial
311 KERNEL_INITRAMFS_SUFFIX := .bin
312 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
313 endef
314 TARGET_DEVICES += smartrg-sr400ac
315
316 define Device/tenda-ac9
317 DEVICE_TITLE := Tenda AC9
318 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
319 IMAGES := trx
320 IMAGE/trx := append-rootfs | trx-serial
321 endef
322 TARGET_DEVICES += tenda-ac9
323
324 define Device/tplink-archer-c5-v2
325 DEVICE_TITLE := TP-LINK Archer C5 V2
326 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
327 IMAGES := bin
328 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
329 TPLINK_BOARD := ARCHER-C5-V2
330 endef
331 TARGET_DEVICES += tplink-archer-c5-v2
332
333 define Device/tplink-archer-c9-v1
334 DEVICE_TITLE := TP-LINK Archer C9 V1
335 DEVICE_PACKAGES := $(USB3_PACKAGES)
336 IMAGES := bin
337 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
338 TPLINK_BOARD := ARCHERC9
339 endef
340 TARGET_DEVICES += tplink-archer-c9-v1
341
342 $(eval $(call BuildImage))