bcm53xx: use otrx for creating TRX images
[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
228 define Device/linksys-ea6300-v1
229 DEVICE_TITLE := Linksys EA6300 V1
230 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
231 endef
232 # TARGET_DEVICES += linksys-ea6300-v1
233
234 define Device/linksys-ea9200
235 DEVICE_TITLE := Linksys EA9200 V1
236 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
237 endef
238 # TARGET_DEVICES += linksys-ea9200
239
240 define Device/linksys-ea9500
241 DEVICE_TITLE := Linksys EA9500
242 DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
243 DEVICE_DTS := bcm47094-linksys-panamera
244 endef
245 # TARGET_DEVICES += linksys-ea9500
246
247 define Device/netgear
248 IMAGES := chk
249 IMAGE/chk := append-ubi | trx-nand | netgear-chk
250 NETGEAR_REGION := 1
251 endef
252
253 define Device/netgear-r6250
254 DEVICE_TITLE := Netgear R6250
255 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
256 $(Device/netgear)
257 NETGEAR_BOARD_ID := U12H245T00_NETGEAR
258 endef
259 TARGET_DEVICES += netgear-r6250
260
261 define Device/netgear-r6300-v2
262 DEVICE_TITLE := Netgear R6300 V2
263 DEVICE_PACKAGES := $(B43) $(USB3_PACKAGES)
264 $(Device/netgear)
265 NETGEAR_BOARD_ID := U12H240T00_NETGEAR
266 endef
267 TARGET_DEVICES += netgear-r6300-v2
268
269 define Device/netgear-r7000
270 DEVICE_TITLE := Netgear R7000
271 DEVICE_PACKAGES := $(USB3_PACKAGES)
272 $(Device/netgear)
273 NETGEAR_BOARD_ID := U12H270T00_NETGEAR
274 endef
275 TARGET_DEVICES += netgear-r7000
276
277 define Device/netgear-r7900
278 DEVICE_TITLE := Netgear R7900
279 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
280 $(Device/netgear)
281 NETGEAR_BOARD_ID := U12H315T30_NETGEAR
282 endef
283 TARGET_DEVICES += netgear-r7900
284
285 define Device/netgear-r8000
286 DEVICE_TITLE := Netgear R8000
287 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
288 $(Device/netgear)
289 NETGEAR_BOARD_ID := U12H315T00_NETGEAR
290 endef
291 TARGET_DEVICES += netgear-r8000
292
293 define Device/netgear-r8500
294 DEVICE_TITLE := Netgear R8500
295 DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
296 $(Device/netgear)
297 NETGEAR_BOARD_ID := U12H334T00_NETGEAR
298 endef
299 # TARGET_DEVICES += netgear-r8500
300
301 define Device/smartrg-sr400ac
302 DEVICE_TITLE := SmartRG SR400ac
303 DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
304 IMAGES := trx
305 IMAGE/trx := append-rootfs | trx-serial
306 KERNEL_INITRAMFS_SUFFIX := .bin
307 KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16
308 endef
309 TARGET_DEVICES += smartrg-sr400ac
310
311 define Device/tenda-ac9
312 DEVICE_TITLE := Tenda AC9
313 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
314 IMAGES := trx
315 IMAGE/trx := append-rootfs | trx-serial
316 endef
317 TARGET_DEVICES += tenda-ac9
318
319 define Device/tplink-archer-c5-v2
320 DEVICE_TITLE := TP-LINK Archer C5 V2
321 DEVICE_PACKAGES := $(B43) $(USB2_PACKAGES)
322 IMAGES := bin
323 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
324 TPLINK_BOARD := ARCHER-C5-V2
325 endef
326 TARGET_DEVICES += tplink-archer-c5-v2
327
328 define Device/tplink-archer-c9-v1
329 DEVICE_TITLE := TP-LINK Archer C9 V1
330 DEVICE_PACKAGES := $(USB3_PACKAGES)
331 IMAGES := bin
332 IMAGE/bin := append-rootfs | bcm53xx-tplink-safeloader
333 TPLINK_BOARD := ARCHERC9
334 endef
335 TARGET_DEVICES += tplink-archer-c9-v1
336
337 $(eval $(call BuildImage))