Skip to content

Commit 15df98f

Browse files
fildunskyhauke
authored andcommitted
mediatek: add ubootmod layout for Cudy WBR3000UAX v1
This allows us to use the full size of nand, which extends ubi size from 64Mb to 122.25Mb. If you are at factory firmware, please refer to [PR](openwrt/openwrt#21141) to boot into OpenWrt first. 1. Log in to the device and backup all the partitions, especially unique `Factory` and `bdata` partitions from System -> Backup / Flash Firmware -> Save mtdblock contents. 2. Install kmod-mtd-rw to unlock mtd partitions for writing: ```bash apk update && apk add kmod-mtd-rw && insmod mtd-rw i_want_a_brick=1 ``` 3. Write new OpenWrt (U-Boot Layout) `BL2` and `FIP`: ```bash mtd write openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-preloader.bin BL2 mtd write openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-bl31-uboot.fip FIP ``` 4. Set static IP on your PC: `192.168.1.254`, gateway `192.168.1.1` 5. Serve openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-initramfs-recovery.itb using TFTP server. 6. Connect Router LAN with PC LAN. 7. Cut off the power and re-engage, wait for TFTP recovery to complete. 8. After OpenWrt initramfs recovery has booted, clean `/dev/mtd5` ubi partition to utilize maximum of free space & create ubootenvs: ```bash ubidetach -p /dev/mtd5; ubiformat /dev/mtd5 -y; ubiattach -p /dev/mtd5 ubimkvol /dev/ubi0 -n 0 -N ubootenv -s 128KiB ubimkvol /dev/ubi0 -n 1 -N ubootenv2 -s 128KiB ``` 4. Perform sysupgrade. Tested-by: 4pda users Signed-off-by: Fil Dunsky <[email protected]> Link: openwrt/openwrt#21225 Signed-off-by: Hauke Mehrtens <[email protected]>
1 parent d7d6faf commit 15df98f

File tree

8 files changed

+422
-1
lines changed

8 files changed

+422
-1
lines changed

package/boot/uboot-mediatek/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,17 @@ define U-Boot/mt7981_cudy_tr3000-v1
314314
DEPENDS:=+trusted-firmware-a-mt7981-cudy-ddr3
315315
endef
316316

317+
define U-Boot/mt7981_cudy_wbr3000uax-v1
318+
NAME:=Cudy WBR3000UAX v1
319+
BUILD_SUBTARGET:=filogic
320+
BUILD_DEVICES:=cudy_wbr3000uax-v1-ubootmod
321+
UBOOT_CONFIG:=mt7981_cudy_wbr3000uax-v1
322+
UBOOT_IMAGE:=u-boot.fip
323+
BL2_BOOTDEV:=cudy-ddr3
324+
BL2_SOC:=mt7981
325+
DEPENDS:=+trusted-firmware-a-mt7981-cudy-ddr3
326+
endef
327+
317328
define U-Boot/mt7981_glinet_gl-mt2500
318329
NAME:=GL.iNet GL-MT2500
319330
BUILD_SUBTARGET:=filogic
@@ -1091,6 +1102,7 @@ UBOOT_TARGETS := \
10911102
mt7981_cmcc_rax3000m-nand-ddr4 \
10921103
mt7981_comfast_cf-wr632ax \
10931104
mt7981_cudy_tr3000-v1 \
1105+
mt7981_cudy_wbr3000uax-v1 \
10941106
mt7981_gatonetworks_gdsp \
10951107
mt7981_glinet_gl-mt2500 \
10961108
mt7981_glinet_gl-x3000 \
Lines changed: 355 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,355 @@
1+
--- /dev/null
2+
+++ b/configs/mt7981_cudy_wbr3000uax-v1_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-cudy-wbr3000uax-v1"
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-cudy-wbr3000uax-v1.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/cudy_wbr3000uax-v1_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-cudy-wbr3000uax-v1.dts
114+
@@ -0,0 +1,184 @@
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 = "Cudy WBR3000UAX v1";
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 1 GPIO_ACTIVE_LOW>;
145+
+ };
146+
+
147+
+ button-wps {
148+
+ label = "wps";
149+
+ linux,code = <KEY_WPS_BUTTON>;
150+
+ gpios = <&pio 0 GPIO_ACTIVE_LOW>;
151+
+ };
152+
+ };
153+
+
154+
+ gpio-leds {
155+
+ compatible = "gpio-leds";
156+
+
157+
+ led_status: led_power {
158+
+ label = "blue:power";
159+
+ gpios = <&pio 8 GPIO_ACTIVE_LOW>;
160+
+ };
161+
+
162+
+ led_wan_blue {
163+
+ label = "blue:wan";
164+
+ gpios = <&pio 10 GPIO_ACTIVE_LOW>;
165+
+ };
166+
+
167+
+ led_wan_red {
168+
+ label = "red:wan";
169+
+ gpios = <&pio 4 GPIO_ACTIVE_LOW>;
170+
+ };
171+
+
172+
+ led_lan {
173+
+ label = "blue:lan";
174+
+ gpios = <&pio 11 GPIO_ACTIVE_LOW>;
175+
+ };
176+
+
177+
+ led_wps_blue {
178+
+ label = "blue:wps";
179+
+ gpios = <&pio 9 GPIO_ACTIVE_LOW>;
180+
+ };
181+
+
182+
+ led_wps_red {
183+
+ label = "red:wps";
184+
+ gpios = <&pio 5 GPIO_ACTIVE_LOW>;
185+
+ };
186+
+
187+
+ led_wifi2g {
188+
+ label = "blue:wifi2g";
189+
+ gpios = <&pio 6 GPIO_ACTIVE_LOW>;
190+
+ };
191+
+
192+
+ led_wifi5g {
193+
+ label = "blue:wifi5g";
194+
+ gpios = <&pio 7 GPIO_ACTIVE_LOW>;
195+
+ };
196+
+ };
197+
+};
198+
+
199+
+&eth {
200+
+ status = "okay";
201+
+ mediatek,gmac-id = <0>;
202+
+ phy-mode = "2500base-x";
203+
+ mediatek,switch = "mt7531";
204+
+ reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>;
205+
+
206+
+ fixed-link {
207+
+ speed = <2500>;
208+
+ full-duplex;
209+
+ };
210+
+};
211+
+
212+
+&pio {
213+
+ spi_flash_pins: spi0-pins-func-1 {
214+
+ mux {
215+
+ function = "flash";
216+
+ groups = "spi0", "spi0_wp_hold";
217+
+ };
218+
+
219+
+ conf-pu {
220+
+ pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
221+
+ drive-strength = <MTK_DRIVE_8mA>;
222+
+ bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
223+
+ };
224+
+
225+
+ conf-pd {
226+
+ pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
227+
+ drive-strength = <MTK_DRIVE_8mA>;
228+
+ bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
229+
+ };
230+
+ };
231+
+};
232+
+
233+
+&spi0 {
234+
+ #address-cells = <1>;
235+
+ #size-cells = <0>;
236+
+ pinctrl-names = "default";
237+
+ pinctrl-0 = <&spi_flash_pins>;
238+
+ status = "okay";
239+
+ must_tx;
240+
+ enhance_timing;
241+
+ dma_ext;
242+
+ ipm_design;
243+
+ support_quad;
244+
+ tick_dly = <2>;
245+
+ sample_sel = <0>;
246+
+
247+
+ spi_nand@0 {
248+
+ compatible = "spi-nand";
249+
+ reg = <0>;
250+
+ spi-max-frequency = <52000000>;
251+
+
252+
+ partitions {
253+
+ compatible = "fixed-partitions";
254+
+ #address-cells = <1>;
255+
+ #size-cells = <1>;
256+
+
257+
+ partition@0 {
258+
+ label = "bl2";
259+
+ reg = <0x0 0x100000>;
260+
+ };
261+
+
262+
+ partition@100000 {
263+
+ label = "u-boot-env";
264+
+ reg = <0x100000 0x80000>;
265+
+ };
266+
+
267+
+ partition@180000 {
268+
+ label = "factory";
269+
+ reg = <0x180000 0x200000>;
270+
+ };
271+
+
272+
+ partition@380000 {
273+
+ label = "bdinfo";
274+
+ reg = <0x380000 0x40000>;
275+
+ };
276+
+
277+
+ partition@3c0000 {
278+
+ label = "fip";
279+
+ reg = <0x3c0000 0x200000>;
280+
+ };
281+
+
282+
+ partition@5c0000 {
283+
+ label = "ubi";
284+
+ reg = <0x5c0000 0x7a40000>;
285+
+ compatible = "linux,ubi";
286+
+ };
287+
+ };
288+
+ };
289+
+};
290+
+
291+
+&uart0 {
292+
+ mediatek,force-highspeed;
293+
+ status = "okay";
294+
+};
295+
+
296+
+&watchdog {
297+
+ status = "disabled";
298+
+};
299+
--- /dev/null
300+
+++ b/defenvs/cudy_wbr3000uax-v1_env
301+
@@ -0,0 +1,54 @@
302+
+ipaddr=192.168.1.1
303+
+serverip=192.168.1.254
304+
+loadaddr=0x46000000
305+
+console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
306+
+bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi
307+
+bootconf=config-1
308+
+bootdelay=0
309+
+bootfile=openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-initramfs-recovery.itb
310+
+bootfile_bl2=openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-preloader.bin
311+
+bootfile_fip=openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-bl31-uboot.fip
312+
+bootfile_upg=openwrt-mediatek-filogic-cudy_wbr3000uax-v1-ubootmod-squashfs-sysupgrade.itb
313+
+bootled_pwr=blue:power
314+
+bootled_rec=red:wan
315+
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
316+
+bootmenu_default=0
317+
+bootmenu_delay=0
318+
+bootmenu_title= ( ( ( OpenWrt ) ) )
319+
+bootmenu_0=Initialize environment.=run _firstboot
320+
+bootmenu_0d=Run default boot command.=run boot_default
321+
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
322+
+bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
323+
+bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
324+
+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
325+
+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
326+
+bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return
327+
+bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
328+
+bootmenu_8=Reboot.=reset
329+
+bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
330+
+boot_first=if button reset ; then led $bootled_rec on ; run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
331+
+boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever
332+
+boot_production=led $bootled_pwr on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_pwr off
333+
+boot_recovery=led $bootled_rec on ; run ubi_read_recovery && bootm $loadaddr#$bootconf ; led $bootled_rec off
334+
+boot_ubi=run boot_production ; run boot_recovery ; run boot_tftp_forever
335+
+boot_tftp_forever=led $bootled_rec on ; while true ; do run boot_tftp_recovery ; sleep 1 ; done
336+
+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
337+
+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
338+
+boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
339+
+boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run mtd_write_fip && run reset_factory
340+
+boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run mtd_write_bl2
341+
+reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
342+
+mtd_write_fip=mtd erase fip && mtd write fip $loadaddr
343+
+mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
344+
+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
345+
+ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
346+
+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
347+
+ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
348+
+ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
349+
+ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
350+
+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
351+
+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
352+
+_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
353+
+_firstboot=setenv _firstboot ; run _switch_to_menu ; run _init_env ; run boot_first
354+
+_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
355+
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ asus,zenwifi-bt8-ubootmod|\
2828
cmcc,a10-ubootmod|\
2929
comfast,cf-wr632ax-ubootmod|\
3030
cudy,tr3000-v1-ubootmod|\
31+
cudy,wbr3000uax-v1-ubootmod|\
3132
h3c,magic-nx30-pro|\
3233
imou,hx21|\
3334
jcg,q30-pro|\

0 commit comments

Comments
 (0)