660981ea1e2611d197bebe769eda2fe549091dbb
[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 define Build/trx-serial
53 $(STAGING_DIR_HOST)/bin/trx \
54 -o $@.new \
55 -m 33554432 \
56 -f $(IMAGE_KERNEL) -a 1024 \
57 -f $@ -a 0x10000 -A $(KDIR)/fs_mark
58 mv $@.new $@
59 endef
60
61 define Build/trx-nand
62 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
63 # if it grows up between releases
64 # root: UBI with one extra block containing UBI mark to trigger erasing
65 # rest of partition
66 $(STAGING_DIR_HOST)/bin/trx \
67 -o $@.new \
68 -m 33554432 \
69 -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
70 -f $@ \
71 -A $(KDIR)/ubi_mark -a 0x20000
72 mv $@.new $@
73 endef
74
75 define Build/asus-trx
76 $(STAGING_DIR_HOST)/bin/asustrx \
77 -p $(PRODUCTID) -i $@ -o $@.new
78 mv $@.new $@
79 endef
80
81 define Build/seama-nand
82 # Seama entity
83 $(STAGING_DIR_HOST)/bin/oseama \
84 entity $@.entity \
85 -m "dev=/dev/mtdblock/7" \
86 -m "type=firmware" \
87 -f $(IMAGE_KERNEL) \
88 -b 0x400000 \
89 -f $@ \
90 -f $(KDIR)/ubi_mark
91 # Seama container
92 $(STAGING_DIR_HOST)/bin/seama \
93 -s $@ \
94 -m "signature=$(SIGNATURE)" \
95 -i $@.entity
96 endef
97
98 DEVICE_VARS += PRODUCTID SIGNATURE NETGEAR_BOARD_ID NETGEAR_REGION TPLINK_BOARD
99 DEVICE_VARS += BUFFALO_TAG_PLATFORM BUFFALO_TAG_VERSION BUFFALO_TAG_MINOR
100
101 BRCMFMAC_43602A1 := kmod-brcmfmac brcmfmac-firmware-43602a1-pcie
102 BRCMFMAC_4366B1 := kmod-brcmfmac brcmfmac-firmware-4366b1-pcie
103 BRCMFMAC_4366C0 := kmod-brcmfmac
104 USB2_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-phy-bcm-ns-usb2
105 USB2_PACKAGES += kmod-usb-ledtrig-usbport
106 USB3_PACKAGES := $(USB2_PACKAGES) kmod-usb3 kmod-phy-bcm-ns-usb3
107
108 define Device/Default
109 # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
110 # extract the full dtb name based on the device info
111 DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
112 KERNEL := kernel-bin | append-dtb | lzma-d16
113 KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
114 FILESYSTEMS := squashfs
115 KERNEL_NAME := zImage
116 IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
117 IMAGES := trx
118 BLOCKSIZE := 128k
119 PAGESIZE := 2048
120 IMAGE/trx := append-ubi | trx-nand
121 endef
122
123 define Device/asus
124 IMAGES := trx
125 IMAGE/trx := append-ubi | trx-nand | asus-trx
126 endef
127
128 define Device/asus-rt-ac56u
129 DEVICE_TITLE := Asus RT-AC56U
130 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
131 endef
132 TARGET_DEVICES += asus-rt-ac56u
133
134 define Device/asus-rt-ac68u
135 DEVICE_TITLE := Asus RT-AC68U
136 DEVICE_PACKAGES := $(USB3_PACKAGES)
137 endef
138 TARGET_DEVICES += asus-rt-ac68u
139
140 define Device/asus-rt-ac87u
141 DEVICE_TITLE := Asus RT-AC87U
142 DEVICE_PACKAGES := $(USB3_PACKAGES)
143 endef
144 TARGET_DEVICES += asus-rt-ac87u
145
146 define Device/asus-rt-n18u
147 DEVICE_TITLE := Asus RT-N18U
148 DEVICE_PACKAGES := $(USB3_PACKAGES)
149 endef
150 TARGET_DEVICES += asus-rt-n18u
151
152 define Device/buffalo-wxr-1900dhp
153 DEVICE_TITLE := Buffalo WXR-1900DHP
154 DEVICE_PACKAGES := $(USB3_PACKAGES)
155 endef
156 TARGET_DEVICES += buffalo-wxr-1900dhp
157
158 define Device/buffalo-wzr-600dhp2
159 DEVICE_TITLE := Buffalo WZR-600DHP2
160 DEVICE_PACKAGES := kmod-b43 $(USB2_PACKAGES)
161 endef
162 TARGET_DEVICES += buffalo-wzr-600dhp2
163
164 define Device/buffalo-wzr-900dhp
165 DEVICE_TITLE := Buffalo WZR-900DHP
166 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
167 BUFFALO_TAG_PLATFORM := bcm
168 BUFFALO_TAG_VERSION := 9.99
169 BUFFALO_TAG_MINOR := 9.99
170 IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
171 IMAGE/factory-DHP-EU.bin := \
172 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
173 buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
174 buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
175 buffalo-dhp-image
176 IMAGE/factory-DHP2-JP.bin := \
177 append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
178 buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
179 buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
180 buffalo-dhp-image
181 endef
182 TARGET_DEVICES += buffalo-wzr-900dhp
183
184 define Device/buffalo-wzr-1750dhp
185 DEVICE_TITLE := Buffalo WZR-1750DHP
186 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
187 endef
188 TARGET_DEVICES += buffalo-wzr-1750dhp
189
190 define Device/dlink
191 IMAGES := bin
192 IMAGE/bin := append-ubi | seama-nand
193 endef
194
195 define Device/dlink-dir-885l
196 DEVICE_TITLE := D-Link DIR-885L
197 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
198 $(Device/dlink)
199 SIGNATURE := wrgac42_dlink.2015_dir885l
200 endef
201 TARGET_DEVICES += dlink-dir-885l
202
203 # Linksys devices are disabled due to problem with 2 TRX partitions
204
205 define Device/linksys-ea6300-v1
206 DEVICE_TITLE := Linksys EA6300 V1
207 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
208 endef
209 # TARGET_DEVICES += linksys-ea6300-v1
210
211 define Device/linksys-ea9200
212 DEVICE_TITLE := Linksys EA9200 V1
213 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
214 endef
215 # TARGET_DEVICES += linksys-ea9200
216
217 define Device/linksys-ea9500
218 DEVICE_TITLE := Linksys EA9500
219 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
220 DEVICE_DTS := bcm47094-linksys-panamera
221 endef
222 # TARGET_DEVICES += linksys-ea9500
223
224 define Device/netgear
225 IMAGES := chk
226 IMAGE/chk := append-ubi | trx-nand | netgear-chk
227 NETGEAR_REGION := 1
228 endef
229
230 define Device/netgear-r6250
231 DEVICE_TITLE := Netgear R6250
232 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
233 $(Device/netgear)
234 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
235 endef
236 TARGET_DEVICES += netgear-r6250
237
238 define Device/netgear-r6300-v2
239 DEVICE_TITLE := Netgear R6300 V2
240 DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
241 $(Device/netgear)
242 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
243 endef
244 TARGET_DEVICES += netgear-r6300-v2
245
246 define Device/netgear-r7000
247 DEVICE_TITLE := Netgear R7000
248 DEVICE_PACKAGES := $(USB3_PACKAGES)
249 $(Device/netgear)
250 NETGEAR_BOARD_ID := U12H270T00_NETGEAR
251 endef
252 TARGET_DEVICES += netgear-r7000
253
254 define Device/netgear-r7900
255 DEVICE_TITLE := Netgear R7900
256 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
257 $(Device/netgear)
258 NETGEAR_BOARD_ID := U12H315T30_NETGEAR
259 endef
260 TARGET_DEVICES += netgear-r7900
261
262 define Device/netgear-r8000
263 DEVICE_TITLE := Netgear R8000
264 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
265 $(Device/netgear)
266 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
267 endef
268 TARGET_DEVICES += netgear-r8000
269
270 define Device/netgear-r8500
271 DEVICE_TITLE := Netgear R8500
272 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
273 $(Device/netgear)
274 NETGEAR_BOARD_ID := U12H334T00_NETGEAR
275 endef
276 # TARGET_DEVICES += netgear-r8500
277
278 define Device/smartrg-sr400ac
279 DEVICE_TITLE := SmartRG SR400ac
280 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
281 IMAGES := trx
282 IMAGE/trx := append-rootfs | trx-serial
283 endef
284 TARGET_DEVICES += smartrg-sr400ac
285
286 define Device/tenda-ac9
287 DEVICE_TITLE := Tenda AC9
288 DEVICE_PACKAGES := kmod-b43 $(USB2_PACKAGES)
289 IMAGES := trx
290 IMAGE/trx := append-rootfs | trx-serial
291 endef
292 TARGET_DEVICES += tenda-ac9
293
294 define Device/tplink-archer-c5-v2
295 DEVICE_TITLE := TP-LINK Archer C5 V2
296 DEVICE_PACKAGES := kmod-b43 $(USB2_PACKAGES)
297 IMAGES := bin
298 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
299 TPLINK_BOARD := ARCHER-C5-V2
300 endef
301 # TARGET_DEVICES += tplink-archer-c5-v2
302
303 define Device/tplink-archer-c9-v1
304 DEVICE_TITLE := TP-LINK Archer C9 V1
305 DEVICE_PACKAGES := $(USB3_PACKAGES)
306 IMAGES := bin
307 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
308 TPLINK_BOARD := ARCHERC9
309 endef
310 TARGET_DEVICES += tplink-archer-c9-v1
311
312 $(eval $(call BuildImage))