Skip to content

Commit ee8df79

Browse files
csharper2005hauke
authored andcommitted
mediatek: MERCUSYS MR90X v1: add OpenWrt U-Boot (UBI) layout
This commit adds OpenWrt U-Boot (UBI) layout support for MERCUSYS MR90X v1. Stock U-Boot UBI size: 50 MiB OpenWrt U-boot UBI size: 126 MiB Install ------- 1. Perform steps 1-14 of the OpenWrt installation guide (use OpenWrt initramfs-recovery.itb instead of initramfs-kernel.bin at the step 10, 12 and 14). Link: https://openwrt.org/toh/mercusys/mr90x_v1#installation 2. Make backups: ``` cat /dev/mtd0 > /tmp/boot.bin cat /dev/mtd5 > /tmp/tp_data.bin ``` Copy /tp_data dir content, /tmp/boot.bin and /tmp/tp_data.bin and to your PC using scp. You can also backup the remaining partititons. Copy backups to a safe place, they are required for the next steps and stock firmware recovery. 3. Reboot to OpenWrt initramfs: ``` reboot ``` 4. Copy OpenWrt ubi-bl31-uboot.fip, ubi-preloader.bin, ubi-squashfs-sysupgrade.itb and MT7986_EEPROM.bin, default-mac (from /tp_data backup) to the /tmp folder of the router using scp. 5. Prepare UBI: ``` ubidetach -p /dev/mtd3; ubiformat /dev/mtd3 -y; ubiattach -p /dev/mtd3 ubimkvol /dev/ubi0 -N fip -t static -s 1MiB ubiupdatevol /dev/ubi0_0 /tmp/ubi-bl31-uboot.fip ubimkvol /dev/ubi0 -N ubootenv -s 0x1f000 ubimkvol /dev/ubi0 -N ubootenv2 -s 0x1f000 ``` 6. Install kmod-mtd-rw and unlock partitions: ``` opkg update && opkg install kmod-mtd-rw insmod mtd-rw i_want_a_brick=1 mtd unlock boot mtd unlock bl2 mtd unlock factory ``` 7. Prepare "factory" partition: ``` dd if=/dev/zero bs=$((0x8000)) count=1 | tr '\000' '\377' > /tmp/factory.bin dd if=/tmp/MT7986_EEPROM.bin of=/tmp/factory.bin conv=notrunc dd if=/tmp/default-mac >> /tmp/factory.bin ``` 8. Write "factory" partition: ``` mtd erase factory mtd write /tmp/factory.bin factory ``` 9. Write preloader partition: ``` mtd erase bl2 mtd write /tmp/ubi-preloader.bin bl2 ``` 10. Write OpenWrt sysupgrade image: ``` sysupgrade -n /tmp/ubi-squashfs-sysupgrade.itb ``` Recovery -------- 1. Place OpenWrt initramfs-recovery.itb image (with original name) on the tftp server (IP: 192.168.1.254). 2. Press "reset" button and power on the router. After ~10 sec release the button. 3. Use OpenWrt initramfs system for recovery. BL2 and FIP recovery -------------------- Use mtk_uartboot and UART connetion if BL2 or FIP in UBI is destroyed: Link: https://github.com/981213/mtk_uartboot Link: https://openwrt.org/toh/mercusys/mr90x_v1#serial Return to stock: ---------------- 1. Copy "boot" partition backup (boot.bin) to the /tmp dir of the router using scp. 2. Install kmod-mtd-rw: ``` opkg update && opkg install kmod-mtd-rw ``` 3. Restore stock U-Boot: ``` insmod mtd-rw i_want_a_brick=1 mtd unlock boot mtd erase boot mtd write /tmp/boot.bin boot ``` 4. Erase UBI and reboot: ``` mtd erase ubi reboot ``` 5. Open U-Boot web recovery, upload stock firmware image and start upgrade. Link: http://192.168.1.1 6. Complete steps 1-9 of the OpenWrt installation guide to get root rights. Link: https://openwrt.org/toh/mercusys/mr90x_v1#installation 7. Upload "tp_data" partition backup (tp_data.bin) to the /tmp folder of the router using scp. 8. Restore stock calibrations: ``` mtd write /tmp/tp_data.bin tp_data reboot ``` 9. Perform "factory restore" via stock firmware web interface. Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com> Link: openwrt/openwrt#16744 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent 77cc4b7 commit ee8df79

