openwrt/package/boot
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
..
arm-trusted-firmware-bcm63xx trusted-firmware-a.mk: pass DTC path similar to u-boot.mk 2022-08-28 19:01:55 +01:00
arm-trusted-firmware-mediatek arm-trusted-firmware-mediatek: update to sources of 2022-08-31 2022-08-31 21:10:39 +01:00
arm-trusted-firmware-mvebu arm-trusted-firmware-mvebu: add Methode eDPU support 2022-10-17 15:42:50 +02:00
arm-trusted-firmware-rockchip
arm-trusted-firmware-sunxi arm-trusted-firmware-sunxi: add package CPE ID 2022-10-19 21:40:23 +02:00
arm-trusted-firmware-tools arm-trusted-firmware-tools: update to v2.7 2022-09-07 04:22:40 +01:00
at91bootstrap at91bootstrap: use sdmmc0 as booting media for sama5d27_som1_ek 2022-09-02 20:43:51 +02:00
fconfig
grub2 grub2: add missing license 2022-04-04 18:15:02 +02:00
imx-bootlets
kexec-tools kexec-tools: add kdump scripts util 2022-06-25 10:14:18 +02:00
kobs-ng
mt7623n-preloader
tfa-layerscape layerscape: update remaining PKG_HASH / PKG_MIRROR_HASH 2022-07-22 22:03:27 +02:00
uboot-at91 uboot-at91: use sdmmc0 as booting media for sama5d27_som1_ek 2022-09-02 20:43:51 +02:00
uboot-bcm4908 uboot-bcm4908: update to the latest generic 2022-12-08 12:10:21 +01:00
uboot-envtools mediatek: add alternative stock layout for Xiaomi Redmi Router AX6000 2022-12-17 15:04:16 +08:00
uboot-fritz4040 uboot-fritz4040: build FritzBox 7520 variant 2022-10-20 17:42:06 +02:00
uboot-imx uboot-imx: pico-pi-imx7d: fix wrong make flags overriding 2022-07-12 09:25:43 +02:00
uboot-kirkwood
uboot-lantiq
uboot-layerscape layerscape: Switch LS1012A-FRDM initramfs to gzip 2022-11-27 13:18:29 +01:00
uboot-mediatek uboot-mediatek: bpi-r3: raise CONFIG_LMB_MAX_REGIONS to 64 2022-11-29 19:44:43 +00:00
uboot-mvebu uboot-mvebu: add Methode eDPU support 2022-10-17 15:42:50 +02:00
uboot-mxs
uboot-omap
uboot-oxnas
uboot-rockchip uboot-rockchip: drop CONFIG_IDENT_STRING 2022-06-19 12:31:02 +02:00
uboot-sunxi sunxi: fix 253-sunxi-h5-add-support-for-nanopi-r1s-h5 patch offset 2022-12-12 09:06:17 +01:00
uboot-tegra
uboot-zynq