Skip to content

Commit 3e5529f

Browse files
committed
mediatek: filogic: add support Wavlink WL-WNT100X3 ubootmod
This allows us to use the full size of nand, which increases ubi size from 90M to 122.25M. Flashing instructions: 1. Login into the device and backup all your partitions, especially 'Factory' and 'HW' to be able to come back to stock and use all Wavlink services. 1. Unlock mtd partitions: ``` apk update && apk add kmod-mtd-rw insmod mtd-rw i_want_a_brick=1 ``` 3. Upload new `bl2` and `fip` to the router /tmp and write them: ``` mtd write /tmp/openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-preloader.bin bl2 mtd write /tmp/openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-bl31-uboot.fip fip mtd erase ubi ``` 4. Set static IP on your PC: IP 192.168.1.254/24, GW 192.168.1.1 5. Serve OpenWrt initramfs image using TFTP server. 6. Cut off the power and re-engage, wait for TFTP recovery to complete. 7. After OpenWrt initramfs has booted, prepare ubi and envs: ``` ubidetach -p /dev/mtd4 && ubiformat /dev/mtd4 -y && ubiattach -p /dev/mtd4 && ubimkvol /dev/ubi0 -n 0 -N ubootenv -s 128KiB && ubimkvol /dev/ubi0 -n 1 -N ubootenv2 -s 128KiB ``` 8. Perform sysupgrade. Signed-off-by: Fil Dunsky <filipp.dunsky@gmail.com>
1 parent 04c67aa commit 3e5529f

7 files changed

Lines changed: 436 additions & 1 deletion

File tree

package/boot/uboot-mediatek/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,18 @@ define U-Boot/mt7981_snr_snr-cpe-ax2
651651
DEPENDS:=+trusted-firmware-a-mt7981-spim-nand-ddr3
652652
endef
653653

