msm8916-openwrt/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
Dirk Buchwalder 9e49593ff7 mediatek: filogic: add support for TP-LINK RE6000XD
This commit adds support for TP-LINK RE6000XD.
The device is quite similar to the Mercusys MR90X V1,
except only 3 LAN ports and more LEDs.
So thanks to csharper2005 for doing all the groundwork.

Device specification
--------------------
SoC Type:   MediaTek MT7986BLA, Cortex-A53, 64-bit
RAM:        MediaTek MT7986BLA (512MB)
Flash:      SPI NAND GigaDevice (128 MB)
Ethernet:   MediaTek MT7531AE + 2.5GbE MaxLinear GPY211C0VC (SLNW8)
Ethernet:   1x2.5Gbe (LAN3 2.5Gbps), 2xGbE (LAN 1Gbps, LAN1,
            LAN2)
WLAN 2g:    MediaTek MT7975N, b/g/n/ax, MIMO 4x4
WLAN 5g:    MediaTek MT7975P(N), a/n/ac/ax, MIMO 4x4
LEDs:       8 LEDs, 1 status blue, 2x WIFI blue, 2x signal
	    blue/red, 3 LAN blue gpio-controlled
Button:     2 (Reset, WPS)
USB ports:  No
Power:      12 VDC, 2 A
Connector:  Barrel
Bootloader: Main U-Boot - U-Boot 2022.01-rc4. Additionally, ubi0
            partition contain "seconduboot" (also U-Boot 2022.01-rc4)

Serial console (UART), unpopulated
---------------------
                            V
+-------+-------+-------+-------+
| +3.3V |  GND  |  TX   |  RX   |
+---+---+-------+-------+-------+
    |
    +--- Don't connect

Disassemble: rm the 2 screws at the bottom and the one at the backside.
            un-clip the case starting at the edge above the LEDs.

Installation (UART)
-------------------
1. Place OpenWrt initramfs image on tftp server with IP 192.168.1.2
2. Attach UART, switch on the router and interrupt the boot process by
   pressing 'Ctrl-C'
3. Load and run OpenWrt initramfs image:
      tftpboot openwrt-mediatek-filogic-tplink_re6000xd-initramfs-kernel.bin bootm
4. Run 'sysupgrade -n' with the sysupgrade OpenWrt image

