bcm53xx: put kernel into TRX when building initramfs images
[librecmc/librecmc.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 BRCMFMAC_43602A1 := kmod-brcmfmac brcmfmac-firmware-43602a1-pcie
111 BRCMFMAC_4366B1 := kmod-brcmfmac brcmfmac-firmware-4366b1-pcie
112 BRCMFMAC_4366C0 := kmod-brcmfmac
113 USB2_PACKAGES := kmod-usb-ohci kmod-usb2 kmod-phy-bcm-ns-usb2
114 USB2_PACKAGES += kmod-usb-ledtrig-usbport
115 USB3_PACKAGES := $(USB2_PACKAGES) kmod-usb3 kmod-phy-bcm-ns-usb3
116
117 define Device/Default
118   # .dtb files are prefixed by SoC type, e.g. bcm4708- which is not included in device/image names
119   # extract the full dtb name based on the device info
120   DEVICE_DTS := $(patsubst %.dtb,%,$(notdir $(wildcard $(if $(IB),$(KDIR),$(DTS_DIR))/*-$(1).dtb)))
121   KERNEL := kernel-bin | append-dtb | lzma-d16
122   KERNEL_DEPENDS = $$(wildcard $(DTS_DIR)/$$(DEVICE_DTS).dts)
123   KERNEL_INITRAMFS_SUFFIX := .trx
124   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma-d16 | trx
125   FILESYSTEMS := squashfs
126   KERNEL_NAME := zImage
127   IMAGE_NAME = $$(IMAGE_PREFIX)-$$(1).$$(2)
128   IMAGES := trx
129   BLOCKSIZE := 128k
130   PAGESIZE := 2048
131   IMAGE/trx := append-ubi | trx-nand
132 endef
133
134 define Device/asus
135   IMAGES := trx
136   IMAGE/trx := append-ubi | trx-nand | asus-trx
137 endef
138
139 define Device/asus-rt-ac56u
140   DEVICE_TITLE := Asus RT-AC56U
141   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
142 endef
143 TARGET_DEVICES += asus-rt-ac56u
144
145 define Device/asus-rt-ac68u
146   DEVICE_TITLE := Asus RT-AC68U
147   DEVICE_PACKAGES := $(USB3_PACKAGES)
148 endef
149 TARGET_DEVICES += asus-rt-ac68u
150
151 define Device/asus-rt-ac87u
152   DEVICE_TITLE := Asus RT-AC87U
153   DEVICE_PACKAGES := $(USB3_PACKAGES)
154 endef
155 TARGET_DEVICES += asus-rt-ac87u
156
157 define Device/asus-rt-n18u
158   DEVICE_TITLE := Asus RT-N18U
159   DEVICE_PACKAGES := $(USB3_PACKAGES)
160 endef
161 TARGET_DEVICES += asus-rt-n18u
162
163 # Buffalo devices have TFTP recovery mode which can work nicely with initramfs
164 # kernels.
165 # We should have two initramfs images for Buffalo: plain initramfs kernel and
166 # TRX with initramfs kernel. It's not possible right now so let's just build
167 # plain initramfs kernel as it may be more useful.
168 define Device/buffalo/Default
169   KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX)
170   KERNEL_INITRAMFS = $$(KERNEL)
171 endef
172
173 define Device/buffalo-wxr-1900dhp
174   $(call Device/buffalo/Default)
175   DEVICE_TITLE := Buffalo WXR-1900DHP
176   DEVICE_PACKAGES := $(USB3_PACKAGES)
177 endef
178 TARGET_DEVICES += buffalo-wxr-1900dhp
179
180 define Device/buffalo-wzr-600dhp2
181   $(call Device/buffalo/Default)
182   DEVICE_TITLE := Buffalo WZR-600DHP2
183   DEVICE_PACKAGES := kmod-b43 $(USB2_PACKAGES)
184 endef
185 TARGET_DEVICES += buffalo-wzr-600dhp2
186
187 define Device/buffalo-wzr-900dhp
188   $(call Device/buffalo/Default)
189   DEVICE_TITLE := Buffalo WZR-900DHP
190   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
191   BUFFALO_TAG_PLATFORM := bcm
192   BUFFALO_TAG_VERSION := 9.99
193   BUFFALO_TAG_MINOR := 9.99
194   IMAGES += factory-DHP-EU.bin factory-DHP2-JP.bin
195   IMAGE/factory-DHP-EU.bin := \
196         append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP EU | \
197         buffalo-enc WZR-900DHP $$(BUFFALO_TAG_VERSION) | \
198         buffalo-tag-dhp WZR-900DHP EU mlang20 | buffalo-enc-tag | \
199         buffalo-dhp-image
200   IMAGE/factory-DHP2-JP.bin := \
201         append-ubi | trx-nand | buffalo-wzr-header WZR-900DHP2 JP | \
202         buffalo-enc WZR-900DHP2 $$(BUFFALO_TAG_VERSION) | \
203         buffalo-tag-dhp WZR-900DHP2 JP jp | buffalo-enc-tag | \
204         buffalo-dhp-image
205 endef
206 TARGET_DEVICES += buffalo-wzr-900dhp
207
208 define Device/buffalo-wzr-1750dhp
209   $(call Device/buffalo/Default)
210   DEVICE_TITLE := Buffalo WZR-1750DHP
211   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
212 endef
213 TARGET_DEVICES += buffalo-wzr-1750dhp
214
215 define Device/dlink
216   IMAGES := bin
217   IMAGE/bin := append-ubi | seama-nand
218 endef
219
220 define Device/dlink-dir-885l
221   DEVICE_TITLE := D-Link DIR-885L
222   DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
223   $(Device/dlink)
224   SIGNATURE := wrgac42_dlink.2015_dir885l
225 endef
226 TARGET_DEVICES += dlink-dir-885l
227
228 # Linksys devices are disabled due to problem with 2 TRX partitions
229
230 define Device/linksys-ea6300-v1
231   DEVICE_TITLE := Linksys EA6300 V1
232   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
233 endef
234 # TARGET_DEVICES += linksys-ea6300-v1
235
236 define Device/linksys-ea9200
237   DEVICE_TITLE := Linksys EA9200 V1
238   DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
239 endef
240 # TARGET_DEVICES += linksys-ea9200
241
242 define Device/linksys-ea9500
243   DEVICE_TITLE := Linksys EA9500
244   DEVICE_PACKAGES := $(BRCMFMAC_4366C0) $(USB3_PACKAGES)
245   DEVICE_DTS := bcm47094-linksys-panamera
246 endef
247 # TARGET_DEVICES += linksys-ea9500
248
249 define Device/netgear
250   IMAGES := chk
251   IMAGE/chk := append-ubi | trx-nand | netgear-chk
252   NETGEAR_REGION := 1
253 endef
254
255 define Device/netgear-r6250
256   DEVICE_TITLE := Netgear R6250
257   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
258   $(Device/netgear)
259   NETGEAR_BOARD_ID := U12H245T00_NETGEAR
260 endef
261 TARGET_DEVICES += netgear-r6250
262
263 define Device/netgear-r6300-v2
264   DEVICE_TITLE := Netgear R6300 V2
265   DEVICE_PACKAGES := kmod-b43 $(USB3_PACKAGES)
266   $(Device/netgear)
267   NETGEAR_BOARD_ID := U12H240T00_NETGEAR
268 endef
269 TARGET_DEVICES += netgear-r6300-v2
270
271 define Device/netgear-r7000
272   DEVICE_TITLE := Netgear R7000
273   DEVICE_PACKAGES := $(USB3_PACKAGES)
274   $(Device/netgear)
275   NETGEAR_BOARD_ID := U12H270T00_NETGEAR
276 endef
277 TARGET_DEVICES += netgear-r7000
278
279 define Device/netgear-r7900
280   DEVICE_TITLE := Netgear R7900
281   DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
282   $(Device/netgear)
283   NETGEAR_BOARD_ID := U12H315T30_NETGEAR
284 endef
285 TARGET_DEVICES += netgear-r7900
286
287 define Device/netgear-r8000
288   DEVICE_TITLE := Netgear R8000
289   DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
290   $(Device/netgear)
291   NETGEAR_BOARD_ID := U12H315T00_NETGEAR
292 endef
293 TARGET_DEVICES += netgear-r8000
294
295 define Device/netgear-r8500
296   DEVICE_TITLE := Netgear R8500
297   DEVICE_PACKAGES := $(BRCMFMAC_4366B1) $(USB3_PACKAGES)
298   $(Device/netgear)
299   NETGEAR_BOARD_ID := U12H334T00_NETGEAR
300 endef
301 # TARGET_DEVICES += netgear-r8500
302
303 define Device/smartrg-sr400ac
304   DEVICE_TITLE := SmartRG SR400ac
305   DEVICE_PACKAGES := $(BRCMFMAC_43602A1) $(USB3_PACKAGES)
306   IMAGES := trx
307   IMAGE/trx := append-rootfs | trx-serial
308 endef
309 TARGET_DEVICES += smartrg-sr400ac
310
311 define Device/tenda-ac9
312   DEVICE_TITLE := Tenda AC9
313   DEVICE_PACKAGES := kmod-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 := kmod-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))