openwrt/target/linux
Hank Moretti 0f0ea1087b mediatek: filogic: add support for Xiaomi WR30U
Hardware specification:
  SoC: MediaTek MT7981B 2x A53
  Flash: ESMT F50L1G41LB 128MB
  RAM: NT52B128M16JR-FL 256MB
  Ethernet: 4x 10/100/1000 Mbps
  Switch: MediaTek MT7531AE
  WiFi: MediaTek MT7976C
  Button: Reset, Mesh
  Power: DC 12V 1A

Flash instructions:

1. Get ssh access
   Check this link: https://forum.openwrt.org/t/openwrt-support-for-xiaomi-ax3000ne/153769/22

2. Backup import partitions
   ```
   dev:    size   erasesize  name
   mtd1: 00100000 00020000 "BL2"
   mtd2: 00040000 00020000 "Nvram"
   mtd3: 00040000 00020000 "Bdata"
   mtd4: 00200000 00020000 "Factory"
   mtd5: 00200000 00020000 "FIP"
   mtd8: 02200000 00020000 "ubi"
   mtd9: 02200000 00020000 "ubi1"
   mtd12: 00040000 00020000 "KF"

   ```

   Use these commands blow to backup your stock partitions.
   ```
   nanddump -f /tmp/BL2.bin /dev/mtd1
   nanddump -f /tmp/Nvram.bin /dev/mtd2
   nanddump -f /tmp/Bdata.bin /dev/mtd3
   nanddump -f /tmp/Factory.bin /dev/mtd4
   nanddump -f /tmp/FIP.bin /dev/mtd5
   nanddump -f /tmp/ubi.bin /dev/mtd8
   nanddump -f /tmp/KF.bin /dev/mtd12
   ```
   Then, transfer them to your computer via scp, netcat, tftp
   or others and keep them in a safe place.

3. Setup Nvram
   Get the current stock: `cat /proc/cmdline`

   If you find `firmware=0` or `mtd=ubi`, use these commands:
   ```
   nvram set boot_wait=on
   nvram set uart_en=1
   nvram set flag_boot_rootfs=1
   nvram set flag_last_success=1
   nvram set flag_boot_success=1
   nvram set flag_try_sys1_failed=0
   nvram set flag_try_sys2_failed=0
   nvram commit
   ```

   If you find `firmware=1` or `mtd=ubi1`, use these commands:
   ```
   nvram set boot_wait=on
   nvram set uart_en=1
   nvram set flag_boot_rootfs=0
   nvram set flag_last_success=0
   nvram set flag_boot_success=1
   nvram set flag_try_sys1_failed=0
   nvram set flag_try_sys2_failed=0
   nvram commit
   ```

4. Flash stock-initramfs-factory.ubi
   If you find `firmware=0` or `mtd=ubi`:
   `ubiformat /dev/mtd9 -y -f /tmp/stock-initramfs-factory.ubi`

   If you find `firmware=1` or `mtd=ubi1`:
   `ubiformat /dev/mtd8 -y -f /tmp/stock-initramfs-factory.ubi`

   Then reboot your router, it should boot to the openwrt
   initramfs system now.

5. Setup uboot-env
   Now it will be setup automatically in upgrade process,
   you can skip this step.

   If your `fw_setenv` did not work, you need run this command:
   `echo "/dev/mtd1 0x0 0x10000 0x20000" > /etc/fw_env.config`

   Then setup uboot-env:
   ```
   fw_setenv boot_wait on
   fw_setenv uart_en 1
   fw_setenv flag_boot_rootfs 0
   fw_setenv flag_last_success 1
   fw_setenv flag_boot_success 1
   fw_setenv flag_try_sys1_failed 8
   fw_setenv flag_try_sys2_failed 8
   fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),
   2048k(factory),2048k(fip),256k(crash),256k(crash_log),
   34816k(ubi),34816k(ubi1),32768k(overlay),12288k(data),256k(KF)"
   ```

6. Flash stock-squashfs-sysupgrade.bin
   Use shell command:
   `sysupgrade -n /tmp/stock-squashfs-sysupgrade.bin`
   Or go to luci web.

If you need to change to Openwrt U-Boot layout, do next. If you
do not need, please ignore it.

Change to OpenWrt U-Boot:

1. Flash ubootmod-initramfs-factory.ubi
   Check mtd partitions: `cat /proc/mtd`
   ```
   mtd7: 00040000 00020000 "KF"
   mtd8: 02200000 00020000 "ubi_kernel"
   mtd9: 04e00000 00020000 "ubi"
   ```

   Run following command:
   `ubiformat /dev/mtd8 -y -f /tmp/ubootmod-initramfs-factory.ubi`
   Then reboot your router, it should boot to the openwrt initramfs
   system now.

2. Check mtd again
   ```
   mtd7: 00040000 00020000 "KF"
   mtd8: 07000000 00020000 "ubi"
   ```
   Make sure mtd8 is ubi.

3. Install kmod-mtd-rw
   Run command: `opkg update && opkg install kmod-mtd-rw`
   Or get it in openwrt server, or build it yourself, then install
   it manually

   Then run this command:
   `insmod /lib/modules/$(uname -r)/mtd-rw.ko i_want_a_brick=1`

4. Clean up pstore
   Run Command: `rm -f /sys/fs/pstore/*`

5. Format ubi and create new ubootenv volume
   ```
   ubidetach -p /dev/mtd8; ubiformat /dev/mtd8 -y; ubiattach -p /dev/mtd8
   ubimkvol /dev/ubi0 -n 0 -N ubootenv -s 128KiB
   ubimkvol /dev/ubi0 -n 1 -N ubootenv2 -s 128KiB
   ```

