feat: add pcie dial support for rw350r-gl and other mtk_t7xx devices

This commit is contained in:
sfwtw 2025-04-27 15:37:04 +08:00
parent ce8cae0f69
commit f21eb3b3e9
7 changed files with 247 additions and 181 deletions

View File

@ -26,6 +26,8 @@ LUCI_DEPENDS:=+luci-compat \
+usbutils \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_PCI_SUPPORT:kmod-pcie_mhi \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_PCI_SUPPORT:pciutils \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT:umbim \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT:kmod-mtk-t7xx \
+PACKAGE_luci-app-qmodem_INCLUDE_ADD_QFIREHOSE_SUPPORT:qfirehose \
+PACKAGE_luci-app-qmodem_USE_TOM_CUSTOMIZED_QUECTEL_CM:quectel-CM-5G-M \
+PACKAGE_luci-app-qmodem_USING_QWRT_QUECTEL_CM_5G:quectel-CM-5G \
@ -34,7 +36,6 @@ LUCI_DEPENDS:=+luci-compat \
+jq +bc\
+coreutils +coreutils-stat
define Package/luci-app-qmodem/conffiles
/etc/config/qmodem
endef
@ -69,6 +70,10 @@ endchoice
bool "Add PCIe Modem SUPPORT"
default n
config PACKAGE_luci-app-qmodem_INCLUDE_ADD_MTK_T7XX_SUPPORT
bool "Add MTK-T7XX Modem PCI SUPPORT"
default n
config PACKAGE_luci-app-qmodem_INCLUDE_ADD_QFIREHOSE_SUPPORT
bool "Add Qfirehose SUPPORT"
default n

View File

@ -840,7 +840,6 @@
scs_tr.appendChild(td);
scs_tr.appendChild(td1);
status_th = this.createTH("<%:Status%>");
status_trh = this.createTRHeader();
status_trh.appendChild(status_th);
@ -875,7 +874,6 @@
this.scan_neighborcell();
});
this.setting_table.appendChild(header);
this.setting_table.appendChild(rat_tr);
this.setting_table.appendChild(pci_tr);

View File

