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