difos/target/linux/qualcommax/ipq807x/base-files/lib/upgrade/platform.sh
jonathan brophy 8da24b1109 Qualcommax: IPQ807x: Add support for TP-Link Deco X80-5G
The TP-link Deco X80-5G is a AX WIFI router with a single 1G (LAN) and 1 2.5G (WAN) port with a built in Quectel 5G modem.

Specifications:

Architecture	ARMv8-A (aarch64 Cortex A53, 4 cores)
Vendor	Qualcomm
Bootloader	U-Boot (2016)
System-On-Chip	Qualcomm IPQ8074A (Networking Pro 1210 platform)
CPU/Speed	2.2GHZ
Flash-Chip	ESMT F59D1G81MB-45TI 1G-bit NAND
Flash MB	128MB (1Gbit)
RAM-chip	2* ESMT M15T4G16256A-DEBG2G 2Gb DDR3L (32bit)
RAM MB	512MB (4Gbit)
WLan System-On-Chip (5g)	Qualcomm QCN5054
WLan Front end modules (5g)	8* Qorvo QPF4588
WLAN (5G)	A/N/AC/AX
WLAN Antenna (int)	8* (4 shared with 2.5G)
WLan System-On-Chip (2.4G)	Qualcomm QCN5024
WLan Front end modules (2.4G)	4* Skyworks SKY85340-11
WLAN (2.4G)	B/G/N/AX
WLAN Antenna (int)	4* (shared with 5g)
Eithernet-phy (1Gbit)	Qualcomm (Atheros) AR8033-AL1A
Ethernet (1Gbit)	1*
Eithernet-phy (2.5Gbit)	Qualcomm QCA8081
Ethernet (2.5Gbit)	1*
Switch	Embedded in the SOC?
Serial	1.8v 8n1 (testpoints)
Modem System-On-Chip	Qualcomm 5G RG50xQ (Snapdragon X55 platform)
5G modem capability	5000Mbps down 900Mbps up
5G modem bands	N1/N3/N5/N7/N8/N20/N28/N38/N40/N41/N77/N78/N79
4G modem capability	4.5G LTE-Advanced Pro (Cat20 down 2Gbps) (Cat18 up 200Mbps)
4G modem FDD bands	B1/B3/B5/B7/B8/B18/B19/B20/B26/B28
4G modem TDD bands	B34/B38/B39/B40/B41/B42/B43
Modem antenna (int)	8* (5G/4G use)
Modem antenna (ext)	2* SMA connectors (5G/4G use)
SIM type	1* Nano SIM
Telephony	1* POTS RJ11
(see wiki for more info:)
https://openwrt.org/inbox/toh/tp-link/x80-5g_v1

        Notes:
Installation Instructions:

Between antennas 7 and 8 on the PCB with the RGB harness there are three test pads labelled TP1 TP2 and TP3 connections are as follows:
  |TP2|-- RX
  |TP1|-- TX
  |TP3|-- GND

RX requires an external pullup to operate somewhere around 5 K ohm but your luck may vary the Uart is 1.8v

Set a static IP and set up a tftpserver and terminal.
power the router and quickly type the magic string “tpl” and press enter to break into u-boot
in the shell set the environment variables to enable tftp booting
setenv ipaddr (routerIP)
setenv serverip (server IP)
load you initramfs:
tftpboot 0x44000000 (serverIP):openwrt-qualcommax-ipq807x-tplink_x80-5g-initramfs-uImage.itb
boot your initramfs
bootm
upload your factory image to /tmp
format and install the factory image:
ubiformat /dev/mtd12 -y -f /tmp/openwrt-qualcommax-ipq807x-tplink_x80-5g-squashfs-factory.ubi

Note as this device swaps root partitions upon update your boot partition may be set as mtd13

Update script to mount factory tplink partition's for MAC recovery and device data.
Capture Labelmac from Factory_data partition.
Patch LAN from Labelmac.
Patch ART from Labelmac.
Set GPIO to make modem operational from boot.

GPIO fan tables work like the  stock device with three fan maps high active idle with a top fan speed of 6800 RPM.

High temp 70 deg speeds 6-8
Active temp 50 deg speeds 2-5
low temp 25 degree speed 0-1

Signed-off-by: jonathan brophy <professor_jonny@hotmail.com>
Link: https://github.com/openwrt/openwrt/pull/16329
Signed-off-by: Robert Marko <robimarko@gmail.com>
2025-04-22 13:25:40 +02:00

327 lines
6.8 KiB
Bash

PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1
RAMFS_COPY_BIN='fw_printenv fw_setenv head'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
xiaomi_initramfs_prepare() {
# Wipe UBI if running initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0
local rootfs_mtdnum="$( find_mtd_index rootfs )"
if [ ! "$rootfs_mtdnum" ]; then
echo "unable to find mtd partition rootfs"
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 "$rootfs_mtdnum"
ubiformat /dev/mtd$rootfs_mtdnum -y
ubidetach -m "$kern_mtdnum"
ubiformat /dev/mtd$kern_mtdnum -y
}
asus_initial_setup() {
# Remove existing linux and jffs2 volumes
[ "$(rootfs_type)" = "tmpfs" ] || return 0
ubirmvol /dev/ubi0 -N linux
ubirmvol /dev/ubi0 -N jffs2
}
remove_oem_ubi_volume() {
local oem_volume_name="$1"
local oem_ubivol
local mtdnum
local ubidev
mtdnum=$(find_mtd_index "$CI_UBIPART")
if [ ! "$mtdnum" ]; then
return
fi
ubidev=$(nand_find_ubi "$CI_UBIPART")
if [ ! "$ubidev" ]; then
ubiattach --mtdn="$mtdnum"
ubidev=$(nand_find_ubi "$CI_UBIPART")
fi
if [ "$ubidev" ]; then
oem_ubivol=$(nand_find_volume "$ubidev" "$oem_volume_name")
[ "$oem_ubivol" ] && ubirmvol "/dev/$ubidev" --name="$oem_volume_name"
fi
}
tplink_get_boot_part() {
local cur_boot_part
local args
# Try to find rootfs from kernel arguments
read -r args < /proc/cmdline
for arg in $args; do
local ubi_mtd_arg=${arg#ubi.mtd=}
case "$ubi_mtd_arg" in
rootfs|rootfs_1)
echo "$ubi_mtd_arg"
return
;;
esac
done
# Fallback to u-boot env (e.g. when running initramfs)
cur_boot_part="$(/usr/sbin/fw_printenv -n tp_boot_idx)"
case $cur_boot_part in
1)
echo rootfs_1
;;
0|*)
echo rootfs
;;
esac
}
tplink_do_upgrade() {
local new_boot_part
case $(tplink_get_boot_part) in
rootfs)
CI_UBIPART="rootfs_1"
new_boot_part=1
;;
rootfs_1)
CI_UBIPART="rootfs"
new_boot_part=0
;;
esac
fw_setenv -s - <<-EOF
tp_boot_idx $new_boot_part
EOF
remove_oem_ubi_volume ubi_rootfs
nand_do_upgrade "$1"
}
linksys_mx_pre_upgrade() {
local setenv_script="/tmp/fw_env_upgrade"
CI_UBIPART="rootfs"
boot_part="$(fw_printenv -n boot_part)"
if [ -n "$UPGRADE_OPT_USE_CURR_PART" ]; then
if [ "$boot_part" -eq "2" ]; then
CI_KERNPART="alt_kernel"
CI_UBIPART="alt_rootfs"
fi
else
if [ "$boot_part" -eq "1" ]; then
echo "boot_part 2" >> $setenv_script
CI_KERNPART="alt_kernel"
CI_UBIPART="alt_rootfs"
else
echo "boot_part 1" >> $setenv_script
fi
fi
boot_part_ready="$(fw_printenv -n boot_part_ready)"
if [ "$boot_part_ready" -ne "3" ]; then
echo "boot_part_ready 3" >> $setenv_script
fi
auto_recovery="$(fw_printenv -n auto_recovery)"
if [ "$auto_recovery" != "yes" ]; then
echo "auto_recovery yes" >> $setenv_script
fi
if [ -f "$setenv_script" ]; then
fw_setenv -s $setenv_script || {
echo "failed to update U-Boot environment"
return 1
}
fi
}
platform_check_image() {
return 0;
}
platform_pre_upgrade() {
case "$(board_name)" in
asus,rt-ax89x)
asus_initial_setup
;;
redmi,ax6|\
xiaomi,ax3600|\
xiaomi,ax9000)
xiaomi_initramfs_prepare
;;
esac
}
platform_do_upgrade() {
case "$(board_name)" in
aliyun,ap8220)
active="$(fw_printenv -n active)"
if [ "$active" -eq "1" ]; then
CI_UBIPART="rootfs1"
else
CI_UBIPART="rootfs2"
fi
nand_do_upgrade "$1"
;;
arcadyan,aw1000|\
cmcc,rm2-6|\
compex,wpq873|\
dynalink,dl-wrx36|\
edimax,cax1800|\
netgear,rax120v2|\
netgear,sxr80|\
netgear,sxs80|\
netgear,wax218|\
netgear,wax620|\
netgear,wax630)
nand_do_upgrade "$1"
;;
asus,rt-ax89x)
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
CI_ROOTPART="jffs2"
nand_do_upgrade "$1"
;;
buffalo,wxr-5950ax12)
CI_KERN_UBIPART="rootfs"
CI_ROOT_UBIPART="user_property"
buffalo_upgrade_prepare
nand_do_flash_file "$1" || nand_do_upgrade_failed
nand_do_restore_config || nand_do_upgrade_failed
buffalo_upgrade_optvol
;;
edgecore,eap102)
active="$(fw_printenv -n active)"
if [ "$active" -eq "1" ]; then
CI_UBIPART="rootfs2"
else
CI_UBIPART="rootfs1"
fi
# force altbootcmd which handles partition change in u-boot
fw_setenv bootcount 3
fw_setenv upgrade_available 1
nand_do_upgrade "$1"
;;
linksys,homewrk)
CI_UBIPART="rootfs"
remove_oem_ubi_volume ubi_rootfs
nand_do_upgrade "$1"
;;
linksys,mx4200v1|\
linksys,mx4200v2|\
linksys,mx4300)
linksys_mx_pre_upgrade "$1"
remove_oem_ubi_volume squashfs
nand_do_upgrade "$1"
;;
linksys,mx5300|\
linksys,mx8500)
linksys_mx_pre_upgrade "$1"
remove_oem_ubi_volume ubifs
nand_do_upgrade "$1"
;;
prpl,haze|\
qnap,301w)
CI_KERNPART="0:HLOS"
CI_ROOTPART="rootfs"
emmc_do_upgrade "$1"
;;
redmi,ax6|\
xiaomi,ax3600|\
xiaomi,ax9000)
# Make sure that UART is enabled
fw_setenv boot_wait on
fw_setenv uart_en 1
# Enforce single partition.
fw_setenv flag_boot_rootfs 0
fw_setenv flag_last_success 0
fw_setenv flag_boot_success 1
fw_setenv flag_try_sys1_failed 8
fw_setenv flag_try_sys2_failed 8
# Kernel and rootfs are placed in 2 different UBI
CI_KERN_UBIPART="ubi_kernel"
CI_ROOT_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
spectrum,sax1v1k)
CI_KERNPART="0:HLOS"
CI_ROOTPART="rootfs"
CI_DATAPART="rootfs_data"
emmc_do_upgrade "$1"
;;
tplink,deco-x80-5g|\
tplink,eap620hd-v1|\
tplink,eap660hd-v1)
tplink_do_upgrade "$1"
;;
yuncore,ax880)
active="$(fw_printenv -n active)"
if [ "$active" -eq "1" ]; then
CI_UBIPART="rootfs_1"
else
CI_UBIPART="rootfs"
fi
# force altbootcmd which handles partition change in u-boot
fw_setenv bootcount 3
fw_setenv upgrade_available 1
nand_do_upgrade "$1"
;;
zbtlink,zbt-z800ax)
local mtdnum="$(find_mtd_index 0:bootconfig)"
local alt_mtdnum="$(find_mtd_index 0:bootconfig1)"
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$mtdnum | cut -f 1 -d "|" | head -n1)"
# vendor firmware may swap the rootfs partition location, u-boot append: ubi.mtd=rootfs
# since we use fixed-partitions, need to force boot from the first rootfs partition
if [ "$part_num" -eq "1" ]; then
mtd erase /dev/mtd$mtdnum
mtd erase /dev/mtd$alt_mtdnum
fi
nand_do_upgrade "$1"
;;
zte,mf269)
CI_KERN_UBIPART="ubi_kernel"
CI_ROOT_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
zyxel,nbg7815)
local config_mtdnum="$(find_mtd_index 0:bootconfig)"
[ -z "$config_mtdnum" ] && reboot
part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|" | head -n1)"
if [ "$part_num" -eq "0" ]; then
CI_KERNPART="0:HLOS"
CI_ROOTPART="rootfs"
else
CI_KERNPART="0:HLOS_1"
CI_ROOTPART="rootfs_1"
fi
emmc_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;
esac
}
platform_copy_config() {
case "$(board_name)" in
prpl,haze|\
qnap,301w|\
spectrum,sax1v1k|\
zyxel,nbg7815)
emmc_copy_config
;;
esac
}