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