Notice: while I was successfull at activating ssh (as described
        here:
        https://www.lisenet.com/2023/gaining-ssh-access-to-tp-link-re200-wi-fi-range-extender/)

        Unfortunately I haven't found the correct root password.
        Looks like they are using a static password
        (md5crypt, salt + 21 characters) that is not the web
        interface admin password.

        The TP-LINK RE900XD looks like the very same device,
        according to the pictures and the firmware.
        But I haven't checked if the OpenWrt firmware works as well
        on that device.

        The second ubi partition (ubi1) is empty and there is no known
        dual-partition mechanism, neither in u-boot nor in the stock firmware.

Signed-off-by: Dirk Buchwalder <buchwalder@posteo.de>
2024-07-04 22:14:32 +02:00

281 lines
5.5 KiB
Bash
Executable File

REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fitblk'
asus_initial_setup()
{
# initialize UBI if it's running on initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0
ubirmvol /dev/ubi0 -N rootfs
ubirmvol /dev/ubi0 -N rootfs_data
ubirmvol /dev/ubi0 -N jffs2
ubimkvol /dev/ubi0 -N jffs2 -s 0x3e000
}
xiaomi_initial_setup()
{
# initialize UBI and setup uboot-env if it's running on initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0
local mtdnum="$( find_mtd_index ubi )"
if [ ! "$mtdnum" ]; then
echo "unable to find mtd partition ubi"
return 1
fi
local kern_mtdnum="$( find_mtd_index ubi_kernel )"
if [ ! "$kern_mtdnum" ]; then
echo "unable to find mtd partition ubi_kernel"
return 1
fi
ubidetach -m "$mtdnum"
ubiformat /dev/mtd$mtdnum -y
ubidetach -m "$kern_mtdnum"
ubiformat /dev/mtd$kern_mtdnum -y
if ! fw_printenv -n flag_try_sys2_failed &>/dev/null; then
echo "failed to access u-boot-env. skip env setup."
return 0
fi
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
local board=$(board_name)
case "$board" in
xiaomi,mi-router-ax3000t|\
xiaomi,mi-router-wr30u-stock)
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)"
;;
xiaomi,redmi-router-ax6000-stock)
fw_setenv mtdparts "nmbm0:1024k(bl2),256k(Nvram),256k(Bdata),2048k(factory),2048k(fip),256k(crash),256k(crash_log),30720k(ubi),30720k(ubi1),51200k(overlay)"
;;
esac
}
platform_do_upgrade() {
local board=$(board_name)
case "$board" in
acer,predator-w6|\
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632|\
smartrg,sdg-8733|\
smartrg,sdg-8734)
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
emmc_do_upgrade "$1"
;;
asus,rt-ax59u|\
asus,tuf-ax4200|\
asus,tuf-ax6000)
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
nand_do_upgrade "$1"
;;
bananapi,bpi-r3|\
bananapi,bpi-r3-mini|\
bananapi,bpi-r4|\
bananapi,bpi-r4-poe|\
jdcloud,re-cp-03|\
mediatek,mt7988a-rfb|\
openwrt,one)
[ -e /dev/fit0 ] && fitblk /dev/fit0
[ -e /dev/fitrw ] && fitblk /dev/fitrw
bootdev="$(fitblk_get_bootdev)"
case "$bootdev" in
mmcblk*)
EMMC_KERN_DEV="/dev/$bootdev"
emmc_do_upgrade "$1"
;;
mtdblock*)
PART_NAME="/dev/mtd${bootdev:8}"
default_do_upgrade "$1"
;;
ubiblock*)
CI_KERNPART="fit"
nand_do_upgrade "$1"
;;
esac
;;
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
CI_KERNPART="production"
emmc_do_upgrade "$1"
;;
*)
CI_KERNPART="fit"
nand_do_upgrade "$1"
;;
esac
;;
cudy,re3000-v1|\
cudy,wr3000-v1|\
yuncore,ax835)
default_do_upgrade "$1"
;;
glinet,gl-mt2500|\
glinet,gl-mt6000|\
glinet,gl-x3000|\
glinet,gl-xe3000)
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
emmc_do_upgrade "$1"
;;
h3c,magic-nx30-pro|\
jcg,q30-pro|\
mediatek,mt7981-rfb|\
netcore,n60|\
qihoo,360t7|\
xiaomi,mi-router-ax3000t-ubootmod|\
xiaomi,mi-router-wr30u-ubootmod)
CI_KERNPART="fit"
nand_do_upgrade "$1"
;;
mercusys,mr90x-v1|\
tplink,re6000xd)
CI_UBIPART="ubi0"
nand_do_upgrade "$1"
;;
nokia,ea0326gmp|\
tplink,tl-xdr4288|\
tplink,tl-xdr6086|\
tplink,tl-xdr6088|\
xiaomi,redmi-router-ax6000-ubootmod)
[ -e /dev/fit0 ] && fitblk /dev/fit0
[ -e /dev/fitrw ] && fitblk /dev/fitrw
CI_KERNPART="fit"
nand_do_upgrade "$1"
;;
ubnt,unifi-6-plus)
CI_KERNPART="kernel0"
EMMC_ROOT_DEV="$(cmdline_get_var root)"
emmc_do_upgrade "$1"
;;
xiaomi,mi-router-ax3000t|\
xiaomi,mi-router-wr30u-stock|\
xiaomi,redmi-router-ax6000-stock)
CI_KERN_UBIPART=ubi_kernel
CI_ROOT_UBIPART=ubi
nand_do_upgrade "$1"
;;
zyxel,ex5601-t0-ubootmod)
CI_KERNPART="fit"
CI_ROOTPART="ubi_rootfs"
nand_do_upgrade "$1"
;;
unielec,u7981-01*)
local rootdev="$(cmdline_get_var root)"
rootdev="${rootdev##*/}"
rootdev="${rootdev%p[0-9]*}"
case "$rootdev" in
mmc*)
CI_ROOTDEV="$rootdev"
CI_KERNPART="kernel"
CI_ROOTPART="rootfs"
emmc_do_upgrade "$1"
;;
*)
CI_KERNPART="fit"
nand_do_upgrade "$1"
;;
esac
;;
*)
nand_do_upgrade "$1"
;;
esac
}
PART_NAME=firmware
platform_check_image() {
local board=$(board_name)
local magic="$(get_magic_long "$1")"
[ "$#" -gt 1 ] && return 1
case "$board" in
bananapi,bpi-r3|\
bananapi,bpi-r4|\
bananapi,bpi-r4-poe|\
cmcc,rax3000m)
[ "$magic" != "d00dfeed" ] && {
echo "Invalid image type."
return 1
}
return 0
;;
*)
nand_do_platform_check "$board" "$1"
return $?
;;
esac
return 0
}
platform_copy_config() {
case "$(board_name)" in
cmcc,rax3000m)
case "$(cmdline_get_var root)" in
/dev/mmc*)
emmc_copy_config
;;
esac
;;
bananapi,bpi-r3|\
bananapi,bpi-r3-mini|\
bananapi,bpi-r4|\
bananapi,bpi-r4-poe)
case "$(fitblk_get_bootdev)" in
mmcblk*)
emmc_copy_config
;;
esac
;;
acer,predator-w6|\
glinet,gl-mt2500|\
glinet,gl-mt6000|\
glinet,gl-x3000|\
glinet,gl-xe3000|\
jdcloud,re-cp-03|\
smartrg,sdg-8612|\
smartrg,sdg-8614|\
smartrg,sdg-8622|\
smartrg,sdg-8632|\
smartrg,sdg-8733|\
smartrg,sdg-8734|\
ubnt,unifi-6-plus)
emmc_copy_config
;;
esac
}
platform_pre_upgrade() {
local board=$(board_name)
case "$board" in
asus,rt-ax59u|\
asus,tuf-ax4200|\
asus,tuf-ax6000)
asus_initial_setup
;;
xiaomi,mi-router-ax3000t|\
xiaomi,mi-router-wr30u-stock|\
xiaomi,redmi-router-ax6000-stock)
xiaomi_initial_setup
;;
esac
}