File tree

8 files changed

+434
-268
lines changed

8 files changed

+434
-268
lines changed

package/boot/uboot-envtools/files/mediatek_filogic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ case "$board" in
3636
abt,asr3000|\
3737
h3c,magic-nx30-pro|\
3838
jcg,q30-pro|\
39+
mercusys,mr90x-v1-ubi|\
3940
netcore,n60|\
4041
nokia,ea0326gmp|\
4142
qihoo,360t7|\
Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
1+
// SPDX-License-Identifier: (GL-2.0 OR MIT)
2+
3+
/dts-v1/;
4+
#include <dt-bindings/input/input.h>
5+
#include <dt-bindings/gpio/gpio.h>
6+
#include <dt-bindings/leds/common.h>
7+
8+
#include "mt7986b.dtsi"
9+
10+
/ {
11+
aliases: aliases {
12+
led-boot = &led_status_green;
13+
led-failsafe = &led_status_green;
14+
led-running = &led_status_green;
15+
led-upgrade = &led_status_green;
16+
17+
serial0 = &uart0;
18+
};
19+
20+
chosen: chosen {
21+
stdout-path = "serial0:115200n8";
22+
};
23+
24+
memory {
25+
reg = <0 0x40000000 0 0x20000000>;
26+
};
27+
28+
keys {
29+
compatible = "gpio-keys";
30+
31+
reset {
32+
label = "reset";
33+
gpios = <&pio 10 GPIO_ACTIVE_LOW>;
34+
linux,code = <KEY_RESTART>;
35+
};
36+
};
37+
38+
leds {
39+
compatible = "gpio-leds";
40+
41+
led-0 {
42+
color = <LED_COLOR_ID_GREEN>;
43+
function = LED_FUNCTION_LAN;
44+
function-enumerator = <2>;
45+
gpios = <&pio 7 GPIO_ACTIVE_LOW>;
46+
};
47+
48+
led-1 {
49+
color = <LED_COLOR_ID_GREEN>;
50+
function = LED_FUNCTION_LAN;
51+
function-enumerator = <1>;
52+
gpios = <&pio 9 GPIO_ACTIVE_LOW>;
53+
};
54+
55+
led-2 {
56+
color = <LED_COLOR_ID_GREEN>;
57+
function = LED_FUNCTION_LAN;
58+
function-enumerator = <0>;
59+
gpios = <&pio 12 GPIO_ACTIVE_LOW>;
60+
};
61+
62+
led-3 {
63+
color = <LED_COLOR_ID_GREEN>;
64+
function = LED_FUNCTION_WAN;
65+
gpios = <&pio 13 GPIO_ACTIVE_LOW>;
66+
};
67+
68+
led-4 {
69+
color = <LED_COLOR_ID_AMBER>;
70+
function = LED_FUNCTION_STATUS;
71+
gpios = <&pio 16 GPIO_ACTIVE_HIGH>;
72+
panic-indicator;
73+
};
74+
75+
led_status_green: led-5 {
76+
color = <LED_COLOR_ID_GREEN>;
77+
function = LED_FUNCTION_STATUS;
78+
gpios = <&pio 17 GPIO_ACTIVE_HIGH>;
79+
};
80+
};
81+
};
82+
83+
&crypto {
84+
status = "okay";
85+
};
86+
87+
&eth {
88+
status = "okay";
89+
90+
gmac0: mac@0 {
91+
compatible = "mediatek,eth-mac";
92+
reg = <0>;
93+
phy-mode = "2500base-x";
94+
95+
fixed-link {
96+
speed = <2500>;
97+
full-duplex;
98+
pause;
99+
};
100+
};
101+
102+
gmac1: mac@1 {
103+
compatible = "mediatek,eth-mac";
104+
reg = <1>;
105+
phy-handle = <&phy6>;
106+
phy-mode = "2500base-x";
107+
};
108+
109+
mdio: mdio-bus {
110+
#address-cells = <1>;
111+
#size-cells = <0>;
112+
};
113+
};
114+
115+
&mdio {
116+
#address-cells = <1>;
117+
#size-cells = <0>;
118+
119+
reset-gpios = <&pio 6 GPIO_ACTIVE_LOW>;
120+
reset-delay-us = <1500000>;
121+
reset-post-delay-us = <1000000>;
122+
123+
/* WAN/LAN 2.5Gbps phy
124+
MaxLinear GPY211C0VC (SLNW8) */
125+
phy6: phy@6 {
126+
compatible = "ethernet-phy-ieee802.3-c45";
127+
reg = <6>;
128+
};
129+
130+
switch: switch@1f {
131+
compatible = "mediatek,mt7531";
132+
reg = <31>;
133+
reset-gpios = <&pio 5 GPIO_ACTIVE_HIGH>;
134+
};
135+
};
136+
137+
&switch {
138+
ports {
139+
#address-cells = <1>;
140+
#size-cells = <0>;
141+
142+
/* WAN/LAN 1Gbps port */
143+
port@0 {
144+
reg = <0>;
145+
label = "lan0";
146+
};
147+
148+
/* LAN1 port */
149+
port@1 {
150+
reg = <1>;
151+
label = "lan1";
152+
};
153+
154+
/* LAN2 port */
155+
port@2 {
156+
reg = <2>;
157+
label = "lan2";
158+
};
159+
160+
port@6 {
161+
reg = <6>;
162+
ethernet = <&gmac0>;
163+
phy-mode = "2500base-x";
164+
165+
fixed-link {
166+
speed = <2500>;
167+
full-duplex;
168+
pause;
169+
};
170+
};
171+
};
172+
};
173+
174+
&pio {
175+
spi_flash_pins: spi-flash-pins-33-to-38 {
176+
mux {
177+
function = "spi";
178+
groups = "spi0", "spi0_wp_hold";
179+
};
180+
conf-pu {
181+
pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
182+
drive-strength = <8>;
183+
mediatek,pull-up-adv = <0>; /* bias-disable */
184+
};
185+
conf-pd {
186+
pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
187+
drive-strength = <8>;
188+
mediatek,pull-down-adv = <0>; /* bias-disable */
189+
};
190+
};
191+
192+
wf_2g_5g_pins: wf_2g_5g-pins {
193+
mux {
194+
function = "wifi";
195+
groups = "wf_2g", "wf_5g";
196+
};
197+
conf {
198+
pins = "WF0_HB1", "WF0_HB2", "WF0_HB3", "WF0_HB4",
199+
"WF0_HB0", "WF0_HB0_B", "WF0_HB5", "WF0_HB6",
200+
"WF0_HB7", "WF0_HB8", "WF0_HB9", "WF0_HB10",
201+
"WF0_TOP_CLK", "WF0_TOP_DATA", "WF1_HB1",
202+
"WF1_HB2", "WF1_HB3", "WF1_HB4", "WF1_HB0",
203+
"WF1_HB5", "WF1_HB6", "WF1_HB7", "WF1_HB8",
204+
"WF1_TOP_CLK", "WF1_TOP_DATA";
205+
drive-strength = <4>;
206+
};
207+
};
208+
};
209+
210+
&spi0 {
211+
pinctrl-names = "default";
212+
pinctrl-0 = <&spi_flash_pins>;
213+
status = "okay";
214+
215+
spi_nand_flash: flash@0 {
216+
compatible = "spi-nand";
217+
#address-cells = <1>;
218+
#size-cells = <1>;
219+
reg = <0>;
220+
221+
spi-max-frequency = <20000000>;
222+
spi-tx-bus-width = <4>;
223+
spi-rx-bus-width = <4>;
224+
225+
partitions: partitions {
226+
compatible = "fixed-partitions";
227+
#address-cells = <1>;
228+
#size-cells = <1>;
229+
};
230+
};
231+
};
232+
233+
&trng {
234+
status = "okay";
235+
};
236+
237+
&uart0 {
238+
status = "okay";
239+
};
240+
241+
&watchdog {
242+
status = "okay";
243+
};
244+
245+
&wifi {
246+
status = "okay";
247+
248+
pinctrl-names = "default";
249+
pinctrl-0 = <&wf_2g_5g_pins>;
250+
251+
ieee80211-freq-limit = <2400000 2500000>, <5170000 5835000>;
252+
};
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// SPDX-License-Identifier: (GL-2.0 OR MIT)
2+
3+
#include "mt7986b-mercusys-mr90x-v1-common.dtsi"
4+
5+
/ {
6+
compatible = "mercusys,mr90x-v1-ubi", "mediatek,mt7986b";
7+
model = "MERCUSYS MR90X v1 (UBI)";
8+
};
9+
10+
&aliases {
11+
label-mac-device = &gmac0;
12+
};
13+
14+
&chosen {
15+
bootargs-append = " root=/dev/fit0 rootwait";
16+
rootdisk = <&ubi_fit>;
17+
};
18+
19+
&gmac0 {
20+
nvmem-cells = <&macaddr_factory_8000 0>;
21+
nvmem-cell-names = "mac-address";
22+
};
23+
24+
&gmac1 {
25+
nvmem-cells = <&macaddr_factory_8000 1>;
26+
nvmem-cell-names = "mac-address";
27+
};
28+
29+
&partitions {
30+
partition@0 {
31+
label = "boot";
32+
reg = <0x0 0x200000>;
33+
read-only;
34+
35+
compatible = "fixed-partitions";
36+
#address-cells = <1>;
37+
#size-cells = <1>;
38+
39+
partition@0 {
40+
label = "bl2";
41+
reg = <0x0 0x100000>;
42+
read-only;
43+
};
44+
45+
partition@100000 {
46+
label = "factory";
47+
reg = <0x100000 0x100000>;
48+
read-only;
49+
50+
nvmem-layout {
51+
compatible = "fixed-layout";
52+
#address-cells = <1>;
53+
#size-cells = <1>;
54+
55+
eeprom_factory_0: eeprom@0 {
56+
reg = <0x0 0x1000>;
57+
};
58+
59+
macaddr_factory_8000: macaddr@8000 {
60+
compatible = "mac-base";
61+
reg = <0x8000 0x6>;
62+
#nvmem-cell-cells = <1>;
63+
};
64+
};
65+
};
66+
};
67+
68+
partition@200000 {
69+
compatible = "linux,ubi";
70+
reg = <0x200000 0x7e00000>;
71+
label = "ubi";
72+
73+
volumes {
74+
ubi_fit: ubi-volume-fit {
75+
volname = "fit";
76+
};
77+
78+
ubi_ubootenv: ubi-volume-ubootenv {
79+
volname = "ubootenv";
80+
};
81+
82+
ubi_ubootenv2: ubi-volume-ubootenv2 {
83+
volname = "ubootenv2";
84+
};
85+
};
86+
};
87+
};
88+
89+
&trng {
90+
status = "okay";
91+
};
92+
93+
&uart0 {
94+
status = "okay";
95+
};
96+
97+
&ubi_ubootenv {
98+
nvmem-layout {
99+
compatible = "u-boot,env-redundant-bool";
100+
};
101+
};
102+
103+
&ubi_ubootenv2 {
104+
nvmem-layout {
105+
compatible = "u-boot,env-redundant-bool";
106+
};
107+
};
108+
109+
&wifi {
110+
nvmem-cells = <&eeprom_factory_0>;
111+
nvmem-cell-names = "eeprom";
112+
113+
band@0 {
114+
reg = <0>;
115+
nvmem-cells = <&macaddr_factory_8000 0>;
116+
nvmem-cell-names = "mac-address";
117+
};
118+
119+
band@1 {
120+
reg = <1>;
121+
nvmem-cells = <&macaddr_factory_8000 (-1)>;
122+
nvmem-cell-names = "mac-address";
123+
};
124+
};

0 commit comments

Comments
 (0)