3b0afa98dffc888bec325c57fd891817baaf7599
[openwrt/openwrt.git] / target / linux / mediatek / image / mt7622.mk
1 DTS_DIR := $(DTS_DIR)/mediatek
2
3 ifdef CONFIG_LINUX_5_4
4 KERNEL_LOADADDR := 0x44080000
5 else
6 KERNEL_LOADADDR := 0x44000000
7 endif
8
9 define Image/Prepare
10 # For UBI we want only one extra block
11 rm -f $(KDIR)/ubi_mark
12 echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark
13 endef
14
15 define Build/buffalo-kernel-trx
16 $(eval magic=$(word 1,$(1)))
17 $(eval dummy=$(word 2,$(1)))
18 $(eval kern_size=$(if $(KERNEL_SIZE),$(KERNEL_SIZE),0x400000))
19
20 $(if $(dummy),touch $(dummy))
21 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
22 $(if $(magic),-M $(magic),) \
23 -f $@ \
24 $(if $(dummy),\
25 -a 0x20000 \
26 -b $$(( $(subst k, * 1024,$(kern_size)) )) \
27 -f $(dummy),)
28 mv $@.new $@
29 endef
30
31 define Build/bl2
32 cat $(STAGING_DIR_IMAGE)/mt7622-$1-bl2.img >> $@
33 endef
34
35 define Build/bl31-uboot
36 cat $(STAGING_DIR_IMAGE)/mt7622_$1-u-boot.fip >> $@
37 endef
38
39 define Build/mt7622-gpt
40 cp $@ $@.tmp 2>/dev/null || true
41 ptgen -g -o $@.tmp -a 1 -l 1024 \
42 $(if $(findstring sdmmc,$1), \
43 -H \
44 -t 0x83 -N bl2 -r -p 512k@512k \
45 ) \
46 -t 0xef -N fip -r -p 2M@2M \
47 -t 0x83 -N ubootenv -r -p 1M@4M \
48 -N recovery -r -p 32M@6M \
49 $(if $(findstring sdmmc,$1), \
50 -N install -r -p 7M@38M \
51 -t 0x2e -N production -p 211M@45M \
52 ) \
53 $(if $(findstring emmc,$1), \
54 -t 0x2e -N production -p 980M@40M \
55 )
56 cat $@.tmp >> $@
57 rm $@.tmp
58 endef
59
60 define Build/trx-nand
61 # kernel: always use 4 MiB (-28 B or TRX header) to allow upgrades even
62 # if it grows up between releases
63 # root: UBI with one extra block containing UBI mark to trigger erasing
64 # rest of partition
65 $(STAGING_DIR_HOST)/bin/otrx create $@.new \
66 -M 0x32504844 \
67 -f $(IMAGE_KERNEL) -a 0x20000 -b 0x400000 \
68 -f $@ \
69 -A $(KDIR)/ubi_mark -a 0x20000
70 mv $@.new $@
71 endef
72
73 define Device/bananapi_bpi-r64
74 DEVICE_VENDOR := Bananapi
75 DEVICE_MODEL := BPi-R64
76 DEVICE_DTS := mt7622-bananapi-bpi-r64
77 DEVICE_DTS_OVERLAY := mt7622-bananapi-bpi-r64-pcie1 mt7622-bananapi-bpi-r64-sata
78 DEVICE_PACKAGES := kmod-ata-ahci-mtk kmod-btmtkuart kmod-usb3 e2fsprogs mkf2fs f2fsck
79 ARTIFACTS := emmc-preloader.bin emmc-bl31-uboot.fip sdcard.img.gz snand-preloader.bin snand-bl31-uboot.fip
80 IMAGES := sysupgrade.itb
81 KERNEL_INITRAMFS_SUFFIX := -recovery.itb
82 ARTIFACT/emmc-preloader.bin := bl2 emmc-2ddr
83 ARTIFACT/emmc-bl31-uboot.fip := bl31-uboot bananapi_bpi-r64-emmc
84 ARTIFACT/snand-preloader.bin := bl2 snand-2ddr
85 ARTIFACT/snand-bl31-uboot.fip := bl31-uboot bananapi_bpi-r64-snand
86 ARTIFACT/sdcard.img.gz := mt7622-gpt sdmmc |\
87 pad-to 512k | bl2 sdmmc-2ddr |\
88 pad-to 2048k | bl31-uboot bananapi_bpi-r64-sdmmc |\
89 pad-to 6144k | append-image-stage initramfs-recovery.itb |\
90 pad-to 38912k | mt7622-gpt emmc |\
91 pad-to 39424k | bl2 emmc-2ddr |\
92 pad-to 40960k | bl31-uboot bananapi_bpi-r64-emmc |\
93 pad-to 43008k | bl2 snand-2ddr |\
94 pad-to 43520k | bl31-uboot bananapi_bpi-r64-snand |\
95 pad-to 46080k | append-image squashfs-sysupgrade.itb | gzip
96 KERNEL := kernel-bin | gzip
97 KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(DTS_DIR)/$$(DEVICE_DTS).dtb with-initrd | pad-to 128k
98 IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(DTS_DIR)/$$(DEVICE_DTS).dtb external-static-with-rootfs | append-metadata
99 endef
100 TARGET_DEVICES += bananapi_bpi-r64
101
102 define Device/buffalo_wsr-2533dhp2
103 DEVICE_VENDOR := Buffalo
104 DEVICE_MODEL := WSR-2533DHP2
105 DEVICE_DTS := mt7622-buffalo-wsr-2533dhp2
106 DEVICE_DTS_DIR := ../dts
107 IMAGE_SIZE := 59392k
108 KERNEL_SIZE := 4096k
109 BLOCKSIZE := 128k
110 PAGESIZE := 2048
111 SUBPAGESIZE := 512
112 UBINIZE_OPTS := -E 5
113 BUFFALO_TAG_PLATFORM := MTK
114 BUFFALO_TAG_VERSION := 9.99
115 BUFFALO_TAG_MINOR := 9.99
116 IMAGES += factory.bin factory-uboot.bin
117 KERNEL_INITRAMFS := kernel-bin | lzma | \
118 fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | \
119 buffalo-kernel-trx
120 IMAGE/factory.bin := append-ubi | trx-nand | \
121 buffalo-enc WSR-2533DHP2 $$(BUFFALO_TAG_VERSION) -l | \
122 buffalo-tag-dhp WSR-2533DHP2 JP JP | buffalo-enc-tag -l | buffalo-dhp-image
123 IMAGE/factory-uboot.bin := append-ubi | trx-nand
124 IMAGE/sysupgrade.bin := append-kernel | \
125 buffalo-kernel-trx 0x32504844 $(KDIR)/tmp/$$(DEVICE_NAME).null | \
126 sysupgrade-tar kernel=$$$$@ | append-metadata
127 DEVICE_PACKAGES := swconfig
128 endef
129 TARGET_DEVICES += buffalo_wsr-2533dhp2
130
131 define Device/elecom_wrc-2533gent
132 DEVICE_VENDOR := Elecom
133 DEVICE_MODEL := WRC-2533GENT
134 DEVICE_DTS := mt7622-elecom-wrc-2533gent
135 DEVICE_DTS_DIR := ../dts
136 DEVICE_PACKAGES := kmod-btmtkuart kmod-usb3 swconfig
137 endef
138 TARGET_DEVICES += elecom_wrc-2533gent
139
140 define Device/linksys_e8450
141 DEVICE_VENDOR := Linksys
142 DEVICE_MODEL := E8450
143 DEVICE_ALT0_VENDOR := Belkin
144 DEVICE_ALT0_MODEL := RT3200
145 DEVICE_DTS := mt7622-linksys-e8450
146 DEVICE_DTS_DIR := ../dts
147 DEVICE_PACKAGES := kmod-mt7915e kmod-usb3
148 endef
149 TARGET_DEVICES += linksys_e8450
150
151 define Device/linksys_e8450-ubi
152 DEVICE_VENDOR := Linksys
153 DEVICE_MODEL := E8450
154 DEVICE_VARIANT := UBI
155 DEVICE_ALT0_VENDOR := Belkin
156 DEVICE_ALT0_MODEL := RT3200
157 DEVICE_ALT0_VARIANT := UBI
158 DEVICE_DTS := mt7622-linksys-e8450-ubi
159 DEVICE_DTS_DIR := ../dts
160 DEVICE_PACKAGES := kmod-mt7915e kmod-usb3
161 UBINIZE_OPTS := -E 5
162 BLOCKSIZE := 128k
163 PAGESIZE := 2048
164 UBOOTENV_IN_UBI := 1
165 KERNEL_IN_UBI := 1
166 KERNEL := kernel-bin | gzip
167 # recovery can also be used with stock firmware web-ui, hence the padding...
168 KERNEL_INITRAMFS := kernel-bin | lzma | \
169 fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 128k
170 KERNEL_INITRAMFS_SUFFIX := -recovery.itb
171 IMAGES := sysupgrade.itb
172 IMAGE/sysupgrade.itb := append-kernel | fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
173 ARTIFACTS := preloader.bin bl31-uboot.fip
174 ARTIFACT/preloader.bin := bl2 snand-1ddr
175 ARTIFACT/bl31-uboot.fip := bl31-uboot linksys_e8450
176 endef
177 TARGET_DEVICES += linksys_e8450-ubi
178
179 define Device/mediatek_mt7622-rfb1
180 DEVICE_VENDOR := MediaTek
181 DEVICE_MODEL := MTK7622 rfb1 AP
182 DEVICE_DTS := mt7622-rfb1
183 DEVICE_PACKAGES := kmod-ata-ahci-mtk kmod-btmtkuart kmod-usb3
184 endef
185 TARGET_DEVICES += mediatek_mt7622-rfb1
186
187 define Device/mediatek_mt7622-rfb1-ubi
188 DEVICE_VENDOR := MediaTek
189 DEVICE_MODEL := MTK7622 rfb1 AP (UBI)
190 DEVICE_DTS := mt7622-rfb1-ubi
191 DEVICE_DTS_DIR := ../dts
192 DEVICE_PACKAGES := kmod-ata-ahci-mtk kmod-btmtkuart kmod-usb3
193 BOARD_NAME := mediatek,mt7622-rfb1-ubi
194 UBINIZE_OPTS := -E 5
195 BLOCKSIZE := 128k
196 PAGESIZE := 2048
197 KERNEL_SIZE := 4194304
198 IMAGE_SIZE := 32768k
199 IMAGES += factory.bin
200 IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
201 check-size $$$$(IMAGE_SIZE)
202 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
203 endef
204 TARGET_DEVICES += mediatek_mt7622-rfb1-ubi
205
206 define Device/totolink_a8000ru
207 DEVICE_VENDOR := TOTOLINK
208 DEVICE_MODEL := A8000RU
209 DEVICE_DTS := mt7622-totolink-a8000ru
210 DEVICE_DTS_DIR := ../dts
211 DEVICE_PACKAGES := swconfig
212 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
213 endef
214 TARGET_DEVICES += totolink_a8000ru
215
216 define Device/ubnt_unifi-6-lr
217 DEVICE_VENDOR := Ubiquiti
218 DEVICE_MODEL := UniFi 6 LR
219 DEVICE_DTS_CONFIG := config@1
220 DEVICE_DTS := mt7622-ubnt-unifi-6-lr
221 DEVICE_DTS_DIR := ../dts
222 DEVICE_PACKAGES := kmod-mt7915e
223 endef
224 TARGET_DEVICES += ubnt_unifi-6-lr
225
226 define Device/ubnt_unifi-6-lr-ubootmod
227 DEVICE_VENDOR := Ubiquiti
228 DEVICE_MODEL := UniFi 6 LR
229 DEVICE_VARIANT := U-Boot mod
230 DEVICE_DTS := mt7622-ubnt-unifi-6-lr-ubootmod
231 DEVICE_DTS_DIR := ../dts
232 DEVICE_PACKAGES := kmod-mt7915e
233 KERNEL := kernel-bin | lzma
234 KERNEL_INITRAMFS_SUFFIX := -recovery.itb
235 KERNEL_INITRAMFS := kernel-bin | lzma | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
236 IMAGES := sysupgrade.itb
237 IMAGE/sysupgrade.itb := append-kernel | fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | pad-rootfs | append-metadata
238 ARTIFACTS := preloader.bin bl31-uboot.fip
239 ARTIFACT/preloader.bin := bl2 nor-2ddr
240 ARTIFACT/bl31-uboot.fip := bl31-uboot ubnt_unifi-6-lr
241 endef
242 TARGET_DEVICES += ubnt_unifi-6-lr-ubootmod