654+
define U-Boot/mt7981_wavlink_wl-wnt100x3
655+
NAME:=WAVLINK WL-WNT100x3
656+
BUILD_SUBTARGET:=filogic
657+
BUILD_DEVICES:=wavlink_wl-wnt100x3-ubootmod
658+
UBOOT_CONFIG:=mt7981_wavlink_wl-wnt100x3
659+
UBOOT_IMAGE:=u-boot.fip
660+
BL2_BOOTDEV:=spim-nand
661+
BL2_SOC:=mt7981
662+
BL2_DDRTYPE:=ddr3
663+
DEPENDS:=+trusted-firmware-a-mt7981-spim-nand-ddr3
664+
endef
665+
654666
define U-Boot/mt7981_xiaomi_mi-router-ax3000t
655667
NAME:=Xiaomi Router AX3000T
656668
BUILD_SUBTARGET:=filogic
@@ -1225,6 +1237,7 @@ UBOOT_TARGETS := \
12251237
mt7981_routerich_ax3000 \
12261238
mt7981_qihoo_360t7 \
12271239
mt7981_snr_snr-cpe-ax2 \
1240+
mt7981_wavlink_wl-wnt100x3 \
12281241
mt7981_xiaomi_mi-router-ax3000t \
12291242
mt7981_xiaomi_mi-router-wr30u \
12301243
mt7986_acer_predator-w6x \
Lines changed: 319 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,319 @@
1+
--- /dev/null
2+
+++ b/configs/mt7981_wavlink_wl-wnt100x3_defconfig
3+
@@ -0,0 +1,108 @@
4+
+CONFIG_ARM=y
5+
+CONFIG_SYS_HAS_NONCACHED_MEMORY=y
6+
+CONFIG_POSITION_INDEPENDENT=y
7+
+CONFIG_ARCH_MEDIATEK=y
8+
+CONFIG_TEXT_BASE=0x41e00000
9+
+CONFIG_SYS_MALLOC_F_LEN=0x4000
10+
+CONFIG_NR_DRAM_BANKS=1
11+
+CONFIG_DEFAULT_DEVICE_TREE="mt7981-wavlink_wl-wnt100x3"
12+
+CONFIG_OF_LIBFDT_OVERLAY=y
13+
+CONFIG_TARGET_MT7981=y
14+
+CONFIG_SYS_LOAD_ADDR=0x46000000
15+
+CONFIG_PRE_CON_BUF_ADDR=0x4007ef00
16+
+CONFIG_DEBUG_UART_BASE=0x11002000
17+
+CONFIG_DEBUG_UART_CLOCK=40000000
18+
+CONFIG_DEBUG_UART=y
19+
+CONFIG_FIT=y
20+
+CONFIG_BOOTDELAY=30
21+
+CONFIG_AUTOBOOT_KEYED=y
22+
+CONFIG_AUTOBOOT_MENU_SHOW=y
23+
+CONFIG_DEFAULT_FDT_FILE="mediatek/mt7981-wavlink_wl-wnt100x3.dtb"
24+
+CONFIG_LOGLEVEL=7
25+
+CONFIG_PRE_CONSOLE_BUFFER=y
26+
+CONFIG_LOG=y
27+
+# CONFIG_BOARD_INIT is not set
28+
+CONFIG_BOARD_LATE_INIT=y
29+
+CONFIG_HUSH_PARSER=y
30+
+CONFIG_SYS_PROMPT="MT7981> "
31+
+CONFIG_CMD_CPU=y
32+
+CONFIG_CMD_LICENSE=y
33+
+CONFIG_CMD_BOOTMENU=y
34+
+CONFIG_CMD_ASKENV=y
35+
+CONFIG_CMD_ERASEENV=y
36+
+CONFIG_CMD_ENV_FLAGS=y
37+
+CONFIG_CMD_STRINGS=y
38+
+CONFIG_CMD_DM=y
39+
+CONFIG_CMD_GPIO=y
40+
+CONFIG_CMD_GPT=y
41+
+CONFIG_CMD_MTD=y
42+
+CONFIG_CMD_PART=y
43+
+CONFIG_CMD_TFTPSRV=y
44+
+CONFIG_CMD_RARP=y
45+
+CONFIG_CMD_CDP=y
46+
+CONFIG_CMD_SNTP=y
47+
+CONFIG_CMD_LINK_LOCAL=y
48+
+CONFIG_CMD_DHCP=y
49+
+CONFIG_CMD_DNS=y
50+
+CONFIG_CMD_PING=y
51+
+CONFIG_CMD_PXE=y
52+
+CONFIG_CMD_CACHE=y
53+
+CONFIG_CMD_PSTORE=y
54+
+CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
55+
+CONFIG_CMD_UUID=y
56+
+CONFIG_CMD_HASH=y
57+
+CONFIG_CMD_SMC=y
58+
+CONFIG_CMD_UBI=y
59+
+CONFIG_CMD_UBI_RENAME=y
60+
+CONFIG_OF_EMBED=y
61+
+CONFIG_ENV_OVERWRITE=y
62+
+CONFIG_ENV_IS_IN_UBI=y
63+
+CONFIG_ENV_REDUNDANT=y
64+
+CONFIG_ENV_UBI_PART="ubi"
65+
+CONFIG_ENV_UBI_VOLUME="ubootenv"
66+
+CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
67+
+CONFIG_ENV_RELOC_GD_ENV_ADDR=y
68+
+CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y
69+
+CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="defenvs/wavlink_wl-wnt100x3_env"
70+
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
71+
+CONFIG_VERSION_VARIABLE=y
72+
+CONFIG_NETCONSOLE=y
73+
+CONFIG_USE_IPADDR=y
74+
+CONFIG_IPADDR="192.168.1.1"
75+
+CONFIG_USE_SERVERIP=y
76+
+CONFIG_SERVERIP="192.168.1.254"
77+
+CONFIG_NET_RANDOM_ETHADDR=y
78+
+CONFIG_REGMAP=y
79+
+CONFIG_SYSCON=y
80+
+CONFIG_BUTTON=y
81+
+CONFIG_BUTTON_GPIO=y
82+
+CONFIG_CLK=y
83+
+CONFIG_GPIO_HOG=y
84+
+CONFIG_LED=y
85+
+CONFIG_LED_BLINK=y
86+
+CONFIG_LED_GPIO=y
87+
+# CONFIG_MMC is not set
88+
+CONFIG_MTD=y
89+
+CONFIG_DM_MTD=y
90+
+CONFIG_MTD_SPI_NAND=y
91+
+CONFIG_MTD_UBI_FASTMAP=y
92+
+CONFIG_PHY_FIXED=y
93+
+CONFIG_MEDIATEK_ETH=y
94+
+CONFIG_PHY=y
95+
+CONFIG_PINCTRL=y
96+
+CONFIG_PINCONF=y
97+
+CONFIG_PINCTRL_MT7981=y
98+
+CONFIG_POWER_DOMAIN=y
99+
+CONFIG_MTK_POWER_DOMAIN=y
100+
+CONFIG_DM_REGULATOR=y
101+
+CONFIG_DM_REGULATOR_FIXED=y
102+
+CONFIG_DM_REGULATOR_GPIO=y
103+
+CONFIG_RAM=y
104+
+CONFIG_DM_SERIAL=y
105+
+CONFIG_SERIAL_RX_BUFFER=y
106+
+CONFIG_MTK_SERIAL=y
107+
+CONFIG_SPI=y
108+
+CONFIG_DM_SPI=y
109+
+CONFIG_MTK_SPIM=y
110+
+CONFIG_ZSTD=y
111+
+CONFIG_HEXDUMP=y
112+
--- /dev/null
113+
+++ b/arch/arm/dts/mt7981-wavlink_wl-wnt100x3.dts
114+
@@ -0,0 +1,148 @@
115+
+// SPDX-License-Identifier: GPL-2.0-or-later
116+
+
117+
+/dts-v1/;
118+
+#include "mt7981.dtsi"
119+
+#include <dt-bindings/gpio/gpio.h>
120+
+#include <dt-bindings/input/linux-event-codes.h>
121+
+
122+
+/ {
123+
+ #address-cells = <1>;
124+
+ #size-cells = <1>;
125+
+ model = "WAVLINK WL-WNT100X3";
126+
+ compatible = "mediatek,mt7981", "mediatek,mt7981-rfb";
127+
+
128+
+ chosen {
129+
+ stdout-path = &uart0;
130+
+ tick-timer = &timer0;
131+
+ };
132+
+
133+
+ memory@40000000 {
134+
+ device_type = "memory";
135+
+ reg = <0x40000000 0x20000000>;
136+
+ };
137+
+
138+
+ gpio-keys {
139+
+ compatible = "gpio-keys";
140+
+
141+
+ button-reset {
142+
+ label = "reset";
143+
+ linux,code = <KEY_RESTART>;
144+
+ gpios = <&pio 11 GPIO_ACTIVE_LOW>;
145+
+ };
146+
+
147+
+ button-mode {
148+
+ label = "mode";
149+
+ linux,code = <EV_SW>;
150+
+ linux,input-type = <BTN_0>;
151+
+ gpios = <&pio 25 GPIO_ACTIVE_LOW>;
152+
+ debounce-interval = <60>;
153+
+ };
154+
+ };
155+
+
156+
+ gpio-leds {
157+
+ compatible = "gpio-leds";
158+
+
159+
+ led_status: led-0 {
160+
+ label = "blue:status";
161+
+ gpios = <&pio 13 GPIO_ACTIVE_LOW>;
162+
+ };
163+
+ };
164+
+};
165+
+
166+
+&uart0 {
167+
+ mediatek,force-highspeed;
168+
+ status = "okay";
169+
+};
170+
+
171+
+&eth {
172+
+ status = "okay";
173+
+ mediatek,gmac-id = <1>;
174+
+ phy-mode = "gmii";
175+
+ phy-handle = <&phy0>;
176+
+
177+
+ mdio {
178+
+ phy0: ethernet-phy@0 {
179+
+ compatible = "ethernet-phy-id03a2.9461";
180+
+ reg = <0x0>;
181+
+ phy-mode = "gmii";
182+
+ };
183+
+ };
184+
+};
185+
+
186+
+&pio {
187+
+ spi_flash_pins: spi0-pins-func-1 {
188+
+ mux {
189+
+ function = "flash";
190+
+ groups = "spi0", "spi0_wp_hold";
191+
+ };
192+
+
193+
+ conf-pu {
194+
+ pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
195+
+ drive-strength = <MTK_DRIVE_8mA>;
196+
+ bias-pull-up = <MTK_PUPD_SET_R1R0_00>;
197+
+ };
198+
+
199+
+ conf-pd {
200+
+ pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
201+
+ drive-strength = <MTK_DRIVE_8mA>;
202+
+ bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
203+
+ };
204+
+ };
205+
+};
206+
+
207+
+&spi0 {
208+
+ #address-cells = <1>;
209+
+ #size-cells = <0>;
210+
+ pinctrl-names = "default";
211+
+ pinctrl-0 = <&spi_flash_pins>;
212+
+ status = "okay";
213+
+ must_tx;
214+
+ enhance_timing;
215+
+ dma_ext;
216+
+ ipm_design;
217+
+ support_quad;
218+
+ tick_dly = <2>;
219+
+ sample_sel = <0>;
220+
+
221+
+ spi_nand@0 {
222+
+ compatible = "spi-nand";
223+
+ reg = <0>;
224+
+ spi-max-frequency = <52000000>;
225+
+
226+
+ partitions {
227+
+ compatible = "fixed-partitions";
228+
+ #address-cells = <1>;
229+
+ #size-cells = <1>;
230+
+
231+
+ partition@0 {
232+
+ label = "bl2";
233+
+ reg = <0x0 0x100000>;
234+
+ };
235+
+
236+
+ partition@100000 {
237+
+ label = "u-boot-env";
238+
+ reg = <0x100000 0x80000>;
239+
+ };
240+
+
241+
+ partition@180000 {
242+
+ label = "factory";
243+
+ reg = <0x180000 0x200000>;
244+
+ };
245+
+
246+
+ partition@380000 {
247+
+ label = "fip";
248+
+ reg = <0x380000 0x200000>;
249+
+ };
250+
+
251+
+ partition@580000 {
252+
+ label = "ubi";
253+
+ reg = <0x580000 0x7a80000>;
254+
+ compatible = "linux,ubi";
255+
+ };
256+
+ };
257+
+ };
258+
+};
259+
+
260+
+&watchdog {
261+
+ status = "disabled";
262+
+};
263+
--- /dev/null
264+
+++ b/defenvs/wavlink_wl-wnt100x3_env
265+
@@ -0,0 +1,53 @@
266+
+ipaddr=192.168.1.1
267+
+serverip=192.168.1.254
268+
+loadaddr=0x46000000
269+
+console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
270+
+bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
271+
+bootconf=config-1
272+
+bootdelay=0
273+
+bootfile=openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-initramfs-recovery.itb
274+
+bootfile_bl2=openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-preloader.bin
275+
+bootfile_fip=openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-bl31-uboot.fip
276+
+bootfile_upg=openwrt-mediatek-filogic-wavlink_wl-wnt100x3-ubootmod-squashfs-sysupgrade.itb
277+
+bootled_pwr=blue:status
278+
+bootled_rec=blue:status
279+
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
280+
+bootmenu_default=0
281+
+bootmenu_delay=0
282+
+bootmenu_title= ␛[0;34m( ( ( ␛[1;39mOpenWrt␛[0;34m ) ) )
283+
+bootmenu_0=Initialize environment.=run _firstboot
284+
+bootmenu_0d=Run default boot command.=run boot_default
285+
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
286+
+bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
287+
+bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
288+
+bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
289+
+bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
290+
+bootmenu_6=␛[31mLoad BL31+U-Boot FIP via TFTP then write to NAND.␛[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
291+
+bootmenu_7=␛[31mLoad BL2 preloader via TFTP then write to NAND.␛[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
292+
+bootmenu_8=Reboot.=reset
293+
+bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
294+
+boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
295+
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
296+
+boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off
297+
+boot_recovery=led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off
298+
+boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
299+
+boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done
300+
+boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
301+
+boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
302+
+boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
303+
+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory
304+
+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
305+
+reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
306+
+mtd_write_fip=mtd erase fip && mtd write fip $loadaddr
307+
+mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
308+
+ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic || run ubi_format ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic || run ubi_format
309+
+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
310+
+ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
311+
+ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
312+
+ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
313+
+ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
314+
+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
315+
+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
316+
+_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
317+
+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first
318+
+_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
319+
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title ␛[33m$ver␛[0m"

package/boot/uboot-tools/uboot-envtools/files/mediatek_filogic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ qihoo,360t7|\
4949
routerich,ax3000-ubootmod|\
5050
routerich,be7200|\
5151
snr,snr-cpe-ax2|\
52+
wavlink,wl-wnt100x3-ubootmod|\
5253
tplink,tl-xdr4288|\
5354
tplink,tl-xdr6086|\
5455
tplink,tl-xdr6088|\

0 commit comments

Comments
 (0)