openwrt/target/linux
Chen Minqiang 18bea173a6 mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000
In this implementation, the flash partition layout is adjusted to avoid
modifying the uboot environment of mtdparts. This ensures that the 30M
ubi_kernel partition remains aligned with the stock ubi partition, and
the kernel volume is placed in it. This allows the stock uboot to boot
from it without changing the mtdparts, which is useful for reverting back
to the stock firmware using Xiaomi Firmware Tools. In actual testing,
modifying mtdparts has been found to break Xiaomi Firmware Tools.

1. use ARTIFACTS to generate initramfs-factory.ubi for easy installation.
2. The NAND flash layout is changed to allow for reverting back to the
   stock firmware.
3. Before performing sysupgrade, do some cleanup in platform_pre_upgrade
   to ensure a clean installation of OpenWRT.
4. Setup the uboot env to ensure that the system always boot, which can
   be helpful for users who may forget to do this before sysupgrade in
   the initramfs.

New flash instructions:
1. Gain ssh access. Please refer to:
   https://openwrt.org/toh/xiaomi/redmi_ax6000#installation)

2. Check which system current u-boot is loading from:
   COMMAND: `cat /proc/cmdline`
   sample OUTPUT: `console=ttyS0,115200n1 loglevel=8 firmware=1 uart_en=1`
   if firmware=1, current system is ubi1
   if firmware=0, current system is ubi0

3. Setup nvram and write the firmware:
   If the current system is ubi1, please set it up so that the next time
   it will boot from ubi, and write the firmware to ubi:
```
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
ubiformat /dev/mtd8 -y -f /tmp/initramfs-factory.ubi
```
   If the current system is ubi, please set it up so that the next time
   it will boot from ubi1, and write the firmware to ubi1:
```
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
ubiformat /dev/mtd9 -y -f /tmp/initramfs-factory.ubi
```

4. After rebooting, the system should now boot into the openwrt initramfs.
   Flash the squashfs-sysupgrade.bin via using ssh or luci.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```
Done.

For existing users of the Redmi AX6000 running OpenWrt, here are the steps to
switch to this new layout:

1. Flash initramfs-factory.ubi
```
mtd -r -e ubi write /tmp/initramfs-factory.ubi ubi
```

2. After rebooting, the system will boot into the new openwrt-initramfs.
Log in and perform a sysupgrade to complete the process.
```
sysupgrade -n /tmp/squashfs-sysupgrade.bin
```

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2022-12-17 15:04:16 +08:00
..
airoha airoha: disable swconfig 2022-11-27 13:18:29 +01:00
apm821xx kernel: bump 5.10 to 5.10.154 2022-11-12 17:05:13 +01:00
archs38 kernel: remove target specific CONFIG_IKCONFIG lines 2022-10-14 13:15:47 +02:00
armvirt kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
at91 at91: Remove CONFIG_PINCTRL_MCP23S08 configuration option 2022-10-31 00:46:15 +01:00
ath25 kernel: bump 5.10 to 5.10.137 2022-08-23 10:37:04 +02:00
ath79 ath79: fix dtc warnings in ruckus zf7372 2022-12-15 15:45:47 +01:00
bcm27xx bcm27xx: bcm2711: add kmod-r8169 2022-12-15 15:08:08 +01:00
bcm47xx mac80211: remove old legacy legacy drivers 2022-11-09 20:44:28 +01:00
bcm53xx bcm53xx: Patch to support BCMA rev 11 2022-12-15 15:08:08 +01:00
bcm63xx kernel: bump 5.15 to 5.15.83 2022-12-14 23:34:50 +01:00
bcm4908 treewide: uniform vendor name for ASUS 2022-11-16 23:30:11 +01:00
bmips kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
gemini gemini: Set proper default networks 2022-12-12 11:18:02 +01:00
generic generic: add support for EON EN25QX128A spi nor flash 2022-12-16 20:58:36 +01:00
imx cypress-nvram: consolidate NVRAM packages 2022-11-16 20:14:13 +01:00
ipq40xx ipq40xx: fix usb driver not loaded for GL-A1300 2022-12-11 03:06:54 +01:00
ipq806x ipq806x: 5.15: standardize wpq864 partition table 2022-12-14 02:23:22 +01:00
kirkwood kernel: remove hack patch, move kirkwood specific kmods to target modules.mk 2022-09-30 12:59:19 +02:00
lantiq lantiq: vr9: include usb driver for fritz 7430 2022-12-11 16:46:34 +01:00
layerscape kernel: bump 5.15 to 5.15.83 2022-12-14 23:34:50 +01:00
malta kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
mediatek mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000 2022-12-17 15:04:16 +08:00
mpc85xx mpc85xx: fix missing kernel config symbol 2022-11-16 23:30:11 +01:00
mvebu kernel: bump 5.15 to 5.15.83 2022-12-14 23:34:50 +01:00
mxs target/mxs: replace gpio-mcp23s08 with pinctrl-mcp23s08 2022-10-30 23:14:45 +01:00
octeon kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
octeontx kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
omap kernel: remove target specific CONFIG_IKCONFIG lines 2022-10-14 13:15:47 +02:00
oxnas kernel: bump 5.15 to 5.15.75 2022-10-30 17:54:59 +01:00
pistachio kernel: backport support for "linux,rootfs" in DT 2022-11-08 09:12:16 +01:00
qoriq qoriq: switch to kernel 5.15 2022-12-14 18:53:39 +02:00
ramips ramips: add support for Etisalat S3 2022-12-13 23:06:20 +01:00
realtek realtek: add Linux Kernel 5.15 as testing version 2022-12-15 20:54:12 +01:00
rockchip kernel: bump 5.10 to 5.10.159 2022-12-14 23:37:28 +01:00
sunxi sunxi: fix sunxi-ir kconfig and description 2022-12-12 09:06:17 +01:00
tegra kernel: Move some IOMMU options to generic 2022-09-24 13:49:47 +02:00
uml uml: switch to Kernel 5.15 2022-12-12 09:06:17 +01:00
x86 kernel: bump 5.10 to 5.10.156 2022-11-27 13:18:29 +01:00
zynq kernel: remove target specific CONFIG_IKCONFIG lines 2022-10-14 13:15:47 +02:00
Makefile build: fix issues with targets installed via feeds 2022-09-27 13:41:12 +02:00