6. (Optional) Add recovery boot feature.
   ```
   ubimkvol /dev/ubi0 -n 2 -N recovery -s 10MiB
   ubiupdatevol /dev/ubi0_2 /tmp/ubootmod-initramfs-recovery.itb
   ```

7. Flash Openwrt U-Boot
   ```
   mtd write /tmp/ubootmod-preloader.bin BL2
   mtd write /tmp/ubootmod-bl31-uboot.fip FIP
   ```

6. Flash ubootmod-squashfs-sysupgrade.itb
   Use shell command:
   `sysupgrade -n /tmp/ubootmod-squashfs-sysupgrade.itb`
   Or go to luci web.

Now everything is done, Enjoy!

Go Back to stock from Openwrt U-Boot:

1. Force flash ubootmod-initramfs-recovery.itb
   Use shell command:
   `sysupgrade -F -n /tmp/ubootmod-initramfs-recovery.itb`
   Or go to luci web.
   Then it should boot to the openwrt initramfs system now.

2. Format ubi and Nvram
   ```
   ubidetach -p /dev/mtd8; ubiformat /dev/mtd8 -y; ubiattach -p /dev/mtd8
   mtd erase Nvram
   ```

3. Install kmod-mtd-rw
   Run command: `opkg update && opkg install kmod-mtd-rw`
   Or get it in openwrt server, or build it yourself, then install
   it manually

   Then run this command:
   `insmod /lib/modules/$(uname -r)/mtd-rw.ko i_want_a_brick=1`

4. Flash stock U-Boot and ubi
   ```
   mtd write /tmp/BL2.bin BL2
   mtd write /tmp/FIP.bin FIP
   mtd write /tmp/ubi.bin ubi
   ```
   Then reboot your router, waiting it finished rollback in minutes.

Go Back to stock from stock layout Openwrt:
   Just run command: `ubiformat /dev/mtd8 -y -f /tmp/ubi.bin`
   Then reboot your router, waiting it finished rollback in minutes.

Notes:
1. Openwrt U-Boot and ubootmod openwrt did not enable NMBM.
   Please make your backup safe.

Signed-off-by: Hank Moretti <mchank9999@gmail.com>
2023-08-07 16:31:27 +01:00
..
airoha airoha: spi-en7523: Fix compile warning 2023-05-31 23:10:11 +02:00
apm821xx apm821xx: switch over from DTB_SIZE to DEVICE_DTC_FLAGS 2023-06-10 19:06:15 +02:00
archs38 treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
armsr kernel: move NXP DPAA2 SFP patches to generic patches 2023-07-26 13:36:58 +02:00
at91 treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
ath25 kernel: bump 5.15 to 5.15.118 2023-06-25 16:05:18 +02:00
ath79 kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
bcm27xx kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
bcm47xx kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
bcm53xx kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
bcm63xx kernel: bump 5.15 to 5.15.119 2023-07-02 10:59:25 +02:00
bcm4908 kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
bmips kernel: bump 5.15 to 5.15.118 2023-06-25 16:05:18 +02:00
gemini treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
generic kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
imx kernel: backport NVMEM patches queued for the v6.5 2023-07-10 12:54:53 +02:00
ipq40xx kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
ipq806x ipq806x: set PERFORMANCE as the default cpufreq governor 2023-06-16 11:42:40 +02:00
ipq807x kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
kirkwood kirkwood: add support for Iomega Storcenter ix4-200d 2023-05-20 15:35:37 +02:00
lantiq lantiq: add patches headers 2023-07-26 13:26:24 +02:00
layerscape layerscape: base-files: remove redundant RAMFS_COPY_* additions 2023-07-26 13:36:58 +02:00
malta treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
mediatek mediatek: filogic: add support for Xiaomi WR30U 2023-08-07 16:31:27 +01:00
mpc85xx mpc85xx: add support for Aerohive BR200-WP 2023-05-14 00:08:35 +02:00
mvebu kernel: bump 5.15 to 5.15.118 2023-06-25 16:05:18 +02:00
mxs mxs: rework image generation 2023-07-06 17:04:13 +02:00
octeon octeon: ubnt-edgerouter-4/6p: devicetree cleanup 2023-07-15 22:24:50 +02:00
octeontx kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
omap treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
oxnas oxnas: Enable CONFIG_CRYPTO_LZ4 2023-06-08 17:28:11 +02:00
pistachio treewide: cleanup kernel symbol references 2023-05-12 13:02:44 +02:00
qoriq kernel: fix handling of CONFIG_DYNAMIC_DEBUG 2023-05-03 10:26:17 -07:00
ramips kernel: bump 5.15 to 5.15.123 2023-07-31 01:39:50 +02:00
realtek kernel: bump 5.15 to 5.15.118 2023-06-25 16:05:18 +02:00
rockchip rockchip: fix setup network config for nanopi r2c 2023-06-17 12:21:13 +02:00
sifiveu kernel: bump 5.15 to 5.15.117 2023-06-17 12:09:03 +02:00
sunxi kernel: Set CONFIG_FRAME_WARN depending on target 2023-06-02 21:18:41 +02:00
tegra treewide: remove files for building 5.10 kernel 2023-05-12 13:02:43 +02:00
uml uml: fix build error due to frame size > 1024 2023-05-24 19:25:39 +01:00
x86 x86: set CONFIG_X86_AMD_PLATFORM_DEVICE 2023-07-08 15:43:59 +02:00
zynq generic: enable CONFIG_ARM_CRYPTO for 32bit arm targets 2023-05-10 19:01:45 +02:00
Makefile build: fix issues with targets installed via feeds 2022-09-27 13:41:12 +02:00