@ -102,6 +102,52 @@ add_avalible_band_entry()
json_close_object
}
get_driver()
{
for i in $(find $modem_path -name driver);do
lsfile=$(ls -l $i)
type=${lsfile:0:1}
if [ "$type" == "l" ];then
link=$(basename $(ls -l $i | awk '{print $11}'))
case $link in
"mtk_t7xx")
mode="mtk_pcie"
break
;;
"qmi_wwan"*)
mode="qmi"
break
;;
"cdc_mbim")
mode="mbim"
break
;;
"cdc_ncm")
mode="ncm"
break
;;
"cdc_ether")
mode="ecm"
break
;;
"rndis_host")
mode="rndis"
break
;;
"mhi_netdev")
mode="mhi"
break
;;
*)
if [ -z "$mode" ]; then
mode="unknown"
fi
;;
esac
fi
done
echo $mode
}
get_dns()
{
@ -260,11 +306,23 @@ get_rat()
#return raw data
get_connect_status()
{
#get active pdp context
connect_status="No"
driver=$(get_driver)
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local config=$(umbim -d $mbim_port config)
local ipv4=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
local ipv6=$(echo "$config" | grep "ipv6address:" | awk '{print $2}' | cut -d'/' -f1)
disallow_ipv4="0.0.0.0"
if [ -n "$ipv4" ] && [ "$ipv4" != "$disallow_ipv4" ] || [ -n "$ipv6" ] && [ "$ipv6" != "::" ]; then
connect_status="Yes"
fi
else
at_cmd="AT+CGACT?"
expect="+CGACT:"
result=`at $at_port $at_cmd | grep $expect|tr '\r' '\n'`
connect_status="No"
for pdp_index in `echo "$result" | tr -d "\r" | awk -F'[,:]' '$3 == 1 {print $2}'`; do
at_cmd="AT+CGPADDR=%s"
at_cmd=$(printf "$at_cmd" "$pdp_index")
@ -286,6 +344,7 @@ get_connect_status()
connect_status="No"
fi
done
fi
add_plain_info_entry "connect_status" "$connect_status" "Connect Status"
}

View File

@ -71,53 +71,6 @@ EOF
esac
}
get_driver()
{
for i in $(find $modem_path -name driver);do
lsfile=$(ls -l $i)
type=${lsfile:0:1}
if [ "$type" == "l" ];then
link=$(basename $(ls -l $i | awk '{print $11}'))
case $link in
"mtk_t7xx")
mode="mtk_pcie"
break
;;
"qmi_wwan"*)
mode="qmi"
break
;;
"cdc_mbim")
mode="mbim"
break
;;
"cdc_ncm")
mode="ncm"
break
;;
"cdc_ether")
mode="ecm"
break
;;
"rndis_host")
mode="rndis"
break
;;
"mhi_netdev")
mode="mhi"
break
;;
*)
if [ -z "$mode" ]; then
mode="unknown"
fi
;;
esac
fi
done
echo $mode
}
unlock_sim()
{
pin=$1
@ -299,7 +252,16 @@ check_ip()
esac
;;
esac
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local config=$(umbim -d $mbim_port config)
ipaddr=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
ipaddr="$ipaddr $(echo "$config" | grep "ipv6address:" | awk '{print $2}' | cut -d'/' -f1)"
else
ipaddr=$(at "$at_port" "$check_ip_command" | grep +CGPADDR:)
fi
if [ -n "$ipaddr" ];then
if [ $mtk -eq 1 ] && echo "$ipv4_config" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
if [ "$pdp_type" = "ipv4v6" ];then
@ -313,7 +275,6 @@ check_ip()
ipv4=$(echo $ipaddr | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
if [ "$manufacturer" = "simcom" ];then
ipv4=$(echo $ipaddr | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | grep -v "0\.0\.0\.0" | head -n 1)
ipaddr=$(echo $ipaddr | sed 's/\./:/g' | sed 's/+CGPADDR: //g' | sed 's/'$ipv4',//g')
ipv6=$(echo $ipaddr | grep -oE "\b([0-9a-fA-F]{0,4}.){2,7}[0-9a-fA-F]{0,4}\b")
fi
disallow_ipv4="0.0.0.0"
@ -821,20 +782,51 @@ at_dial()
esac
m_debug "dialing vendor:$manufacturer;platform:$platform; $cgdcont_command ; $at_command"
at "${at_port}" "${cgdcont_command}"
if [ $mtk -eq 1 ];then
sleep 3
fi
[ $mtk -eq 1 ] && sleep 1
at "$at_port" "$at_command"
if [ $mtk -eq 1 ];then
sleep 3
[ $mtk -eq 1 ] && sleep 1
if [ "$driver" = "mtk_pcie" ];then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
umbim -d $mbim_port disconnect > /dev/null 2>&1
sleep 1
umbim -d $mbim_port connect > /dev/null 2>&1
sleep 1
fi
}
ip_change_fm350()
{
m_debug "ip_change_fm350"
local ipv4_config=""
local ipv4_dns1=""
local ipv4_dns2=""
local ipv6_dns1=""
local ipv6_dns2=""
local gateway=""
local netmask="255.255.255.0"
if [ "$driver" = "mtk_pcie" ]; then
mbim_port=$(echo "$at_port" | sed 's/at/mbim/g')
local config=$(umbim -d $mbim_port config)
ipv4_config=$(echo "$config" | grep "ipv4address:" | awk '{print $2}' | cut -d'/' -f1)
gateway=$(echo "$config" | grep "ipv4gateway:" | awk '{print $2}')
ipv4_dns1=$(echo "$config" | grep "ipv4dnsserver:" | head -n 1 | awk '{print $2}')
ipv4_dns2=$(echo "$config" | grep "ipv4dnsserver:" | tail -n 1 | awk '{print $2}')
if [ "$ipv4_dns1" = "$ipv4_dns2" ]; then
ipv4_dns2="119.29.29.29"
fi
ipv6_dns1=$(echo "$config" | grep "ipv6dnsserver:" | head -n 1 | awk '{print $2}')
ipv6_dns2=$(echo "$config" | grep "ipv6dnsserver:" | tail -n 1 | awk '{print $2}')
m_debug "umbim config: ipv4=$ipv4_config, gateway=$gateway, netmask=$netmask, dns1=$ipv4_dns1, dns2=$ipv4_dns2"
else
at_command="AT+CGPADDR=3"
local ipv4_config=$(at ${at_port} ${at_command} | cut -d, -f2 | grep -oE '[0-9]+.[0-9]+.[0-9]+.[0-9]+')
ipv4_config=$(at ${at_port} ${at_command} | cut -d, -f2 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+')
gateway="${ipv4_config%.*}.1"
local public_dns1_ipv4="223.5.5.5"
local public_dns2_ipv4="119.29.29.29"
local public_dns1_ipv6="2400:3200::1"
@ -860,11 +852,11 @@ ip_change_fm350()
ipv6_dns2="${public_dns2_ipv6}"
}
uci_ipv4=$(uci -q get network.$interface_name.ipaddr)
fi
uci set network.${interface_name}.proto='static'
uci set network.${interface_name}.ipaddr="${ipv4_config}"
uci set network.${interface_name}.netmask='255.255.255.0'
uci set network.${interface_name}.gateway="${ipv4_config%.*}.1"
uci set network.${interface_name}.netmask="${netmask}"
uci set network.${interface_name}.gateway="${gateway}"
uci set network.${interface_name}.peerdns='0'
uci -q del network.${interface_name}.dns
uci add_list network.${interface_name}.dns="${ipv4_dns1}"
@ -989,7 +981,7 @@ at_dial_monitor()
check_ip
if [ $connection_status -eq 0 ];then
at_dial
sleep 5
sleep 3
elif [ $connection_status -eq -1 ];then
unexpected_response_count=$((unexpected_response_count+1))
if [ $unexpected_response_count -gt 3 ];then

View File

@ -293,9 +293,7 @@ match_config()
[[ "$name" = *"rm500u-ea"* ]] && name="rm500u-ea"
#t99w175
[[ "$name" = *"mv31-w"* ]] && name="t99w175"
[[ "$name" = *"T99W175"* ]] && name="t99w175"
[[ "$name" = *"mv31-w"* ]] || [[ "$name" = *"T99W175"* ]] && name="t99w175"
[[ "$name" = *"T99W373"* ]] && name="t99w373"

View File

@ -1005,6 +1005,15 @@
"mbim"
]
},
"rw350r-gl": {
"manufacturer": "fibocom",
"platform": "mediatek",
"data_interface": "pcie",
"define_connect": "1",
"modes": [
"mbim"
]
},
"fm150-ae": {
"manufacturer": "fibocom",
"platform": "qualcomm",

View File

@ -58,6 +58,11 @@ get_mode()
"41") mode="rndis" ;;
*) mode="$mode_num" ;;
esac
driver=$(get_driver)
case "$driver" in
"mtk_pcie")
mode="mbim" ;;
esac
;;
*)
mode="$mode_num"