openwrt/target/linux
Mikhail Zhilkin 620aa80064 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: https://github.com/openwrt/openwrt/pull/16744
(cherry picked from commit ee8df790ca)
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/17129
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2024-12-10 01:08:03 +01:00
..
airoha kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
apm821xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
archs38 kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
armsr armsr: don't limit kmods to armsr armv8 subtarget 2024-10-29 00:07:55 +01:00
at91 kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
ath79 Revert "ath79: elecom,wab: use nvmem" 2024-11-29 18:25:36 +01:00
bcm27xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
bcm47xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
bcm53xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
bcm4908 kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
bmips kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
d1 kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
gemini kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
generic generic: mtd: spinand: add support for FORESEE F35SQA001G 2024-12-06 15:12:46 +01:00
imx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
ipq40xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
ipq806x kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
ixp4xx kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
kirkwood kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
lantiq kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
layerscape kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
loongarch64 kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
malta kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
mediatek mediatek: MERCUSYS MR90X v1: add OpenWrt U-Boot (UBI) layout 2024-12-10 01:08:03 +01:00
mpc85xx mpc85xx: p2020: add missing symbols 2024-11-28 18:48:10 +00:00
mvebu mvebu: devm for mutex_init 2024-11-28 18:48:57 +00:00
mxs mxs: run kernel_oldconfig 2024-11-28 18:48:55 +00:00
octeon kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
omap kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
pistachio kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
qoriq kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
qualcommax qualcommax: ipq807x: add Netgear DEVICE_VARS 2024-12-08 09:59:16 +01:00
ramips ramips: dna_valokuitu-plus-ex400: clean-up image creation 2024-11-28 18:49:29 +00:00
realtek realtek: align kernel config with upstream 2024-11-28 18:47:31 +00:00
rockchip kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
sifiveu kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
siflower kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
starfive kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
stm32 stm32: Remove unnecessary kernel options 2024-11-28 18:49:23 +00:00
sunxi kernel: bump 6.6 to 6.6.61 2024-11-24 22:46:21 +01:00
tegra kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
uml uml: fix glibc-static check with GCC14 2024-06-22 22:06:06 +02:00
x86 x86: Deactivate kernel options with extra overhead 2024-11-28 18:49:17 +00:00
zynq kernel: filter out compiler opts from config 2024-11-28 18:47:54 +00:00
Makefile linux: add dtb makefile target to targets list 2024-02-08 23:04:55 +01:00