Skip to content

Commit 77cc4b7

Browse files
csharper2005hauke
authored andcommitted
uboot-mediatek: add MERCUSYS MR90X v1 support
Add U-Boot replacement loader for the MERCUSYS MR90X. This is required to increase available flash space in OpenWrt. Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com> Link: openwrt/openwrt#16744 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent 2ea9ede commit 77cc4b7

File tree

2 files changed

+356
-0
lines changed

2 files changed

+356
-0
lines changed

package/boot/uboot-mediatek/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,18 @@ define U-Boot/mt7986_jdcloud_re-cp-03
570570
DEPENDS:=+trusted-firmware-a-mt7986-emmc-ddr4
571571
endef
572572

573+
define U-Boot/mt7986_mercusys_mr90x-v1
574+
NAME:=MERCUSYS MR90X v1
575+
BUILD_SUBTARGET:=filogic
576+
BUILD_DEVICES:=mercusys_mr90x-v1-ubi
577+
UBOOT_CONFIG:=mt7986_mercusys_mr90x-v1
578+
UBOOT_IMAGE:=u-boot.fip
579+
BL2_BOOTDEV:=spim-nand-ubi
580+
BL2_SOC:=mt7986
581+
BL2_DDRTYPE:=ddr3
582+
DEPENDS:=+trusted-firmware-a-mt7986-spim-nand-ubi-ddr3
583+
endef
584+
573585
define U-Boot/mt7986_netcore_n60
574586
NAME:=Netcore N60
575587
BUILD_SUBTARGET:=filogic
@@ -847,6 +859,7 @@ UBOOT_TARGETS := \
847859
mt7986_bananapi_bpi-r3-mini-snand \
848860
mt7986_glinet_gl-mt6000 \
849861
mt7986_jdcloud_re-cp-03 \
862+
mt7986_mercusys_mr90x-v1 \
850863
mt7986_netcore_n60 \
851864
mt7986_tplink_tl-xdr4288 \
852865
mt7986_tplink_tl-xdr6086 \
Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
--- /dev/null
2+
+++ b/configs/mt7986_mercusys_mr90x-v1_defconfig
3+
@@ -0,0 +1,107 @@
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="mt7986b-mercusys_mr90x-v1"
12+
+CONFIG_OF_LIBFDT_OVERLAY=y
13+
+CONFIG_TARGET_MT7986=y
14+
+CONFIG_PRE_CON_BUF_ADDR=0x4007ef00
15+
+CONFIG_DEBUG_UART_BASE=0x11002000
16+
+CONFIG_DEBUG_UART_CLOCK=40000000
17+
+CONFIG_SYS_LOAD_ADDR=0x46000000
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/mt7986b-mercusys_mr90x-v1.dtb"
24+
+CONFIG_LOGLEVEL=7
25+
+CONFIG_PRE_CONSOLE_BUFFER=y
26+
+CONFIG_LOG=y
27+
+CONFIG_BOARD_LATE_INIT=y
28+
+CONFIG_HUSH_PARSER=y
29+
+CONFIG_SYS_PROMPT="MT7986> "
30+
+CONFIG_CMD_CPU=y
31+
+CONFIG_CMD_LICENSE=y
32+
+CONFIG_CMD_BOOTMENU=y
33+
+CONFIG_CMD_ASKENV=y
34+
+CONFIG_CMD_ERASEENV=y
35+
+CONFIG_CMD_ENV_FLAGS=y
36+
+CONFIG_CMD_STRINGS=y
37+
+CONFIG_CMD_DM=y
38+
+CONFIG_CMD_GPIO=y
39+
+CONFIG_CMD_MTD=y
40+
+CONFIG_CMD_DHCP=y
41+
+CONFIG_CMD_TFTPSRV=y
42+
+CONFIG_CMD_RARP=y
43+
+CONFIG_CMD_PING=y
44+
+CONFIG_CMD_CDP=y
45+
+CONFIG_CMD_SNTP=y
46+
+CONFIG_CMD_DNS=y
47+
+CONFIG_CMD_LINK_LOCAL=y
48+
+CONFIG_CMD_PXE=y
49+
+CONFIG_CMD_CACHE=y
50+
+CONFIG_CMD_PSTORE=y
51+
+CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
52+
+CONFIG_CMD_UUID=y
53+
+CONFIG_CMD_HASH=y
54+
+CONFIG_CMD_SMC=y
55+
+CONFIG_CMD_UBI=y
56+
+CONFIG_CMD_UBI_RENAME=y
57+
+CONFIG_OF_EMBED=y
58+
+CONFIG_ENV_OVERWRITE=y
59+
+CONFIG_ENV_IS_IN_UBI=y
60+
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
61+
+CONFIG_ENV_UBI_PART="ubi"
62+
+CONFIG_ENV_UBI_VOLUME="ubootenv"
63+
+CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
64+
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
65+
+CONFIG_USE_DEFAULT_ENV_FILE=y
66+
+CONFIG_DEFAULT_ENV_FILE="mercusys_mr90x-v1_env"
67+
+CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
68+
+CONFIG_VERSION_VARIABLE=y
69+
+CONFIG_NET_RANDOM_ETHADDR=y
70+
+CONFIG_NETCONSOLE=y
71+
+CONFIG_USE_IPADDR=y
72+
+CONFIG_IPADDR="192.168.1.1"
73+
+CONFIG_USE_SERVERIP=y
74+
+CONFIG_SERVERIP="192.168.1.254"
75+
+CONFIG_REGMAP=y
76+
+CONFIG_SYSCON=y
77+
+CONFIG_BUTTON=y
78+
+CONFIG_BUTTON_GPIO=y
79+
+CONFIG_CLK=y
80+
+CONFIG_GPIO_HOG=y
81+
+# CONFIG_I2C is not set
82+
+# CONFIG_MMC is not set
83+
+CONFIG_LED=y
84+
+CONFIG_LED_BLINK=y
85+
+CONFIG_LED_GPIO=y
86+
+CONFIG_MTD=y
87+
+CONFIG_DM_MTD=y
88+
+CONFIG_MTD_SPI_NAND=y
89+
+CONFIG_MTD_UBI_FASTMAP=y
90+
+CONFIG_PHY_FIXED=y
91+
+CONFIG_MEDIATEK_ETH=y
92+
+CONFIG_PHY=y
93+
+CONFIG_PINCTRL=y
94+
+CONFIG_PINCONF=y
95+
+CONFIG_PINCTRL_MT7986=y
96+
+CONFIG_POWER_DOMAIN=y
97+
+CONFIG_MTK_POWER_DOMAIN=y
98+
+CONFIG_DM_REGULATOR=y
99+
+CONFIG_DM_REGULATOR_FIXED=y
100+
+CONFIG_DM_REGULATOR_GPIO=y
101+
+CONFIG_RAM=y
102+
+CONFIG_DM_SERIAL=y
103+
+CONFIG_MTK_SERIAL=y
104+
+CONFIG_SPI=y
105+
+CONFIG_DM_SPI=y
106+
+CONFIG_MTK_SPIM=y
107+
+CONFIG_RANDOM_UUID=y
108+
+CONFIG_ZSTD=y
109+
+CONFIG_HEXDUMP=y
110+
+CONFIG_LMB_MAX_REGIONS=64
111+
--- /dev/null
112+
+++ b/arch/arm/dts/mt7986b-mercusys_mr90x-v1.dts
113+
@@ -0,0 +1,174 @@
114+
+// SPDX-License-Identifier: GPL-2.0
115+
+/*
116+
+ * Copyright (c) 2024
117+
+ * Author: Mikhail Zhilkin <csharper2005@gmail.com>
118+
+ */
119+
+
120+
+/dts-v1/;
121+
+#include "mt7986.dtsi"
122+
+#include <dt-bindings/gpio/gpio.h>
123+
+#include <dt-bindings/input/linux-event-codes.h>
124+
+
125+
+/ {
126+
+ #address-cells = <1>;
127+
+ #size-cells = <1>;
128+
+ model = "MERCUSYS MR90X v1";
129+
+ compatible = "mediatek,mt7986", "mediatek,mt7986-rfb";
130+
+
131+
+ chosen {
132+
+ stdout-path = &uart0;
133+
+ tick-timer = &timer0;
134+
+ };
135+
+
136+
+ memory@40000000 {
137+
+ device_type = "memory";
138+
+ reg = <0x40000000 0x20000000>;
139+
+ };
140+
+
141+
+ keys {
142+
+ compatible = "gpio-keys";
143+
+
144+
+ reset {
145+
+ label = "reset";
146+
+ linux,code = <KEY_RESTART>;
147+
+ gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
148+
+ };
149+
+ };
150+
+
151+
+ leds {
152+
+ compatible = "gpio-leds";
153+
+
154+
+ led-0 {
155+
+ label = "green:lan2";
156+
+ gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
157+
+ };
158+
+
159+
+ led-1 {
160+
+ label = "green:lan1";
161+
+ gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
162+
+ };
163+
+
164+
+ led-2 {
165+
+ label = "green:lan0";
166+
+ gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
167+
+ };
168+
+
169+
+ led-3 {
170+
+ label = "green:wan";
171+
+ gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
172+
+ };
173+
+
174+
+ led-4 {
175+
+ label = "amber:status";
176+
+ gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
177+
+ };
178+
+
179+
+ led_status_green: led-5 {
180+
+ label = "green:status";
181+
+ gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
182+
+ };
183+
+ };
184+
+};
185+
+
186+
+&uart0 {
187+
+ status = "okay";
188+
+};
189+
+
190+
+&uart1 {
191+
+ pinctrl-names = "default";
192+
+ pinctrl-0 = <&uart1_pins>;
193+
+ status = "disabled";
194+
+};
195+
+
196+
+&eth {
197+
+ status = "okay";
198+
+ mediatek,gmac-id = <0>;
199+
+ phy-mode = "2500base-x";
200+
+ mediatek,switch = "mt7531";
201+
+ reset-gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
202+
+
203+
+ fixed-link {
204+
+ speed = <2500>;
205+
+ full-duplex;
206+
+ };
207+
+};
208+
+
209+
+&pinctrl {
210+
+ spi_flash_pins: spi0-pins-func-1 {
211+
+ mux {
212+
+ function = "flash";
213+
+ groups = "spi0", "spi0_wp_hold";
214+
+ };
215+
+
216+
+ conf-pu {
217+
+ pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
218+
+ drive-strength = <MTK_DRIVE_8mA>;
219+
+ bias-pull-up = <MTK_PUPD_SET_R1R0_00>;
220+
+ };
221+
+
222+
+ conf-pd {
223+
+ pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
224+
+ drive-strength = <MTK_DRIVE_8mA>;
225+
+ bias-pull-down = <MTK_PUPD_SET_R1R0_00>;
226+
+ };
227+
+ };
228+
+
229+
+ spic_pins: spi1-pins-func-1 {
230+
+ mux {
231+
+ function = "spi";
232+
+ groups = "spi1_2";
233+
+ };
234+
+ };
235+
+
236+
+ uart1_pins: spi1-pins-func-3 {
237+
+ mux {
238+
+ function = "uart";
239+
+ groups = "uart1_2";
240+
+ };
241+
+ };
242+
+};
243+
+
244+
+&spi0 {
245+
+ #address-cells = <1>;
246+
+ #size-cells = <0>;
247+
+ pinctrl-names = "default";
248+
+ pinctrl-0 = <&spi_flash_pins>;
249+
+ status = "okay";
250+
+ must_tx;
251+
+ enhance_timing;
252+
+ dma_ext;
253+
+ ipm_design;
254+
+ tick_dly = <2>;
255+
+ sample_sel = <0>;
256+
+
257+
+ spi_nand@1 {
258+
+ compatible = "spi-nand";
259+
+ reg = <1>;
260+
+ spi-max-frequency = <20000000>;
261+
+
262+
+ partitions {
263+
+ compatible = "fixed-partitions";
264+
+ #address-cells = <1>;
265+
+ #size-cells = <1>;
266+
+
267+
+ partition@0 {
268+
+ reg = <0x0 0x100000>;
269+
+ label = "bl2";
270+
+ };
271+
+
272+
+ partition@100000 {
273+
+ reg = <0x100000 0x100000>;
274+
+ label = "factory";
275+
+ };
276+
+
277+
+ partition@200000 {
278+
+ reg = <0x200000 0x7e00000>;
279+
+ label = "ubi";
280+
+ };
281+
+ };
282+
+ };
283+
+};
284+
+
285+
+&watchdog {
286+
+ status = "disabled";
287+
+};
288+
--- /dev/null
289+
+++ b/mercusys_mr90x-v1_env
290+
@@ -0,0 +1,53 @@
291+
+ipaddr=192.168.1.1
292+
+serverip=192.168.1.254
293+
+loadaddr=0x46000000
294+
+console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
295+
+bootargs=console=ttyS0,115200n8 console_msg_format=syslog
296+
+bootcmd=run check_buttons ; run boot_production ; run boot_recovery
297+
+bootconf=config-1
298+
+bootdelay=0
299+
+bootfile=openwrt-mediatek-filogic-mercusys_mr90x-v1-ubi-initramfs-recovery.itb
300+
+bootfile_bl2=openwrt-mediatek-filogic-mercusys_mr90x-v1-ubi-preloader.bin
301+
+bootfile_fip=openwrt-mediatek-filogic-mercusys_mr90x-v1-ubi-bl31-uboot.fip
302+
+bootfile_upg=openwrt-mediatek-filogic-mercusys_mr90x-v1-ubi-squashfs-sysupgrade.itb
303+
+bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
304+
+bootmenu_default=0
305+
+bootmenu_delay=0
306+
+bootmenu_title= ( ( ( OpenWrt ) ) ) [SPI-NAND]
307+
+bootmenu_0=Initialize environment.=run _firstboot
308+
+bootmenu_0d=Run default boot command.=run boot_default
309+
+bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
310+
+bootmenu_2=Boot production system from NAND.=run boot_production ; run bootmenu_confirm_return
311+
+bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return
312+
+bootmenu_4=Load production system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_production ; noboot= ; replacevol= ; run bootmenu_confirm_return
313+
+bootmenu_5=Load recovery system via TFTP then write to NAND.=noboot=1 ; replacevol=1 ; run boot_tftp_recovery ; noboot= ; replacevol= ; run bootmenu_confirm_return
314+
+bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return
315+
+bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
316+
+bootmenu_8=Reboot.=reset
317+
+bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset
318+
+boot_default=run led_boot ; run bootcmd ; run boot_recovery ; replacevol=1 ; run boot_tftp_forever
319+
+boot_production=run led_boot ; run ubi_read_production && bootm $loadaddr#$bootconf
320+
+boot_recovery=run led_boot ; run ubi_read_recovery && bootm $loadaddr#$bootconf
321+
+boot_tftp=run led_boot ; tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
322+
+boot_tftp_forever=run led_boot ; while true ; do run boot_tftp ; sleep 1 ; done
323+
+boot_tftp_production=run led_boot ; tftpboot $loadaddr $bootfile_upg && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_production ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
324+
+boot_tftp_recovery=run led_boot ; tftpboot $loadaddr $bootfile && test $replacevol = 1 && iminfo $loadaddr && run ubi_write_recovery ; if test $noboot = 1 ; then else bootm $loadaddr#$bootconf ; fi
325+
+boot_tftp_write_fip=run led_boot ; tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
326+
+boot_tftp_write_bl2=run led_boot ; tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2
327+
+check_buttons=if button reset ; then run boot_tftp ; fi
328+
+ethaddr_factory=mtd read factory 0x40080000 0x0 0x20000 && env readmem -b ethaddr 0x40088000 0x6 ; setenv ethaddr_factory
329+
+led_boot=led green:status off ; led amber:status on
330+
+reset_factory=mw $loadaddr 0xff 0x1f000 ; ubi write $loadaddr ubootenv 0x1f000 ; ubi write $loadaddr ubootenv2 0x1f000 ; ubi remove rootfs_data
331+
+snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x40000
332+
+ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic
333+
+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
334+
+ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
335+
+ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery
336+
+ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
337+
+ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip $filesize static && ubi write $loadaddr fip $filesize
338+
+ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
339+
+ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize
340+
+_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv
341+
+_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; bootmenu
342+
+_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
343+
+_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title $ver"

0 commit comments

Comments
 (0)